-->
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: Using 'discriminator' in 'order by'
PostPosted: Wed May 11, 2005 10:30 pm 
Newbie

Joined: Wed May 11, 2005 10:12 pm
Posts: 1
1) I have a query that looks something like this:

from Load l left join l.events e … so on…
order by e.eventLoadType, e.eventType, e.eventSchedOnDoorTime


2) Basically, Load has one to many ‘Events’. Each Event can either be a ‘LoadEvent’ or ‘UnloadEvent’. The ‘discriminator’ is defined in the ‘Event’ base class as follows:

<discriminator column="event_type" not-null="false" type="string" length="10"/>


3) On the Load object I have a ‘bag’ that looks like this:

<bag name="events" inverse="true" cascade="save-update" lazy="true" order-by="event_type">
<key column="event_load_gkey"/>
<one-to-many class="com.xyz.trips.business.entity.Event"/>
</bag>

When I run the query (#1 above), I get an exception saying ‘eventType’ is not a property of Event.

My question is – how do I use a ‘discriminator’ column in ‘order by’. I added a method called, getEventType(), in each of the classes (Event, LoadEvent, UnloadEvent), but that doesn’t help.

Please help! Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 23, 2005 3:01 am 
Beginner
Beginner

Joined: Fri Feb 11, 2005 12:03 pm
Posts: 48
Location: Kiel, Germany
Hi,

did you define the property eventType in the base class as a hibernate property. Otherwise I do not think hibernate will know it though it is a bean property.

If you want to use the discriminator column as a real property you have to define the mapping.

Perhaps this will work, too:
Code:
order by e.class


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.