Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need to use table alias inside @Formula annotation in Hibernate

Tags:

java

hibernate

Is there a way to reference the current table's alias inside of a @Formula annotation in Hibernate? I want to use the RRN() function which takes in the table name or alias if the table is aliased as a parameter. I tried specifying the table name directly in the annotation but that won't work because the table is aliased.

I also tried {alias} hoping it may be available but it didn't work either.

@Formula("RRN({alias})")

I'm looking to generate a query like this:

select alias.column1, alias.column2, alias.column3, RRN(alias) from table as alias
like image 467
Gunny Avatar asked Sep 12 '16 22:09

Gunny


1 Answers

I believe it was fixed in Resolve {alias} in @Formula like Restrictions.sqlRestriction()

like image 83
sibnick Avatar answered Sep 20 '22 10:09

sibnick