HQL Same table selection seems to override column with the latest value

208 Views Asked by At

I'am facing an issue with a native sql script in hibernate for testing, i'am loading data into a h2 database from a csv...

well the problem is when i do :

Select t1.name, t2.name FROM Person as t1, Person as t2  where t1.name='TOTO' and t2.name!='TITI'

I got the correct values, unless t1.name seems to be replaced by t2.name.

PS : the same script is working fine in SQLDevelopper.

Any clue or help would be appreciated :)

1

There are 1 best solutions below

4
On

I suspect the problem is that the aliases are being confused because they are the same. Try using as:

Select t1.name as name1, t2.name as name2
FROM Person t1, Person t2 
where t1.name = 'TOTO' and t2.name <> 'TITI';