This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills: The software developer's life manual and have John Sonmez on-line!
See this thread for details.
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EJB3 double reference issue.

 
Adam Koprowski
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If there is a need to keep track of Left & Right perhaps these can be subtypes.





Good luck,
Stu
 
Dianne Pop
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic