hibernate - create entity for given relation one to one relationship, primary key of one table is foreign key of another table -


hierarchy

send me hoe create entities relation using hibernate jpa annotations

this onetoone mapping between user , profile

@entity public class user {  @id private int id; private string name;  @onetoone(fetch = fetchtype.lazy, mappedby = "user", cascade = cascadetype.all) private profile profile;  } 

profile entity

@entity public class profil{      @genericgenerator(name = "generator", strategy = "foreign",      parameters = @parameter(name = "property", value = "user"))     @id     @generatedvalue(generator = "generator")     private int id;      @onetoone(fetch = fetchtype.lazy)     @primarykeyjoincolumn     private user user;  } 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -