• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

EJB3 double reference issue.

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic