-->
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: Hibernate produce different SQL for every query
PostPosted: Wed Feb 19, 2014 4:03 pm 
Newbie

Joined: Wed Feb 19, 2014 3:58 pm
Posts: 2
Why does hibernate use weird names like person0_ and ID1_0_0_ in the below generated query?

Code:
    select
        person0_.ID as ID1_0_0_,
        person0_.firstName as firstNam3_0_0_,
        person0_.lastName as lastName4_0_0_,
        person0_.salary as salary5_0_0_,
    from
        Person person0_
    where
        person0_.ID=?


Doesn't this cause the underlying database to fetch a new plan everytime since the query is different each time?


Top
 Profile  
 
 Post subject: Re: Hibernate produce different SQL for every query
PostPosted: Sun Feb 23, 2014 5:24 am 
Senior
Senior

Joined: Tue Oct 28, 2008 10:39 am
Posts: 196
This produces the same query everytime because it's a PreparedStatement.


Top
 Profile  
 
 Post subject: Re: Hibernate produce different SQL for every query
PostPosted: Sun Feb 23, 2014 12:56 pm 
Newbie

Joined: Wed Feb 19, 2014 3:58 pm
Posts: 2
My question was regarding the query string being different because of the presence of aliases like:

Code:
person0_.ID as ID1_0_0_


If you run the same operation of reading by primary key, Hibernate generates a different query each time because the aliases are different each time such that next time it would be ID2_0_0_ and yet another time it would be ID3_0_0_

If it was ID1_0_0_ everytime, there would be no problem


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.