-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Hibernate returning the wrong class
PostPosted: Fri Mar 26, 2004 11:05 am 
Newbie

Joined: Fri Mar 26, 2004 10:36 am
Posts: 1
Hi All,

I'm new to Hibernate so you may have to bare with me. I have 2 classes, Image and its subclass FullImage that are mapped in the following way:

<class name="uk.co.granitedigital.imagelib.core.Image" table="image">
<id name="id" type="long">
<generator class="native" >

</generator>
</id>
<property name="filename" column="filename" type="string" />
<property name="title" column="title" type="string" />
<property name="description" column="description" type="string" />
<property name="photographer" column="photographer" type="string" />
<property name="dateCreated" column="dateCreated" type="date" />
<joined-subclass name="uk.co.granitedigital.imagelib.core.FullImage" table="fullimage"
extends="uk.co.granitedigital.imagelib.core.Image" >
<key column="id" />
<map name="properties" >

<key column="imageId" />
<index column="type" type="long" />
<one-to-many class="uk.co.granitedigital.imagelib.core.ImageProperty" />
</map>
<property name="longDescription" type="string" />
</joined-subclass>

</class>

Now this seems to work, I can session.load either FullImages or just Images. My problem is that I want to be able to select a list of Images, I thought that session.find("from Image as image") would do the trick but this seems to return FullImages, how can I make Hibernate just return Images as I don't want it to make the extra join to get all the ImageProperty values?

Thanks

Harry


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 26, 2004 11:55 am 
Beginner
Beginner

Joined: Thu Nov 20, 2003 12:29 pm
Posts: 39
maybe this helps

Code:
fSession.find("from " + className + " as t where t.class = " + className);


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.