Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

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

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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 ]
 
Marshal
Posts: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
sorry about the unformatted code,
thanks james.
[ June 21, 2008: Message edited by: Odair Brentam ]
 
If you were a tree, what sort of tree would you be? This tiny ad is a poop beast.
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic