简体   繁体   中英

Function inside Hibernate Criteria

I'm trying to create a Hibernate criteria filter that uses a database (Oracle) function as part of the Where .

So far, I have it working with sqlRestriction...but I can't seem to ge the {alias} to work (I'm trying to feed in the "id" of the current row as a function argument).

eg, my function takes 2 arguments:

def query = {
and {
sqlRestriction("F_FGAC('SomeText',{alias}.id) = 'Y'")
}
}

The error I get is:

No signature of method: basecas_05.EmplController.sqlRestriction() is applicable for argument types: (java.lang.String, java.lang.String) values: [F_FGAC('SomeText',{alias}.id) = 'Y'...].

Any idea what the problem is here...?

I see the problem...it's not with the alias, it's that I was not putting the right arguments into the method...this works:

sqlRestriction("F_FGAC('SomeText',{alias}.id) = 'Y'")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM