Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

single bean reference

 
siraj baig
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can i use a single bean to refer 2 tables.
in my bean i have properties username,password,firstname,lastname.
i want to store username and password to store in table1.
firstname and lastname have to store in table2.

<class name="org.hib.User" table="table1">
<id name="user_id" column="user_id">
<generator class="increment"/>
</id>
<property name="username" column="username"/>
<property name="password" column="password"/>
</class>

<class name="org.hib.User" table="table2">
<id name="user_id2" column="user_id2">
<generator class="increment"/>
</id>
<property name="firstname" column="firstname"/>
<property name="lastname" column="lastname"/>
</class>

Hibernate will not allow with two class names as same.
How can i achieve this.

Awaiting For Reply.
siraj.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you can do this, but it will still be just one <class> tag being used.

http://www.hibernate.org/hib_docs/v3/reference/en/html/mapping.html#mapping-declaration-join

There is also this option, but I don't think this is what you want, try the one above, and if that doesn't work like you want, then you can try this if that isn't
http://www.hibernate.org/hib_docs/v3/reference/en/html/mapping.html#mapping-entityname

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic