You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@openjpa.apache.org by Pinaki Poddar <pp...@apache.org> on 2011/06/15 01:57:19 UTC

Re: Update statements not generated for a @OneToMany mapping (with persistent entity)

> What am I missing? 
> @OneToMany(mappedBy = "settlement", Cascade=CascadeType.REFRESH) 

Correct cascade type. (also the capital case on Cascade looks a suspect) 


-----
Pinaki 
--
View this message in context: http://openjpa.208410.n2.nabble.com/Update-statements-not-generated-for-a-OneToMany-mapping-with-persistent-entity-tp6476296p6476693.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: Update statements not generated for a @OneToMany mapping (with persistent entity)

Posted by Pinaki Poddar <pp...@apache.org>.
Also you should call voucher.setSettlement(s). JPA, by default, will not
manage bi-directional referential integrity. The application has to do it.
OpenJPA has a inverse manager -- you can activate that and most likely with
the current code you will see an exception. 

But asking OpenJPA to check referential integrity of bi-directional relation
is costly.  

-----
Pinaki 
--
View this message in context: http://openjpa.208410.n2.nabble.com/Update-statements-not-generated-for-a-OneToMany-mapping-with-persistent-entity-tp6476296p6476807.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: Update statements not generated for a @OneToMany mapping (with persistent entity)

Posted by Pinaki Poddar <pp...@apache.org>.
add cascade type MERGE, and call em.merge(settlement). Remember that merge
returns a Settlement different than its input argument.

Looks like a non-owning, owning side issue. Settlement is the non-owning
side of the relation. Owning side is the one that has the Foreign Key for
the relation in the database.  

-----
Pinaki 
--
View this message in context: http://openjpa.208410.n2.nabble.com/Update-statements-not-generated-for-a-OneToMany-mapping-with-persistent-entity-tp6476296p6476786.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Re: Update statements not generated for a @OneToMany mapping (with persistent entity)

Posted by infinity2heaven <in...@gmail.com>.
It's a typo in this post. code compiles just fine. Cascade type shouldn't
matter because I'm not persisting Voucher here (it's already a persistent
entity as it's reloaded in dao). As a test, CascadeType.All doesn't make any
difference.

--
View this message in context: http://openjpa.208410.n2.nabble.com/Update-statements-not-generated-for-a-OneToMany-mapping-with-persistent-entity-tp6476296p6476707.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.