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: Discriminator values in HQL / Influencing joins.
PostPosted: Tue May 27, 2008 4:41 am 
Newbie

Joined: Wed May 21, 2008 9:54 am
Posts: 8
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
2.0
Mapping documents:
<hibernate-mapping auto-import="true" default-lazy="false" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:nhibernate-mapping-2.2">
<class name="MyProject.PaymentRunType, MyProject" table="PaymentRunType" discriminator-value="PaymentRunType">
<id name="ID" access="property" column="ID" type="Int64" unsaved-value="0">
<generator class="hilo">
<param name="max_lo">9</param>
</generator>
</id>
<discriminator column="BureauType" type="string" />
<version name="Version" access="property" column="Version" type="Int32" />
<property name="Name" access="property" type="String">
<column name="Name" length="100"/>
</property>
<many-to-one name="NotificationGroup" access="property" class="MyProject.NotificationGroup, MyProject" column="NotificationGroup" />
<many-to-one name="Template" access="property" class="MyProject.ConfigurationTemplate, MyProject" column="Template" />
<subclass name="MyProject.IndirectPaymentRunType, MyProject" discriminator-value="Indirect">
</subclass>
<subclass name="MyProject.ConfigurationTemplate, MyProject" discriminator-value="DefaultSet">
</subclass>
<subclass name="MyProject.DirectPaymentRunType, MyProject" discriminator-value="Direct">
</subclass>
</class>
</hibernate-mapping>


I'm running against SQL Server.
I need to order the data that I retrieve, the SQL I want is:
Code:
from PAYMENTRUN a 
  join PAYMENTRUNTYPE b on a.PAYMENTRUNTYPE = b.ID
  left outer join PAYMENTRUNTYPE d on b.TEMPLATE = d.ID
  join BATCH c on c.ID = a.BATCH 
where c.PAYMENTMETHOD = ?
order by isnull(b.NOTIFICATIONGROUP, d.NOTIFICATIONGROUP)


My HQL:
Code:
from PaymentRun as a
join a.PaymentRunType as b
left outer join b.Template as d
join a.Batch as c
where c.PaymentMethod = ?
order by isnull(b.NotificationGroup, d.NotificationGroup)


This results in the SQL:

Code:
from PAYMENTRUN a inner join PAYMENTRUNTYPE b on a.PAYMENTRUNTYPE = b.ID
             left outer join PAYMENTRUNTYPE d on b.TEMPLATE = d.ID
                     inner join BATCH c on a.BATCH = c.ID
where d.BUREAUTYPE = 'DefaultSet'     
   and c.PAYMENTMETHOD = ?
order by  isnull(b.NOTIFICATIONGROUP, d.NOTIFICATIONGROUP)


which obviously negates the left outer join. How can I influence the SQL that is being produced? The fix for the statement is relatively easy, but I have no idea how to control the discriminator column.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 29, 2008 3:19 am 
Newbie

Joined: Wed May 21, 2008 9:54 am
Posts: 8
any ideas? any documentation I can read ?


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.