Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2007

Tip: Looking for answers? Try searching our database.

Inheritence issue with Hibernate

Thread view: 
vj - 10 Apr 2007 07:39 GMT
Hi,

I am new to hibernate and was experimenting with inheritance when i
ran into this problem. Basically i have modelled an entity named as
Tag which has 2 major attributes. TagTitle and TagData. Now Tag is
subclassed by many classes like LocationTag, CommentTag , ImageTag
etc. They all use the TagData field to store their data.

I have a configured Tag.hbm.xml file where i have declared the
subclasses but left there property set empty since all of then wil be
using the parent class getters and setters. below is an excerpt from
the file.

<class name="Tag" table="usertags" >
       <id name="TagID" column="tagid" type="long">
           <generator class="native"/>
       </id>
       <discriminator column="tagtype" type="string"/>

       <property name="TagData" column="tagdata" type="string"/>
       <property name="TagTitle" column="tagtitle" type="string"/>

       <subclass name="LocationTag" discriminator-
value="locationtag">
       </subclass>

The LocationTag uses the tagdata field to store the longitude and
latitude info in comma separated format. Like 22.345,-23.445

Now i have implemented a method in LocationTag class to parse and
retrive the Longitude & Latitudes (getLongitude , getLatitude)  from
the datafield. & corrosponding setMethods set the datafield in
appropriate format.

The issue is arising when i want to  use the Hibernate Query Language
to query locations whose longitude is say 22.23. I wrote following
code.

Query qr= session.createQuery(" from LocationTag as tg where
tg.Longitude=22.23");
    List<LocationTag> lst=qr.list();
    for(LocationTag ltg:lst)
    System.out.println(ltg.getLocationName());

I throws a Could not resolve property Longitute exception. So i am
unable to understand how describe a attriute which is infact derived
from another attribute.

If i am posting to a wrong groups please point me an appropriate
group.

Thanks,
Robert Klemme - 10 Apr 2007 11:50 GMT
> Hi,
>
[quoted text clipped - 46 lines]
> If i am posting to a wrong groups please point me an appropriate
> group.

Try to use "longitute" (lowercase first char) as property name in your
query.

    robert


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.