I have been trying to call a function that i created using jpa but i keep getting this error
(org.eclipse.persistence.exceptions.DatabaseException Internal Exception: com.microsoft.sqlserver.jdbc.SQLServerException: 'udf_searchEmployeeLeaves' is not a recognized built-in function name. Error Code: 195)
public List<EmployeeLeaves> searchEmployeeLeaves(String str) throws EmployeeLeavesException {
try {
Query query = em.createNativeQuery("SELECT udf_searchEmployeeLeaves(?1) FROM LAB ");
query.setParameter(1, str);
return query.getResultList();
} catch (Exception e) {
throw new EmployeeLeavesException("[searchEmployeeLeaves-ERROR]: " + e.getMessage());
}
}
I think the call is incorrect.
You have to call the table function like this:
Query query = em.createNativeQuery("SELECT * FROM udf_searchEmployeeLeaves(?1)");