HHH-8398 - StoredProcedureQuery passed resultClasses chooses incorrect aliases to extract results

This commit is contained in:
Steve Ebersole 2013-07-31 11:16:40 -05:00
parent d210c0cae2
commit 15e9b028b5
2 changed files with 10 additions and 14 deletions

View File

@ -251,6 +251,8 @@ public class ResultImpl implements Result {
} }
private static CustomLoaderExtension buildSpecializedCustomLoader(final ResultContext context) { private static CustomLoaderExtension buildSpecializedCustomLoader(final ResultContext context) {
// might be better to just manually construct the Return(s).. SQLQueryReturnProcessor does a lot of
// work that is really unnecessary here.
final SQLQueryReturnProcessor processor = new SQLQueryReturnProcessor( final SQLQueryReturnProcessor processor = new SQLQueryReturnProcessor(
context.getQueryReturns(), context.getQueryReturns(),
context.getSession().getFactory() context.getSession().getFactory()
@ -292,8 +294,7 @@ public class ResultImpl implements Result {
private QueryParameters queryParameters; private QueryParameters queryParameters;
private SessionImplementor session; private SessionImplementor session;
// temp private boolean needsDiscovery = true;
private final CustomQuery customQuery;
public CustomLoaderExtension( public CustomLoaderExtension(
CustomQuery customQuery, CustomQuery customQuery,
@ -302,14 +303,16 @@ public class ResultImpl implements Result {
super( customQuery, session.getFactory() ); super( customQuery, session.getFactory() );
this.queryParameters = queryParameters; this.queryParameters = queryParameters;
this.session = session; this.session = session;
this.customQuery = customQuery;
} }
// todo : this would be a great way to add locking to stored procedure support (at least where returning entities). // todo : this would be a great way to add locking to stored procedure support (at least where returning entities).
public List processResultSet(ResultSet resultSet) throws SQLException { public List processResultSet(ResultSet resultSet) throws SQLException {
super.autoDiscoverTypes( resultSet ); if ( needsDiscovery ) {
super.autoDiscoverTypes( resultSet );
// todo : EntityAliases discovery
needsDiscovery = false;
}
return super.processResultSet( return super.processResultSet(
resultSet, resultSet,
queryParameters, queryParameters,
@ -320,12 +323,5 @@ public class ResultImpl implements Result {
Collections.<AfterLoadAction>emptyList() Collections.<AfterLoadAction>emptyList()
); );
} }
@Override
protected void validateAlias(String alias) {
System.out.println(
"TEMPORARY... discovered result set alias from stored procedure [" + alias + "] : " + customQuery.getSQL()
);
}
} }
} }

View File

@ -49,7 +49,7 @@ import static org.junit.Assert.assertTrue;
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@RequiresDialect( H2Dialect.class ) @RequiresDialect( H2Dialect.class )
public class JpaUsageTest extends BaseEntityManagerFunctionalTestCase { public class JpaTckUsageTest extends BaseEntityManagerFunctionalTestCase {
@Test @Test
public void testMultipleGetUpdateCountCalls() { public void testMultipleGetUpdateCountCalls() {
@ -60,7 +60,7 @@ public class JpaUsageTest extends BaseEntityManagerFunctionalTestCase {
// this is what the TCK attempts to do, don't shoot the messenger... // this is what the TCK attempts to do, don't shoot the messenger...
query.getUpdateCount(); query.getUpdateCount();
// yep, twice // yep, twice
int updateCount = query.getUpdateCount(); query.getUpdateCount();
em.getTransaction().commit(); em.getTransaction().commit();
em.close(); em.close();