java - Generated POJOs with hibernate reverse engineering - How to create POJOs containing other objects? -
i'm using hibernate reverse engineering generate java classes mysql database. i'm using eclipse juno hibernate tools.
everything's going fine i'd take step further , i'm stuck.
let's reverse engineering generated class calls.java
, class users.java
.
/** * calls generated hbm2java */ @entity @table(name = "calls", catalog = "mydb") public class calls implements java.io.serializable { private string id; private string name; private date dateentered; private string modifieduserid; private string assigneduserid; ... } /** * users generated hbm2java */ @entity @table(name = "users", catalog = "mydb") public class users implements java.io.serializable { private string id; private string username; ... }
the properties modifieduserid
, assigneduserid
calls
id
's users
instance (in db foreign keys).
when set 1 foreign key (let's assigneduserid
), following definition of calls.java:
/** * calls generated hbm2java */ @entity @table(name = "calls", catalog = "mydb") public class calls implements java.io.serializable { private string id; private string name; private date dateentered; private string modifieduserid; private users users; ... }
as can see, loose name assigneduserid
.
however, if define 2 foreign keys (for assigneduserid
, modifieduserid
), property of type users first foreign key defined in table (in case, modifieduserid
).
/** * calls generated hbm2java */ @entity @table(name = "calls", catalog = "mydb") public class calls implements java.io.serializable { private string id; private string name; private date dateentered; private users users; private string assigneduserid; ... }
what i'd obtain in generated class calls.java
have modifieduserid
, assigneduserid
of type users
, not string
:
/** * calls generated hbm2java */ @entity @table(name = "calls", catalog = "mydb") public class calls implements java.io.serializable { private string id; private string name; private date dateentered; private users modifieduserid; private users assigneduserid; ... }
would have tip on how this? i've been checking lot of tutorials on how generate pojo's db jboss documentation reverse engineering; cannot find clue on how include object in generated pojo class.
thanks lot help!
kind regards,
bs_c3
Comments
Post a Comment