HHH-12136 - Fix REF_CURSOR StoredProcedure Hibernate Type not known issue

This commit is contained in:
Andrea Boriero 2018-01-10 09:41:59 +00:00 committed by Vlad Mihalcea
parent 7edddae8db
commit 5387ffc717
1 changed files with 39 additions and 29 deletions

View File

@ -349,7 +349,16 @@ public class ProcedureParameterImpl<T>
if ( mode == ParameterMode.IN ) { if ( mode == ParameterMode.IN ) {
throw new ParameterMisuseException( "IN parameter not valid for output extraction" ); throw new ParameterMisuseException( "IN parameter not valid for output extraction" );
} }
try {
if ( mode == ParameterMode.REF_CURSOR ) {
if ( procedureCall.getParameterStrategy() == ParameterStrategy.NAMED ) {
return (T) statement.getObject( name );
}
else {
return (T) statement.getObject( startIndex );
}
}
else {
final Type hibernateType = determineHibernateType(); final Type hibernateType = determineHibernateType();
final int[] sqlTypes = hibernateType.sqlTypes( procedureCall.getSession().getFactory() ); final int[] sqlTypes = hibernateType.sqlTypes( procedureCall.getSession().getFactory() );
@ -360,7 +369,7 @@ public class ProcedureParameterImpl<T>
procedureCall.getParameterStrategy() == ParameterStrategy.NAMED && procedureCall.getParameterStrategy() == ParameterStrategy.NAMED &&
canDoNameParameterBinding( hibernateType ); canDoNameParameterBinding( hibernateType );
try {
if ( ProcedureParameterExtractionAware.class.isInstance( hibernateType ) ) { if ( ProcedureParameterExtractionAware.class.isInstance( hibernateType ) ) {
if ( useNamed ) { if ( useNamed ) {
return (T) ( (ProcedureParameterExtractionAware) hibernateType ).extract( return (T) ( (ProcedureParameterExtractionAware) hibernateType ).extract(
@ -386,6 +395,7 @@ public class ProcedureParameterImpl<T>
} }
} }
} }
}
catch (SQLException e) { catch (SQLException e) {
throw procedureCall.getSession().getFactory().getSQLExceptionHelper().convert( throw procedureCall.getSession().getFactory().getSQLExceptionHelper().convert(
e, e,