-->
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: Query: Alias geht verloren
PostPosted: Fri Feb 24, 2006 6:03 am 
Newbie

Joined: Fri Feb 24, 2006 5:25 am
Posts: 2
Hibernate version: 3.1 RC1

Mapping documents: wir verwenden Annotationen, daher habe ich kein Mapping. Die Datenstruktur ist wie folgt:

RecoverBean:
UUID, RECOVER_CLASS, IS_MISSING
(Key: UUID)

RecoverLinkBean:
UUID, RECOVER_LINK, RECV_UUID
(Key: UUID)
(FK: RECV_UUID ist von RecoverBean.UUID)

meine HQL-Query sieht folgendermaßen aus:

delete RecoverLinkBean o where o in (Select i.objectId from RecoverLinkBean i inner join i.m_recoverParentHb b
where b.m_recoverClass = :recoverClass
and i.m_value = :linkValue and b.m_isMissing = false)

bzw. als (Select i from ....

Das Ergebnis ist in beiden Fällen das selbe:

The generated SQL (show_sql=true):

delete from RECV_LINK where UUID in
(select UUID from RECV_LINK recoverlin1_ inner join RECV_RECV recoverhb2_
on RECV_UUID=recoverhb2_.UUID
where RECV_CLASS= ? and RECOVERY_LINK= ? and IS_MISSING=0)

richtig wäre:
delete from RECV_LINK where UUID in
(select recoverlin1_.UUID from RECV_LINK recoverlin1_ inner join RECV_RECV recoverhb2_
on RECV_UUID=recoverhb2_.UUID
where RECV_CLASS= ? and RECOVERY_LINK= ? and IS_MISSING=0)

Da die Spalte UUID in beiden Tabellen vorkommt, ist die Angabe UUID im Subselect nicht eindeutig. Leider habe ich keinen Weg gefunden hibernate dazu zu bringen den alias einzutragen. Hat jemand eine Idee wie das zu lösen ist?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 02, 2006 8:51 am 
Expert
Expert

Joined: Tue Nov 23, 2004 7:00 pm
Posts: 570
Location: mostly Frankfurt Germany
Prüfe mal, ob der Fehler nicht bereits hier liegt:

Code:
delete RecoverLinkBean o where o in (Select i.objectId from RecoverLinkBean i

vermutlich eher
Code:
delete RecoverLinkBean o where o.objectId in (Select i.objectId from RecoverLinkBean i ...)


Gruß Sebastian

_________________
Best Regards
Sebastian
---
Training for Hibernate and Java Persistence
Tutorials for Hibernate, Spring, EJB, JSF...
eBook: Hibernate 3 - DeveloperGuide
Paper book: Hibernate 3 - Das Praxisbuch
http://www.laliluna.de


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.