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: How to move condition in the WHERE clause to the FROM clause
PostPosted: Tue Mar 15, 2005 8:55 pm 
Beginner
Beginner

Joined: Thu Jan 06, 2005 6:21 pm
Posts: 23
Hibernate version:3.0

I have the following HQL query:

select parameter.data
from Repository repository
inner join repository.events as event
inner join event.parameter as parameter
where repository.id = :id and parameter.data is not null

that generate the following sql:

select parameter.data as parameter
from RepositoryTable repository
inner join RepositoryEventTable repositoryEvent
on repository.id=repositoryEvent.repositoryId
inner join EventTable event
on repositoryEvent.eventId=event.id
inner join ParameterTable parameter
on event.parameter=parameter.id
where repository.id='1' and parameter.data is not null

I'd like to move the condition in the WHERE clause in the FROM clause has it improves the performance of the query:

select parameter.data as parameter
from RepositoryTable repository
inner join RepositoryEventTable repositoryEvent
on repository.id=repositoryEvent.repositoryId and repository.id='1'
inner join EventTable event
on repositoryEvent.eventId=event.id
inner join ParameterTable parameter on event.parameter=parameter.id and parameter.data is not null

I didn't find a way to write a HQL query that will generate such a sql statement.
Is it possible? If yes, how do I do that.

Thanks,

Richard


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.