-->
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: Subquery in select clause duplicate alias error
PostPosted: Mon Jun 15, 2015 10:35 am 
Newbie

Joined: Mon Jun 15, 2015 10:16 am
Posts: 1
Hi, I'm getting this error:
"Encountered a duplicated sql alias [] during auto-discovery of a native-sql query" using JPA2 with Hibernate in the following select clause, it's a subquery that will return values to a column filtered by the main query row id.
I'm using a native query to achieve the result. It works great in sql server console.
It's something like this..

Code:
select ENTITY.ID_ENTITY as entity ,d.CODE as code, st.STATE as state,
(select
Case
When b.a = 'True' Then '-A'
Else ''
End +
Case
When b.b = 'True' Then '-B'
Else ''
End +
Case
When b.c = 'True' Then '-C'
Else ''
End +
Case
When b.d = 'True' Then '-D'
Else ''
End +
Case
When b.e = 'True' Then '-E'
Else ''
End +
Case
When b.f = 'True' Then '-F'
Else ''
End
from BASE b where b.ID_ENTITY = ENTITY.ID_ENTITY)
,'1','2' ,'3','4' from DIMO d
inner join STATE st on (d.ID_DIMO = st.ID_STATE)
inner join ENTITY on (ENTITY.ID_DIMO = d.ID_DIMO)
where d.ID_CRISIS=1 AND (st.ID_STATE =2 OR st.ID_STATE =3)


How can I make the subquery in the select clause work? Can anyone help?

Thanks


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.