• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

hibernate mapping to subclass

 
jay roy
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys
this must be simple, but i am new to this filed.

This is my xml file in hibernate

<hibernate-mapping>

<class name="com.aoc.judiciary.framework.ValueObjects.TestVO" table="FMT_CASEADR">
<id name="userId" column="ATTYID">
<generator class="native"/>
</id>

<property name="ssn" column="ATTYCASESEQNO"/>
<property name="name" column="ATTYCASESTREET"/>

</class>


<sql-query name="getParties">
<return alias="ResultSet" class="com.aoc.judiciary.framework.ValueObjects.TestVO"/>
Select * from DBWD.FMT_CASEADR WHERE ATTYID = ?
</sql-query>

</hibernate-mapping>


+++++++++++++++++++++++
Now Inside TestVO , i have only the userId field like this

public class TestVO
{

private String userId;
setuserId(), getuserId() methods

private TestReturnVO trvo; //i have another class in which i want to store the results
setTrvo() ; getTrvo() methods


}

+++++++++++++++++++++++++++++
Class TestReturnVO contains
private String ssn;
private String name;
and set() and get() for both the fields
+++++++++++++++++++++++++

Now based on the above scenario , can i modify my above xml like this:

<hibernate-mapping>

<class name="com.aoc.judiciary.framework.ValueObjects.TestVO" table="FMT_CASEADR">
<id name="userId" column="ATTYID">
<generator class="native"/>
</id>

<property name="trvo.ssn" column="ATTYCASESEQNO"/> // CHANGED to trvo.ssn
<property name="trvo.name" column="ATTYCASESTREET"/> // CHANGED to trvo.name

</class>


<sql-query name="getParties">
<return alias="ResultSet" class="com.aoc.judiciary.framework.ValueObjects.TestVO"/>
Select * from DBWD.FMT_CASEADR WHERE ATTYID = ?
</sql-query>

</hibernate-mapping>

Basically , i want to store the values from the table in a subclass object(TestReturnVO trvo)
the above code is not working and i have no idea why. any help would be greatly appreciated

thanks
Jay
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of taking lots of time to reply, I am going to have you look at the hibernate.org website and look for inheritance mapping. What you are doing will not work.

Hibernate doc page to read
http://www.hibernate.org/hib_docs/v3/reference/en/html/mapping.html#mapping-declaration-subclass

Good Luck

Mark
 
jay roy
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well, i found the solution

thanks
J
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic