Search code examples
javaoracle-databasespring-bootspring-data-jpaquerydsl

Call Oracle Function and set it to entity


Please forgive me if this issue already exist. Here is my scenario:

class EntityA {
  private EntityB entityB;
  ...
}

I need to call functionA(entityB.value) (this is oracle function)

The way I resolved it is I will get list of EntityA, then loops it

for(EntityA entityA : entityAList){
  // then I will call oracle function here
  callOracleFunction(entityA.entityB.value)
}

It resolved the problem, but the query will be called multiple times. How can I query it in one go ? Like this query

SELECT a.name,
functionA(b.value) AS "Result"
FROM EntityA a
LEFT JOIN EntityB b ON a.id = b.id;

Thank you in advance :)


Solution

  • I think using @Formula is better way for this situation, at least it's better than my current solution. Thanks