I am looking into the viability of porting our applications to EclipseLink
from Hibernate. One thing I haven't been able to easily figure out is how
to register custom SQL functions. For example, we have some setup in
Hibernate for use with Oracle Text by extending the OracleDialect and
registering them like this:
registerFunction("score", new StandardSQLFunction("score",
registerFunction("contains", new StandardSQLFunction("contains",
I'm assuming to do the same in EclipseLink we would extend the
Oracle10Platform and somehow register them in there, but I can't see any
obvious ways of doing that. I also haven't been able to find any
documentation that describes how one would do this.
Are there any examples or documentation anywhere I can look at to learn
how to do this?
In EclipseLink you can define your own expression operators using the
ExpressionOperator class and registering these with the platform or with
ExpressionOperator. You can then use them in EclipseLink Expression
queries using the Expression getFunction(int) API.
You cannot currently use them in JPQL however (please log a bug for that).
You can also any database function using getFunction(String) and just give
the database function name. You could also use native SQL for the query.