Getting ClassCastException (Boolean to String) while calling Store procedure

130 Views Asked by At

I am using Hibernate ProcedureCall to run a stored procedure:

Session session = 
HibernateUtilities.getSessionFactory().openSession();

try {
    session.beginTransaction();

    ProcedureCall procedureCall =                           
     session.createStoredProcedureCall(Strings.
     StoredProcedureNames.EXHIBITORCREATEUSER_SP);

   System.out.println("@@@@@@@@@@@@@@@@@@@     " + community);

    procedureCall.registerParameter("username", String.class,ParameterMode.IN);
    procedureCall.getParameterRegistration("username").bindValue(community.getUsername());

    procedureCall.registerParameter("first_name", String.class,ParameterMode.IN);
    procedureCall.getParameterRegistration("first_name").bindValue(community.getFirst_name());

    procedureCall.registerParameter("last_name", String.class,ParameterMode.IN);
    procedureCall.getParameterRegistration("last_name").bindValue(community.getLast_name());

    procedureCall.registerParameter("mobile", String.class,ParameterMode.IN);
    procedureCall.getParameterRegistration("mobile").bindValue(community.getMobile());

    procedureCall.registerParameter("account_type", Integer.class,ParameterMode.IN);
    procedureCall.getParameterRegistration("account_type").bindValue(2);

    procedureCall.registerParameter("inserted_id", PostgresUUIDType.class, ParameterMode.OUT);

    UUID total = (UUID) procedureCall.getOutputs().getOutputParameterValue("inserted_id");

I get the following exception at last Line of above code:

(java.lang.ClassCastException: java.lang.Boolean cannot be cast to java.lang.String at org.hibernate.type.descriptor.java.StringTypeDescriptor.unwrap(StringTypeDescriptor.java:22))

I didn't use any Boolean Variable in my pojo class

What could be the reason behind error, kindly help me.

0

There are 0 best solutions below