This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes EJB3 double reference issue. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "EJB3 double reference issue." Watch "EJB3 double reference issue." New topic
Author

EJB3 double reference issue.

Adam Koprowski
Greenhorn

Joined: Oct 22, 2007
Posts: 3
Hello,
I'm having an issue with referencing an entity bean twice from other bean. Here's a simplified version of what I have:



Now, to begin with, is this allowed? If not, how can I achieve something like that? If so, then why am I getting errors while trying to delete objects of type Block? :-). I tried to play around with different cascading settings but nothing seems to help. I'm getting an error:

where the identifier is the key of the block which indeed occurs twice in the Items table, for two different items, but I do not see why should that be a problem.

Any help greatly appreciated!
Cheers,
Adam
Dianne Pop
Greenhorn

Joined: May 07, 2003
Posts: 8
I have the exact same problem right now

Did you find a way to fix this?

I can't seem to use the mappings correctly for this case!
Stu Quinn
Ranch Hand

Joined: Feb 27, 2009
Posts: 35
If there is a need to keep track of Left & Right perhaps these can be subtypes.





Good luck,
Stu
Dianne Pop
Greenhorn

Joined: May 07, 2003
Posts: 8
Unfortunately, splitting into LeftItem and RightItem would have no business meaning and it would be very confusing. I actually have several such fields, in several "parent" entities, and it could get really complicated really fast.

What I did do is remove the optional=false constraint, and it seems to work correctly now. The only problem is that I have to remember to always set the parent (Block), because the DB will not complain about it missing.

 
wood burning stoves
 
subject: EJB3 double reference issue.
 
Similar Threads
EJB relationship mapping OneToMany bidrectional
EJB3/JPA @OneToOne
JPA2.0 CascadeType.ALL doesn't cascade persist
"Removing a detached instance" exception while updating the entity
uses a non-entity as target entity in relationship attribute