Gunny
Gunny

Reputation: 164

Need to use table alias inside @Formula annotation in 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

Upvotes: 7

Views: 1734

Answers (1)

sibnick
sibnick

Reputation: 4305

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

Upvotes: 4

Related Questions