Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » Reference entity in other EJB module
Reference entity in other EJB module [message #540654] Wed, 16 June 2010 20:52 Go to next message
drrevis is currently offline drrevisFriend
Messages: 2
Registered: June 2010
Junior Member
I have an EAR project that has two EJB modules. Each has it's own persistence unit which references a separate database. One database contains the content entities I'm using and the other contains information about the users who will be accessing that content. I can access each database/EJB module individually without any problems.

I now need to create a new configuration entity in the user database that is owned by a user, but references some of the content entities from the other EJB module.

In the properties for the user EJB module, I set the dependency on the content EJB module and also have the project reference set and so I thought that would allow me to access the content entities. However, when I try, I get an error on the @ManyToOne mapping saying that the "Target entity is not an Entity." It is specifically listed in the persistence.xml file, though, and is definitely an entity in the other module.

@ManyToOne(targetEntity = com.test.configuration.CommonConfig.class)
private CommonConfig mainConfig;


I'm still fairly new to understanding how all of this works and I'm hoping that there's just something basic that I'm not doing correctly. From everything I've read, I should be able to package entities in two different modules and reference them with no problems, so any help in figuring out what I'm doing wrong would be much appreciated!

Also, if there's a better place to post this question, please let me know.

Thanks!
Renee
Re: Reference entity in other EJB module [message #540984 is a reply to message #540654] Thu, 17 June 2010 21:17 Go to previous message
Neil Hauge is currently offline Neil HaugeFriend
Messages: 475
Registered: July 2009
Senior Member
Renee wrote on Wed, 16 June 2010 16:52

From everything I've read, I should be able to package entities in two different modules and reference them with no problems, so any help in figuring out what I'm doing wrong would be much appreciated!



Hi Renee,

An EJB JAR must have a persistence.xml and hence a persistence unit defined (so far so good), but you cannot map relationships between these persistence units using JPA.

JPA does not support the ability to reference an entity defined in one persistence unit from an entity defined in a second persistence unit, which is the scenario you have described here.

There are various ways to work around this scenario. One would be to work with these independent persistence units in your application and use data obtained from one PU to query against the other PU. Another option would be to use some sort of database linking on the DB side, and use 1 persistence unit to map to this linked DB content. How this would work would depend on what database you are using.

You may also want to look for different possible approaches on the eclipselink-users mailing list or the EclipseLink forum - http://www.eclipse.org/forums/index.php?t=thread&frm_id= 111& .

Neil
Previous Topic:XML Catalog entries not exported in preferences?
Next Topic:JS code assist problems[SOLVED]
Goto Forum:
  


Current Time: Sat Apr 20 03:36:55 GMT 2024

Powered by FUDForum. Page generated in 0.02406 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top