java - How to save changes to @OneToOne relationship -


this part of eclipselink jpa entity:

public class task implements serializable {  @joincolumn(name = "idtransaction", referencedcolumnname = "serial_no") @onetoone(cascade = cascadetype.all) private transaction idtransaction;  } 

when persist or merge task entity, transaction entity doesn't update changes it.

somebody told me use : (cascade = cascadetype.all) didn't work.

so, how can save changes both entites 1 persist/merge call ?

i update database way:

if (getentitymanager().isopen()) {             gettransaction().begin();             entity = em.merge(entity);             gettransaction().commit();         } 

"entity" task entity talking about, updates not relations.

i found solution, these available cascades:

cascadetype.merge cascadetype.persist cascadetype.detach cascadetype.remove cascadetype.refresh cascadetype.all 

if have entity "usa" list of "states" entites , made changes states have add:

@onetomany(cascade = cascadetype.merge) private state stateid; 

and merge usa entity , not every changed state. cascadetype.merge, should automatically update you.


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -