hibernate - create entity for given relation one to one relationship, primary key of one table is foreign key of another table -
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
Post a Comment