Tuesday, November 5, 2013

Using native database functions in JPQL

Java Persistence Query language(JPQL) is defined by the Java Persistence API(JPA) and it is very easy to use for querying database with entities. But sometime it becomes pretty hard to find similar function in JPQL which is available only in a particular database. To overcome this issue, it has an option and it is the FUNC function of JPQL.

This function basically interpret the database native functions with the JPQL. The procedure to use the function is like below.


I am using the TO_NUMBER() as an example here, but it can be any function.

SELECT o FROM result o WHERE FUNC('TO_NUMBER', e.total) < 90

No comments:

Get function name programaticaly - Python

This little piece of code will help you to get the function name programatically. This is very helpful when you are implementing the debug...