-->
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.  [ 6 posts ] 
Author Message
 Post subject: How to force alias in HQL
PostPosted: Mon Jun 20, 2016 5:46 pm 
Newbie

Joined: Mon Jun 20, 2016 5:19 pm
Posts: 3
Hello,

My HQL:

select full_name from person
or
select pp.full_name as FullNameStr from person pp

Hibernate generate the SQL:

select person0_.full_name as col_0_0_ from person person0_

In other words, it ignores my alias...

How could I force my own alias??

Or, is there any mechanics to force always the same alias? Sometimes, hibernate change the alias for the same query.

Thanks,


Top
 Profile  
 
 Post subject: Re: How to force alias in HQL
PostPosted: Tue Jun 21, 2016 2:23 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1638
Location: Romania
That's a logical alias. Behind the scenes, Hibernate must ensure that all SQL-level aliases are unique, so it replaces the logical alias with a physical one.

Why do you want to change it?

_________________
If you liked my answer, you are going to love my High-Performance Java Persistence book and my blog as well.


Top
 Profile  
 
 Post subject: Re: How to force alias in HQL
PostPosted: Tue Jun 21, 2016 10:16 am 
Newbie

Joined: Mon Jun 20, 2016 5:19 pm
Posts: 3
Because, for the same query, sometimes, hibernate changes the name of alias.

This is a problem, because DBA built a plan specific execution plan for this query, but when hibernates change the alias, Oracle doesn't find this execution plan, and the performance goes down again.

So, If there isn't any chance to force the alias, I would like to, at least, guarantee that hibernates never changes the alias.

Got it ?


Thanks


Top
 Profile  
 
 Post subject: Re: How to force alias in HQL
PostPosted: Tue Jun 21, 2016 10:36 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1638
Location: Romania
But then the issue is that Hibernate changes the alias. Can you provide a test case for it?

_________________
If you liked my answer, you are going to love my High-Performance Java Persistence book and my blog as well.


Top
 Profile  
 
 Post subject: Re: How to force alias in HQL
PostPosted: Wed Jun 22, 2016 11:11 am 
Newbie

Joined: Mon Jun 20, 2016 5:19 pm
Posts: 3
Well I don't have any test case to show to you, I just know that DBA reported that, after he had built a especial execution plan for the query, the performance had be improved, but, the next day, for the same query, the performance was decreased. When he investigate, he saw that the alias of columns and\or tables were changed, for the same query

I did on more attempting, using named query, but even so, I can't use my alias

So, I getting the conclusion that, the only way to guarantee that the query will be always the same query, is using the native query.

Unfortunately, this is the unique answer.

If you have any idea, I will appreciate.

Thank


Top
 Profile  
 
 Post subject: Re: How to force alias in HQL
PostPosted: Thu Jun 23, 2016 3:13 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1638
Location: Romania
I don't think you can fix that. What I need is the exact SQL queries that have been generated differently, so that we have something to start from.

_________________
If you liked my answer, you are going to love my High-Performance Java Persistence book and my blog as well.


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