• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

hibernate mapping to subclass

 
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well, i found the solution

thanks
J
 
Be reasonable. You can't destroy everything. Where would you sit? How would you read a tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic