HHH-8413 - Rename ProcedureResults -> ProcedureOutputs
This commit is contained in:
parent
49a2ee04b9
commit
59d2bff81b
|
@ -141,7 +141,7 @@ public interface ProcedureCall extends BasicQueryContract, SynchronizeableQuery
|
|||
*
|
||||
* @return The ProcedureResult representation
|
||||
*/
|
||||
public ProcedureResult getResult();
|
||||
public ProcedureOutputs getResult();
|
||||
|
||||
/**
|
||||
* Extract the disconnected representation of this call. Used in HEM to allow redefining a named query
|
||||
|
|
|
@ -23,20 +23,20 @@
|
|||
*/
|
||||
package org.hibernate.procedure;
|
||||
|
||||
import org.hibernate.result.Result;
|
||||
import org.hibernate.result.Outputs;
|
||||
|
||||
/**
|
||||
* Specialization of the {@link Result} contract providing access to the stored procedure's registered
|
||||
* Specialization of the {@link org.hibernate.result.Outputs} contract providing access to the stored procedure's registered
|
||||
* output parameters.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface ProcedureResult extends Result {
|
||||
public interface ProcedureOutputs extends Outputs {
|
||||
/**
|
||||
* Retrieve the value of an OUTPUT parameter by the parameter's registration memento.
|
||||
* <p/>
|
||||
* Should NOT be called for parameters registered as REF_CURSOR. REF_CURSOR parameters should be
|
||||
* accessed via the returns (see {@link #getNextReturn}
|
||||
* accessed via the returns (see {@link #getNextOutput}
|
||||
*
|
||||
* @param parameterRegistration The parameter's registration memento.
|
||||
*
|
|
@ -53,7 +53,7 @@ import org.hibernate.procedure.NamedParametersNotSupportedException;
|
|||
import org.hibernate.procedure.ParameterRegistration;
|
||||
import org.hibernate.procedure.ProcedureCall;
|
||||
import org.hibernate.procedure.ProcedureCallMemento;
|
||||
import org.hibernate.procedure.ProcedureResult;
|
||||
import org.hibernate.procedure.ProcedureOutputs;
|
||||
import org.hibernate.result.spi.ResultContext;
|
||||
import org.hibernate.type.Type;
|
||||
|
||||
|
@ -75,7 +75,7 @@ public class ProcedureCallImpl extends AbstractBasicQueryContractImpl implements
|
|||
|
||||
private Set<String> synchronizedQuerySpaces;
|
||||
|
||||
private ProcedureResultImpl outputs;
|
||||
private ProcedureOutputsImpl outputs;
|
||||
|
||||
/**
|
||||
* The no-returns form.
|
||||
|
@ -367,7 +367,7 @@ public class ProcedureCallImpl extends AbstractBasicQueryContractImpl implements
|
|||
}
|
||||
|
||||
@Override
|
||||
public ProcedureResult getResult() {
|
||||
public ProcedureOutputs getResult() {
|
||||
if ( outputs == null ) {
|
||||
outputs = buildOutputs();
|
||||
}
|
||||
|
@ -375,7 +375,7 @@ public class ProcedureCallImpl extends AbstractBasicQueryContractImpl implements
|
|||
return outputs;
|
||||
}
|
||||
|
||||
private ProcedureResultImpl buildOutputs() {
|
||||
private ProcedureOutputsImpl buildOutputs() {
|
||||
// todo : going to need a very specialized Loader for this.
|
||||
// or, might be a good time to look at splitting Loader up into:
|
||||
// 1) building statement objects
|
||||
|
@ -419,7 +419,7 @@ public class ProcedureCallImpl extends AbstractBasicQueryContractImpl implements
|
|||
i += parameter.getSqlTypes().length;
|
||||
}
|
||||
|
||||
return new ProcedureResultImpl( this, statement );
|
||||
return new ProcedureOutputsImpl( this, statement );
|
||||
}
|
||||
catch (SQLException e) {
|
||||
throw getSession().getFactory().getSQLExceptionHelper().convert(
|
||||
|
|
|
@ -28,23 +28,23 @@ import java.sql.ResultSet;
|
|||
|
||||
import org.hibernate.engine.jdbc.cursor.spi.RefCursorSupport;
|
||||
import org.hibernate.procedure.ParameterRegistration;
|
||||
import org.hibernate.procedure.ProcedureResult;
|
||||
import org.hibernate.result.Return;
|
||||
import org.hibernate.result.internal.ResultImpl;
|
||||
import org.hibernate.procedure.ProcedureOutputs;
|
||||
import org.hibernate.result.Output;
|
||||
import org.hibernate.result.internal.OutputsImpl;
|
||||
|
||||
/**
|
||||
* Implementation of ProcedureResult. Defines centralized access to all of the results of a procedure call.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class ProcedureResultImpl extends ResultImpl implements ProcedureResult {
|
||||
public class ProcedureOutputsImpl extends OutputsImpl implements ProcedureOutputs {
|
||||
private final ProcedureCallImpl procedureCall;
|
||||
private final CallableStatement callableStatement;
|
||||
|
||||
private final ParameterRegistrationImplementor[] refCursorParameters;
|
||||
private int refCursorParamIndex;
|
||||
|
||||
ProcedureResultImpl(ProcedureCallImpl procedureCall, CallableStatement callableStatement) {
|
||||
ProcedureOutputsImpl(ProcedureCallImpl procedureCall, CallableStatement callableStatement) {
|
||||
super( procedureCall, callableStatement );
|
||||
this.procedureCall = procedureCall;
|
||||
this.callableStatement = callableStatement;
|
||||
|
@ -83,7 +83,7 @@ public class ProcedureResultImpl extends ResultImpl implements ProcedureResult {
|
|||
@Override
|
||||
public boolean indicatesMoreReturns() {
|
||||
return super.indicatesMoreReturns()
|
||||
|| ProcedureResultImpl.this.refCursorParamIndex < ProcedureResultImpl.this.refCursorParameters.length;
|
||||
|| ProcedureOutputsImpl.this.refCursorParamIndex < ProcedureOutputsImpl.this.refCursorParameters.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -92,21 +92,21 @@ public class ProcedureResultImpl extends ResultImpl implements ProcedureResult {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Return buildExtendedReturn() {
|
||||
ProcedureResultImpl.this.refCursorParamIndex++;
|
||||
final ParameterRegistrationImplementor refCursorParam = ProcedureResultImpl.this.refCursorParameters[refCursorParamIndex];
|
||||
protected Output buildExtendedReturn() {
|
||||
ProcedureOutputsImpl.this.refCursorParamIndex++;
|
||||
final ParameterRegistrationImplementor refCursorParam = ProcedureOutputsImpl.this.refCursorParameters[refCursorParamIndex];
|
||||
ResultSet resultSet;
|
||||
if ( refCursorParam.getName() != null ) {
|
||||
resultSet = ProcedureResultImpl.this.procedureCall.getSession().getFactory().getServiceRegistry()
|
||||
resultSet = ProcedureOutputsImpl.this.procedureCall.getSession().getFactory().getServiceRegistry()
|
||||
.getService( RefCursorSupport.class )
|
||||
.getResultSet( ProcedureResultImpl.this.callableStatement, refCursorParam.getName() );
|
||||
.getResultSet( ProcedureOutputsImpl.this.callableStatement, refCursorParam.getName() );
|
||||
}
|
||||
else {
|
||||
resultSet = ProcedureResultImpl.this.procedureCall.getSession().getFactory().getServiceRegistry()
|
||||
resultSet = ProcedureOutputsImpl.this.procedureCall.getSession().getFactory().getServiceRegistry()
|
||||
.getService( RefCursorSupport.class )
|
||||
.getResultSet( ProcedureResultImpl.this.callableStatement, refCursorParam.getPosition() );
|
||||
.getResultSet( ProcedureOutputsImpl.this.callableStatement, refCursorParam.getPosition() );
|
||||
}
|
||||
return new ResultSetReturnImpl( extractResults( resultSet ) );
|
||||
return new ResultSetOutputImpl( extractResults( resultSet ) );
|
||||
}
|
||||
}
|
||||
|
|
@ -24,18 +24,18 @@
|
|||
package org.hibernate.result;
|
||||
|
||||
/**
|
||||
* Common contract for individual return objects which can be either results ({@link ResultSetReturn}) or update
|
||||
* counts ({@link UpdateCountReturn}).
|
||||
* Common contract for individual return objects which can be either results ({@link ResultSetOutput}) or update
|
||||
* counts ({@link UpdateCountOutput}).
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface Return {
|
||||
public interface Output {
|
||||
/**
|
||||
* Determine if this return is a result (castable to {@link ResultSetReturn}). The alternative is that it is
|
||||
* an update count (castable to {@link UpdateCountReturn}).
|
||||
* Determine if this return is a result (castable to {@link ResultSetOutput}). The alternative is that it is
|
||||
* an update count (castable to {@link UpdateCountOutput}).
|
||||
*
|
||||
* @return {@code true} indicates that {@code this} can be safely cast to {@link ResultSetReturn}), other wise
|
||||
* it can be cast to {@link UpdateCountReturn}.
|
||||
* @return {@code true} indicates that {@code this} can be safely cast to {@link ResultSetOutput}), other wise
|
||||
* it can be cast to {@link UpdateCountOutput}.
|
||||
*/
|
||||
public boolean isResultSet();
|
||||
}
|
|
@ -24,29 +24,29 @@
|
|||
package org.hibernate.result;
|
||||
|
||||
/**
|
||||
* Represents the result of executing a JDBC statement accounting for mixing of result sets and update counts hiding the
|
||||
* complexity (IMO) of how this is exposed in the JDBC API.
|
||||
*
|
||||
* A result is made up of group of {@link Return} objects, each representing a single result set or update count.
|
||||
* Represents the outputs of executing a JDBC statement accounting for mixing of result sets and update counts
|
||||
* hiding the complexity (IMO) of how this is exposed in the JDBC API.
|
||||
* <p/>
|
||||
* The outputs are exposed as a group of {@link Output} objects, each representing a single result set or update count.
|
||||
* Conceptually, Result presents those Returns as an iterator.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface Result {
|
||||
public interface Outputs {
|
||||
/**
|
||||
* Retrieve the current return.
|
||||
* Retrieve the current Output object.
|
||||
*
|
||||
* @return The current return.
|
||||
* @return The current Output object. Can be {@code null}
|
||||
*/
|
||||
public Return getCurrentReturn();
|
||||
public Output getCurrentOutput();
|
||||
|
||||
/**
|
||||
* Are there any more returns associated with this result?
|
||||
* Are there any more Output objects associated with {@code this}?
|
||||
*
|
||||
* @return {@code true} means there are more returns available via {@link #getNextReturn()}; {@code false}
|
||||
* indicates that calling {@link #getNextReturn()} will certainly result in an exception.
|
||||
* @return {@code true} means there are more Output objects available via {@link #getNextOutput()}; {@code false}
|
||||
* indicates that calling {@link #getNextOutput()} will certainly result in an exception.
|
||||
*/
|
||||
public boolean hasMoreReturns();
|
||||
public boolean hasMoreOutput();
|
||||
|
||||
/**
|
||||
* Retrieve the next return
|
||||
|
@ -54,7 +54,7 @@ public interface Result {
|
|||
* @return The next return.
|
||||
*
|
||||
* @throws NoMoreReturnsException Thrown if there are no more returns associated with this Result, as would
|
||||
* have been indicated by a {@code false} return from {@link #hasMoreReturns()}.
|
||||
* have been indicated by a {@code false} return from {@link #hasMoreOutput()}.
|
||||
*/
|
||||
public Return getNextReturn() throws NoMoreReturnsException;
|
||||
public Output getNextOutput() throws NoMoreReturnsException;
|
||||
}
|
|
@ -30,7 +30,7 @@ import java.util.List;
|
|||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface ResultSetReturn extends Return {
|
||||
public interface ResultSetOutput extends Output {
|
||||
/**
|
||||
* Consume the underlying {@link java.sql.ResultSet} and return the resulting List.
|
||||
*
|
|
@ -28,7 +28,7 @@ package org.hibernate.result;
|
|||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface UpdateCountReturn extends Return {
|
||||
public interface UpdateCountOutput extends Output {
|
||||
/**
|
||||
* Retrieve the associated update count
|
||||
*
|
|
@ -42,17 +42,17 @@ import org.hibernate.loader.custom.CustomQuery;
|
|||
import org.hibernate.loader.custom.sql.SQLQueryReturnProcessor;
|
||||
import org.hibernate.loader.spi.AfterLoadAction;
|
||||
import org.hibernate.result.NoMoreReturnsException;
|
||||
import org.hibernate.result.Result;
|
||||
import org.hibernate.result.ResultSetReturn;
|
||||
import org.hibernate.result.Return;
|
||||
import org.hibernate.result.UpdateCountReturn;
|
||||
import org.hibernate.result.Outputs;
|
||||
import org.hibernate.result.ResultSetOutput;
|
||||
import org.hibernate.result.Output;
|
||||
import org.hibernate.result.UpdateCountOutput;
|
||||
import org.hibernate.result.spi.ResultContext;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class ResultImpl implements Result {
|
||||
private static final Logger log = CoreLogging.logger( ResultImpl.class );
|
||||
public class OutputsImpl implements Outputs {
|
||||
private static final Logger log = CoreLogging.logger( OutputsImpl.class );
|
||||
|
||||
private final ResultContext context;
|
||||
private final PreparedStatement jdbcStatement;
|
||||
|
@ -60,7 +60,7 @@ public class ResultImpl implements Result {
|
|||
|
||||
private CurrentReturnState currentReturnState;
|
||||
|
||||
public ResultImpl(ResultContext context, PreparedStatement jdbcStatement) {
|
||||
public OutputsImpl(ResultContext context, PreparedStatement jdbcStatement) {
|
||||
this.context = context;
|
||||
this.jdbcStatement = jdbcStatement;
|
||||
|
||||
|
@ -95,7 +95,7 @@ public class ResultImpl implements Result {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Return getCurrentReturn() {
|
||||
public Output getCurrentOutput() {
|
||||
if ( currentReturnState == null ) {
|
||||
return null;
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ public class ResultImpl implements Result {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMoreReturns() {
|
||||
public boolean hasMoreOutput() {
|
||||
// prepare the next return state
|
||||
try {
|
||||
final boolean isResultSet = jdbcStatement.getMoreResults();
|
||||
|
@ -117,12 +117,12 @@ public class ResultImpl implements Result {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Return getNextReturn() {
|
||||
if ( !hasMoreReturns() ) {
|
||||
public Output getNextOutput() {
|
||||
if ( !hasMoreOutput() ) {
|
||||
throw new NoMoreReturnsException( "Results have been exhausted" );
|
||||
}
|
||||
|
||||
return getCurrentReturn();
|
||||
return getCurrentOutput();
|
||||
}
|
||||
|
||||
private List extractCurrentResults() {
|
||||
|
@ -158,7 +158,7 @@ public class ResultImpl implements Result {
|
|||
private final boolean isResultSet;
|
||||
private final int updateCount;
|
||||
|
||||
private Return rtn;
|
||||
private Output rtn;
|
||||
|
||||
protected CurrentReturnState(boolean isResultSet, int updateCount) {
|
||||
this.isResultSet = isResultSet;
|
||||
|
@ -177,14 +177,14 @@ public class ResultImpl implements Result {
|
|||
return updateCount;
|
||||
}
|
||||
|
||||
public Return getReturn() {
|
||||
public Output getReturn() {
|
||||
if ( rtn == null ) {
|
||||
rtn = buildReturn();
|
||||
}
|
||||
return rtn;
|
||||
}
|
||||
|
||||
protected Return buildReturn() {
|
||||
protected Output buildReturn() {
|
||||
if ( log.isDebugEnabled() ) {
|
||||
log.debugf(
|
||||
"Building Return [isResultSet=%s, updateCount=%s, extendedReturn=%s",
|
||||
|
@ -204,10 +204,10 @@ public class ResultImpl implements Result {
|
|||
);
|
||||
|
||||
if ( isResultSet() ) {
|
||||
return new ResultSetReturnImpl( extractCurrentResults() );
|
||||
return new ResultSetOutputImpl( extractCurrentResults() );
|
||||
}
|
||||
else if ( getUpdateCount() >= 0 ) {
|
||||
return new UpdateCountReturnImpl( updateCount );
|
||||
return new UpdateCountOutputImpl( updateCount );
|
||||
}
|
||||
else if ( hasExtendedReturns() ) {
|
||||
return buildExtendedReturn();
|
||||
|
@ -222,15 +222,15 @@ public class ResultImpl implements Result {
|
|||
return false;
|
||||
}
|
||||
|
||||
protected Return buildExtendedReturn() {
|
||||
protected Output buildExtendedReturn() {
|
||||
throw new IllegalStateException( "State does not define extended returns" );
|
||||
}
|
||||
}
|
||||
|
||||
protected static class ResultSetReturnImpl implements ResultSetReturn {
|
||||
protected static class ResultSetOutputImpl implements ResultSetOutput {
|
||||
private final List results;
|
||||
|
||||
public ResultSetReturnImpl(List results) {
|
||||
public ResultSetOutputImpl(List results) {
|
||||
this.results = results;
|
||||
}
|
||||
|
||||
|
@ -257,10 +257,10 @@ public class ResultImpl implements Result {
|
|||
}
|
||||
}
|
||||
|
||||
protected static class UpdateCountReturnImpl implements UpdateCountReturn {
|
||||
protected static class UpdateCountOutputImpl implements UpdateCountOutput {
|
||||
private final int updateCount;
|
||||
|
||||
public UpdateCountReturnImpl(int updateCount) {
|
||||
public UpdateCountOutputImpl(int updateCount) {
|
||||
this.updateCount = updateCount;
|
||||
}
|
||||
|
|
@ -33,16 +33,15 @@ import org.hibernate.dialect.Dialect;
|
|||
import org.hibernate.engine.spi.Mapping;
|
||||
import org.hibernate.mapping.AuxiliaryDatabaseObject;
|
||||
import org.hibernate.procedure.ProcedureCall;
|
||||
import org.hibernate.procedure.ProcedureResult;
|
||||
import org.hibernate.result.ResultSetReturn;
|
||||
import org.hibernate.result.Return;
|
||||
import org.hibernate.procedure.ProcedureOutputs;
|
||||
import org.hibernate.result.ResultSetOutput;
|
||||
import org.hibernate.result.Output;
|
||||
import org.hibernate.dialect.H2Dialect;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.hibernate.testing.junit4.ExtraAssertions;
|
||||
|
||||
import static org.hibernate.testing.junit4.ExtraAssertions.assertTyping;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
@ -171,10 +170,10 @@ public class StoredProcedureTest extends BaseCoreFunctionalTestCase {
|
|||
session.beginTransaction();
|
||||
|
||||
ProcedureCall query = session.createStoredProcedureCall( "user");
|
||||
ProcedureResult procedureResult = query.getResult();
|
||||
Return currentReturn = procedureResult.getCurrentReturn();
|
||||
assertNotNull( currentReturn );
|
||||
ResultSetReturn resultSetReturn = assertTyping( ResultSetReturn.class, currentReturn );
|
||||
ProcedureOutputs procedureResult = query.getResult();
|
||||
Output currentOutput = procedureResult.getCurrentOutput();
|
||||
assertNotNull( currentOutput );
|
||||
ResultSetOutput resultSetReturn = assertTyping( ResultSetOutput.class, currentOutput );
|
||||
String name = (String) resultSetReturn.getSingleResult();
|
||||
assertEquals( "SA", name );
|
||||
|
||||
|
@ -188,10 +187,10 @@ public class StoredProcedureTest extends BaseCoreFunctionalTestCase {
|
|||
session.beginTransaction();
|
||||
|
||||
ProcedureCall query = session.createStoredProcedureCall( "findOneUser" );
|
||||
ProcedureResult procedureResult = query.getResult();
|
||||
Return currentReturn = procedureResult.getCurrentReturn();
|
||||
assertNotNull( currentReturn );
|
||||
ResultSetReturn resultSetReturn = assertTyping( ResultSetReturn.class, currentReturn );
|
||||
ProcedureOutputs procedureResult = query.getResult();
|
||||
Output currentOutput = procedureResult.getCurrentOutput();
|
||||
assertNotNull( currentOutput );
|
||||
ResultSetOutput resultSetReturn = assertTyping( ResultSetOutput.class, currentOutput );
|
||||
Object result = resultSetReturn.getSingleResult();
|
||||
assertTyping( Object[].class, result );
|
||||
String name = (String) ( (Object[]) result )[1];
|
||||
|
@ -207,10 +206,10 @@ public class StoredProcedureTest extends BaseCoreFunctionalTestCase {
|
|||
session.beginTransaction();
|
||||
|
||||
ProcedureCall query = session.createStoredProcedureCall( "findUsers" );
|
||||
ProcedureResult procedureResult = query.getResult();
|
||||
Return currentReturn = procedureResult.getCurrentReturn();
|
||||
assertNotNull( currentReturn );
|
||||
ResultSetReturn resultSetReturn = assertTyping( ResultSetReturn.class, currentReturn );
|
||||
ProcedureOutputs procedureResult = query.getResult();
|
||||
Output currentOutput = procedureResult.getCurrentOutput();
|
||||
assertNotNull( currentOutput );
|
||||
ResultSetOutput resultSetReturn = assertTyping( ResultSetOutput.class, currentOutput );
|
||||
List results = resultSetReturn.getResultList();
|
||||
assertEquals( 3, results.size() );
|
||||
|
||||
|
@ -244,10 +243,10 @@ public class StoredProcedureTest extends BaseCoreFunctionalTestCase {
|
|||
ProcedureCall query = session.createStoredProcedureCall( "findUserRange" );
|
||||
query.registerParameter( "start", Integer.class, ParameterMode.IN ).bindValue( 1 );
|
||||
query.registerParameter( "end", Integer.class, ParameterMode.IN ).bindValue( 2 );
|
||||
ProcedureResult procedureResult = query.getResult();
|
||||
Return currentReturn = procedureResult.getCurrentReturn();
|
||||
assertNotNull( currentReturn );
|
||||
ResultSetReturn resultSetReturn = assertTyping( ResultSetReturn.class, currentReturn );
|
||||
ProcedureOutputs procedureResult = query.getResult();
|
||||
Output currentOutput = procedureResult.getCurrentOutput();
|
||||
assertNotNull( currentOutput );
|
||||
ResultSetOutput resultSetReturn = assertTyping( ResultSetOutput.class, currentOutput );
|
||||
List results = resultSetReturn.getResultList();
|
||||
assertEquals( 1, results.size() );
|
||||
Object result = results.get( 0 );
|
||||
|
@ -269,10 +268,10 @@ public class StoredProcedureTest extends BaseCoreFunctionalTestCase {
|
|||
ProcedureCall query = session.createStoredProcedureCall( "findUserRange" );
|
||||
query.registerParameter( 1, Integer.class, ParameterMode.IN ).bindValue( 1 );
|
||||
query.registerParameter( 2, Integer.class, ParameterMode.IN ).bindValue( 2 );
|
||||
ProcedureResult procedureResult = query.getResult();
|
||||
Return currentReturn = procedureResult.getCurrentReturn();
|
||||
assertNotNull( currentReturn );
|
||||
ResultSetReturn resultSetReturn = assertTyping( ResultSetReturn.class, currentReturn );
|
||||
ProcedureOutputs procedureResult = query.getResult();
|
||||
Output currentOutput = procedureResult.getCurrentOutput();
|
||||
assertNotNull( currentOutput );
|
||||
ResultSetOutput resultSetReturn = assertTyping( ResultSetOutput.class, currentOutput );
|
||||
List results = resultSetReturn.getResultList();
|
||||
assertEquals( 1, results.size() );
|
||||
Object result = results.get( 0 );
|
||||
|
|
|
@ -41,14 +41,13 @@ import java.util.List;
|
|||
import org.hibernate.CacheMode;
|
||||
import org.hibernate.FlushMode;
|
||||
import org.hibernate.LockMode;
|
||||
import org.hibernate.procedure.ParameterRegistration;
|
||||
import org.hibernate.procedure.ProcedureCall;
|
||||
import org.hibernate.procedure.ProcedureCallMemento;
|
||||
import org.hibernate.procedure.ProcedureResult;
|
||||
import org.hibernate.procedure.ProcedureOutputs;
|
||||
import org.hibernate.result.NoMoreReturnsException;
|
||||
import org.hibernate.result.ResultSetReturn;
|
||||
import org.hibernate.result.Return;
|
||||
import org.hibernate.result.UpdateCountReturn;
|
||||
import org.hibernate.result.ResultSetOutput;
|
||||
import org.hibernate.result.Output;
|
||||
import org.hibernate.result.UpdateCountOutput;
|
||||
import org.hibernate.jpa.spi.BaseQueryImpl;
|
||||
import org.hibernate.jpa.spi.HibernateEntityManagerImplementor;
|
||||
|
||||
|
@ -57,7 +56,7 @@ import org.hibernate.jpa.spi.HibernateEntityManagerImplementor;
|
|||
*/
|
||||
public class StoredProcedureQueryImpl extends BaseQueryImpl implements StoredProcedureQuery {
|
||||
private final ProcedureCall procedureCall;
|
||||
private ProcedureResult procedureResult;
|
||||
private ProcedureOutputs procedureResult;
|
||||
|
||||
public StoredProcedureQueryImpl(ProcedureCall procedureCall, HibernateEntityManagerImplementor entityManager) {
|
||||
super( entityManager );
|
||||
|
@ -200,7 +199,7 @@ public class StoredProcedureQueryImpl extends BaseQueryImpl implements StoredPro
|
|||
|
||||
// outputs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
private ProcedureResult outputs() {
|
||||
private ProcedureOutputs outputs() {
|
||||
if ( procedureResult == null ) {
|
||||
procedureResult = procedureCall.getResult();
|
||||
}
|
||||
|
@ -220,8 +219,8 @@ public class StoredProcedureQueryImpl extends BaseQueryImpl implements StoredPro
|
|||
@Override
|
||||
public boolean execute() {
|
||||
try {
|
||||
final Return rtn = outputs().getCurrentReturn();
|
||||
return rtn != null && ResultSetReturn.class.isInstance( rtn );
|
||||
final Output rtn = outputs().getCurrentOutput();
|
||||
return rtn != null && ResultSetOutput.class.isInstance( rtn );
|
||||
}
|
||||
catch (NoMoreReturnsException e) {
|
||||
return false;
|
||||
|
@ -238,18 +237,18 @@ public class StoredProcedureQueryImpl extends BaseQueryImpl implements StoredPro
|
|||
|
||||
@Override
|
||||
public boolean hasMoreResults() {
|
||||
return outputs().hasMoreReturns() && ResultSetReturn.class.isInstance( outputs().getCurrentReturn() );
|
||||
return outputs().hasMoreOutput() && ResultSetOutput.class.isInstance( outputs().getCurrentOutput() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUpdateCount() {
|
||||
try {
|
||||
final Return rtn = outputs().getCurrentReturn();
|
||||
final Output rtn = outputs().getCurrentOutput();
|
||||
if ( rtn == null ) {
|
||||
return -1;
|
||||
}
|
||||
else if ( UpdateCountReturn.class.isInstance( rtn ) ) {
|
||||
return ( (UpdateCountReturn) rtn ).getUpdateCount();
|
||||
else if ( UpdateCountOutput.class.isInstance( rtn ) ) {
|
||||
return ( (UpdateCountOutput) rtn ).getUpdateCount();
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
|
@ -263,12 +262,12 @@ public class StoredProcedureQueryImpl extends BaseQueryImpl implements StoredPro
|
|||
@Override
|
||||
public List getResultList() {
|
||||
try {
|
||||
final Return rtn = outputs().getCurrentReturn();
|
||||
if ( ! ResultSetReturn.class.isInstance( rtn ) ) {
|
||||
final Output rtn = outputs().getCurrentOutput();
|
||||
if ( ! ResultSetOutput.class.isInstance( rtn ) ) {
|
||||
throw new IllegalStateException( "Current CallableStatement return was not a ResultSet, but getResultList was called" );
|
||||
}
|
||||
|
||||
return ( (ResultSetReturn) rtn ).getResultList();
|
||||
return ( (ResultSetOutput) rtn ).getResultList();
|
||||
}
|
||||
catch (NoMoreReturnsException e) {
|
||||
// todo : the spec is completely silent on these type of edge-case scenarios.
|
||||
|
@ -307,7 +306,7 @@ public class StoredProcedureQueryImpl extends BaseQueryImpl implements StoredPro
|
|||
if ( ProcedureCall.class.isAssignableFrom( cls ) ) {
|
||||
return (T) procedureCall;
|
||||
}
|
||||
else if ( ProcedureResult.class.isAssignableFrom( cls ) ) {
|
||||
else if ( ProcedureOutputs.class.isAssignableFrom( cls ) ) {
|
||||
return (T) outputs();
|
||||
}
|
||||
else if ( BaseQueryImpl.class.isAssignableFrom( cls ) ) {
|
||||
|
|
Loading…
Reference in New Issue