Search code examples
jpql

Can I call Static java method in JPQL


Ex: select distinct new JPQA.QueryResultObjectV1(space.name,spaceID) " + " from Space space,Building building,Floor floor join space.guid.oid spaceID " +........... N This works fine

Now when I try adding a MUL static function which is a static method available in classpath I get an error as below select distinct new JPQA.QueryResultObjectV1(space.name,JPQATestClient.Mul(10,20),spaceID) " + " from Space space,Building building,Floor floor join space.guid.oid spaceID


Solution

  • No you cannot. It is not possible to call any Java methods from the JPQL. In the end JPQL is converted to SQL and executed in database. Database cannot call your methods.