1

Basically what I'm trying to do is a call to Oracle stored procedure using Hibernate. Procedure takes two IN parameters, creates object of Oracle type User (it has two fields - id and name) and returns it via OUT parameter. My Java call is:

ProcedureCall call = session.createStoredProcedureCall("get_obj");
call.registerParameter(1, Long.class, ParameterMode.IN).bindValue(1L);
call.registerParameter(2, String.class, ParameterMode.IN).bindValue("John");
call.registerParameter(3, User.class, ParameterMode.OUT);

Java class is simple POJO class with same fields, setters and getters. Is there a way to convert Oracle types to Java and vice versa?

1 Answer 1

1

As per Using Customized Type Mappings you should create a User class by implementing SQLData interface:

public class User implements SQLData {
  // fields
  // readSQL
  // writeSQL
}

and then use Connection.setTypeMap() to setup the mapping for new User type.

Sign up to request clarification or add additional context in comments.

1 Comment

is it same in hibernate,for pure jdbc I use it but in hibernate?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.