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

hibernate mapping error

 
raj baig
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can i map a single table to two java beans(same setters and getters).
when i am trying to access it shows some mapping error.the code is

<class name="abc.login.User" table="myuser1">
<id name="user_id" column="user_id">
<generator class="assigned"/>
</id>
<property name="account_id" column="account_id"/>
<property name="uname" column="uname"/>
<property name="pwd" column="pwd"/>
</class>
<class name="xyz.login.User" table="myuser1">
<id name="user_id" column="user_id">
<generator class="assigned"/>
</id>
<property name="account_id" column="account_id"/>
<property name="uname" column="uname"/>
<property name="pwd" column="pwd"/>
</class>


here the tables is one. beans are of type user with the same setters and getters stored in different packages
 
Janhavi Namshikar
Ranch Hand
Posts: 85
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Can you post the error message that you are getting.
 
Janhavi Namshikar
Ranch Hand
Posts: 85
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Try this, use the entity-name attribute to differentiate between the two instances.

<class name="MyClass" table="mytable"
entity-name="somename">
<property name="prop" column="col">
</class>


<class name="MyClass" table="mytable"
entity-name="othername">
<property name="prop" column="col">
</class>
 
raj baig
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Janhavi Namshikar,

Thank u. it's fine working.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic