-->
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.  [ 3 posts ] 
Author Message
 Post subject: Problem with distinct in subselect
PostPosted: Tue Sep 27, 2005 8:13 am 
Newbie

Joined: Tue Sep 27, 2005 7:38 am
Posts: 4
Hibernate version: 3.0.5

Database: PostgreSQL 7.4.8

Generated SQL:
Quote:
select company0_.id as id5_, company0_.companysize as companys2_5_,
company0_.country_id as country3_5_, company0_.name1 as name4_5_,
company0_.name2 as name5_5_, company0_.address1 as address6_5_,
company0_.address2 as address7_5_, company0_.zip as zip5_, company0_.city
as city5_, company0_.phone as phone5_, company0_.fax as fax5_,
company0_.logo as logo5_, company0_.email as email5_, company0_.homepage as
homepage5_, company0_.founded as founded5_, company0_.employees as
employees5_, company0_.valid as valid5_, company0_.remark as remark5_,
company0_.created as created5_, company0_.createdby as createdby5_,
company0_.updated as updated5_, company0_.updatedby as updatedby5_,
company0_.description as descrip23_5_, company0_.desc_keys as desc24_5_
from ixtenso_owner.company company0_
where ( company0_.id in (
select distinct company1_.id
from ixtenso_owner.company company1_,
left outer join company_ref_sector sectors2_ on company1_.id=sectors2_.ref
left outer join ixtenso_owner.sector sector3_ on sectors2_.id_sector=sector3_.id,
left outer join company_ref_keyword keywords4_ on company1_.id=keywords4_.ref
left outer join ixtenso_owner.keyword keyword5_ on keywords4_.id_keyword=keyword5_.id
where ( lower(company1_.name1) like '%schilder%' or
lower(company1_.name2) like '%schilder%' or
lower(company1_.description) like '%schilder%' or
lower(company1_.desc_keys) like '%schilder%' or
lower(sector3_.value) like '%schilder%' or
lower(keyword5_.value) like '%schilder%' )
and ( sector3_.id in (1, 2))
)
)
and company0_.valid=true
order by lower(company0_.name1);



Hello,

I'm having a problem with following HQL Query:

Quote:
from Company c
where c.id in
(
select distinct(c.id)
from Company c
left join c.sectors s
left join c.keywords k
where ( lower(c.name1) like :searchText
or lower(c.name2) like :searchText
or lower(c.description) like :searchText
or lower(c.descKeys) like :searchText
or lower(s.name) like :searchText
or lower(k.name) like :searchText
)
and s.id in (:sectorId)
)
and c.valid = true
order by lower(c.name1)


This one results in the above SQL-Statement which has 2 errors, that prevent it from returning a result. The following exception is thrown:

WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 0, SQLState: 42601
2005-09-27 14:08:02,016 ERROR org.hibernate.util.JDBCExceptionReporter - ERROR: syntax error at or near "outer"

As you can see there is comma in the subquery after the "from"-clause just before "left outer join" as well as one after the second "left outer join". If I remove them the query runs as expected. But how can I tune the HQL to get a proper statement?

Running the subquery on its own reveals the correct SQL-Query. So it obviously has something to do with using the statement as a subquery.

Thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 27, 2005 11:52 am 
Beginner
Beginner

Joined: Wed Apr 13, 2005 10:34 am
Posts: 38
I think this is a known bug in 3.0.5. It is fixed in 3.1beta1.

See http://opensource2.atlassian.com/projects/hibernate/browse/HHH-564


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 27, 2005 2:10 pm 
Newbie

Joined: Tue Sep 27, 2005 7:38 am
Posts: 4
Actually in my case it still doesn't work. Neither with 3.1 beta 3 nor with CVS.


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