• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate HQL query problem

 
Fadjer One
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have a very strong problem with an HQL query and I'm looking for your precious help ;-)

My HQL query is :
select distinct articles from com.iserva.model.Article as articles
inner join articles.column as column
inner join articles.state as state
where
articles.language =:language
and articles.state.stepId =:stepId
and articles.state.status =:status
and articles.column =:column

The SQL Equivalent generated by Hibernate is :
select distinct ... article fields ... from ARTICLE article0_ inner join `COLUMN` column1_ on article0_.COLUMN_ID=column1_.COLUMN_ID inner join OS_CURRENTSTEP state2_ on article0_.WORKFLOW_ID=state2_.entry_id where (article0_.LANGUAGE=? )and(state2_.step_Id=? )and(state2_.status=? )and(column1_.COLUMN_ID=? )

The problem is taht the SQL query return the good results, but not the HQL one !

I have used the P6Spy framework to obtain the exact query the Hibernate motor launches (query with all values not '?' chars) and I still having the same problem : SQL is good not the HQL one

Whant does hibernate do after executing like my SQL query ? any idea please ?

After many searching hours I have found this alternative that works fine, the difference is that I do no join on Column object :

select distinct articles from com.iserva.model.Article as articles
inner join articles.state as state
where
articles.language =:language
and articles.state.stepId =:stepId
and articles.state.status =:status
and articles.column =:column

Why this work and not the first one ?

Thanks in advance.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic