V
vj
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,
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,