hibernate - @OneToOne - Can't persist the second entity -


this first post , have problem hibernate @onetoone mapping. following link first example. have 2 model classes calls user , profile. every time, user registry, want create new user account given info , default profile user. problem code able generate user account, not profile. structure following:

public class user {      @onetoone(fetch=fetchtype.lazy, mappedby="profileuser", cascade=cascadetype.all)     private profile profile; }  public class profile {      @id     @generatedvalue(strategy=generationtype.identity)     @column(name="profile_id")     private long profileid;      @onetoone     @primarykeyjoincolumn     private user profileuser; }  @repository public userdao { public void createuser(user user) {         currentsession().save(user);     } }  @service  public userservice {      @autowire userdao dao;          @transactional     public void createuser(user user) {          profile profile = profile.createinstance();         profile.setprofileuser(user);           user.setprofile(profile);         dao.createuser(user);     }  } 

i @ console , detect 1 query run persist account not profile. have no clue wrong.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -