• 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

cascade operations only populate foreign key for the owning side of the relationship

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Helo, I have two entities with the following mappings


When this method completes Q1 and A1 are persistes but the foreign key IS NULL
but for A2 and Q2 the foreign key is INSERTED WITH THE CORRECT VALUE.

The point is: the foreign key is filled only if the entity passed to the persit() is an "owning side" entity.

Is it not possible to use the cascade operations when persisting a entity of the "inverse side" of the relationship and have the foreign key populated?
[ June 21, 2008: Message edited by: Odair Brentam ]
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Brentam", please check your private messages for an important administrative matter.

Also, please be sure to use UBB code tags when posting code to the forums. Unformatted code is extermely hard to read and many people that might be able to help you will just move along. Please read this for more information.

You can go back and change your post to add code tags by clicking the .
 
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In JPA you must maintain bi-directional relationship in your application or object mode code. Basically you code should work if you set methods also set the inverse relationship (careful of the infinite loop).

see,
http://en.wikibooks.org/wiki/Java_Persistence/Relationships
> One side of the relationship is not updated after updating the other side
 
Odair Brentam
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry about the unformatted code,
thanks james.
[ June 21, 2008: Message edited by: Odair Brentam ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic