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