I'm trying to use a custom object in oracledb as IN parameter for a procedure, but I'm having issues sending it from my java application
I tried mapping the DTO class directly in
query.registerStoredProcedureParameter(1, CustomClass.class, ParameterMode.IN);
Also I didn't find this particular question in stackoverflow
Java code:
private String executeSP(CustomClass dto) {
StoredProcedureQuery query = em.createStoredProcedureQuery("PACKAGE.SOMEPROCEDURE");
query.registerStoredProcedureParameter(1, CustomClass.class, ParameterMode.IN);
query.registerStoredProcedureParameter(2, String.class, ParameterMode.OUT);
// Pass the parameter values
query.setParameter(1, dto);
// Execute query
query.execute();
// Get output parameters
String response = (String) query.getOutputParameterValue(2);
System.out.println(response);
return response;
}
PL SQL Procedure:
PROCEDURE SOMEPROCEDURE (
P_DTO IN DTOTYPE (previously created)
P_RESULT OUT VARCHAR2);
Expected result: Hibernate maps the dto to the oracle custom object
Actual result: org.hibernate.MappingException: Unknown entity
Copyright Notice:Content Author:「DarioJ」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/57381082/how-to-map-java-class-to-oracle-custom-type-to-use-as-in-parameter-in-stored-pro