-->
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.  [ 1 post ] 
Author Message
 Post subject: Request for qualifying strange behaviour
PostPosted: Thu Jan 14, 2010 10:18 am 
Newbie

Joined: Thu Jan 14, 2010 10:05 am
Posts: 1
Hello all,

Can you help me qualifying this strange behaviour with a subquery.

Here is the class mapping : a single class

Code:
@Entity
public class Document implements Serializable {
   @Id
   @Column(name="idDocument", nullable=false)
   private Long id;
   @ManyToOne(optional=true,fetch=FetchType.LAZY)
   @JoinColumn(name="idDocumentPere",nullable=true, updatable=false)
   private Document documentPere;
}


Query 1 :
select count(d) from Document d where d.documentPere is null
gives the following SQL:
Code:
    select
        count(document0_.idDocument) as col_0_0_
    from
        document document0_
    where
        document0_.idDocumentPere is null

OK

However when reusing the previous query as a subquery
HQL:
select 1, (select count(d) from Document d where d.documentPere is null) from Document"

SQL:
Code:
  select
        1 as col_0_0_,
        (select
            count(document1_.idDocument)
        from
            document document1_,
            document document2_
        where
            document1_.idDocumentPere=document2_.idDocument
            and (
                document1_.idDocumentPere is null
            )) as col_1_0_
    from
        document document0_

The subquery is obviously incorrect and always returns 0 results.

Is it a known bug or an undocumented limitation in the use of subquerys ?

Hibernate version: 3.2.4 SP1 with hibernatespatial (using PostgisDialect)
RDBMS: Postgres 8.2

Thanks for your help and the great job you do.


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

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.