-->
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.  [ 4 posts ] 
Author Message
 Post subject: 'case' expression in SQL-statement
PostPosted: Mon Jan 19, 2004 7:27 am 
Newbie

Joined: Mon Jan 19, 2004 6:39 am
Posts: 2
Hello!

I'm using hibernate2.1 and firebirdsql (dialect=net.sf.hibernate.dialect.InterbaseDialect). I have problem for inheritance.
I have 3 classes - Person and Organization inherits Subject (joined-subclass).

For expression:

session.load(Subject.class, new Integer(1));

, hibernate generates next SQL-query:

select organiza1_.ID as ID0_, organiza1_.FULLNAME as FULLNAME2_0_, organiza1_.BRIEFNAME as BRIEFNAME2_0_, organiza1_.ORGPHONE as ORGPHONE2_0_, organiza1_.ORGMAILTO as ORGMAILTO2_0_, organiza1_.ID_PARENT as ID_PARENT2_0_, organiza2_.ID as ID1_, organiza2_.FULLNAME as FULLNAME2_1_, organiza2_.BRIEFNAME as BRIEFNAME2_1_, organiza2_.ORGPHONE as ORGPHONE2_1_, organiza2_.ORGMAILTO as ORGMAILTO2_1_, organiza2_.ID_PARENT as ID_PARENT2_1_, subject0_.id as id2_,

case
when subject0__1.ID is not null
then 1
when subject0__2.ID is not null
then 2
when subject0_.id is not null
then 0
end as clazz_2_,

subject0__1.FIRSTNAME as FIRSTNAME1_2_, subject0__1.MIDDLENAME as MIDDLENAME1_2_, subject0__1.LASTNAME as LASTNAME1_2_, subject0__1.BIRTHDAY as BIRTHDAY1_2_, subject0__1.SEX as SEX1_2_, subject0__1.HOMEPHONE as HOMEPHONE1_2_, subject0__1.MOBILEPHONE as MOBILEPH8_1_2_, subject0__1.PRIVATEMAILTO as PRIVATEM9_1_2_, subject0__2.FULLNAME as FULLNAME2_2_, subject0__2.BRIEFNAME as BRIEFNAME2_2_, subject0__2.ORGPHONE as ORGPHONE2_2_, subject0__2.ORGMAILTO as ORGMAILTO2_2_, subject0__2.ID_PARENT as ID_PARENT2_2_ from SUBJECT subject0_ left outer join PERSON subject0__1 on subject0_.id=subject0__1.ID left outer join ORGANIZATION subject0__2 on subject0_.id=subject0__2.ID left outer join ORGANIZATION organiza1_ on subject0__2.ID_PARENT=organiza1_.ID left outer join SUBJECT organiza1__1 on organiza1_.ID=organiza1__1.id left outer join ORGANIZATION organiza2_ on organiza1_.ID_PARENT=organiza2_.ID left outer join SUBJECT organiza2__1 on organiza2_.ID=organiza2__1.id where subject0_.id=?

, but Interbase/Firebird not support 'case' expression in SQL-statement.
What to do?

_________________
Yakov Revyakin
"Ukrgazprompolis" Ins. Co.
"UGP-Net" ISP


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 19, 2004 8:07 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Apparently Firebird 1.5 is supposed to support ANSI-style CASE.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 19, 2004 8:39 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
It does, I am using it here and it works very nice.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 19, 2004 10:42 am 
Newbie

Joined: Mon Jan 19, 2004 6:39 am
Posts: 2
Thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.