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.