HHH-1283 : Join fetched collections using Query.scroll() is correct only for first entity

This commit is contained in:
Gail Badner 2012-09-12 23:46:50 -07:00
parent 04ed36bf0a
commit 8eb7d8cf64
2 changed files with 21 additions and 18 deletions

View File

@ -382,11 +382,20 @@ private Object sequentialLoad(
loadedKeys, loadedKeys,
returnProxies returnProxies
); );
if ( ! keyToRead.equals( loadedKeys[0] ) ) {
throw new AssertionFailure(
String.format(
"Unexpected key read for row; expected [%s]; actual [%s]",
keyToRead,
loadedKeys[0] )
);
}
if ( result == null ) { if ( result == null ) {
result = loaded; result = loaded;
} }
} }
while ( keyToRead.equals( loadedKeys[0] ) && resultSet.next() ); while ( resultSet.next() &&
keyToRead.equals( getKeyFromResultSet( 0, getEntityPersisters()[0], null, resultSet, session ) ) );
} }
catch ( SQLException sqle ) { catch ( SQLException sqle ) {
throw factory.getSQLExceptionHelper().convert( throw factory.getSQLExceptionHelper().convert(

View File

@ -25,6 +25,7 @@
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame; import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
@ -84,7 +85,7 @@ public void testIncompleteScrollFirstResult() {
} }
@Test @Test
@FailureExpected( jiraKey = "HHH-1283" ) @TestForIssue( jiraKey = "HHH-1283" )
public void testIncompleteScrollSecondResult() { public void testIncompleteScrollSecondResult() {
try { try {
insertTestData(); insertTestData();
@ -122,7 +123,7 @@ public void testIncompleteScrollFirstResultInTransaction() {
} }
@Test @Test
@FailureExpected( jiraKey = "HHH-1283" ) @TestForIssue( jiraKey = "HHH-1283" )
public void testIncompleteScrollSecondResultInTransaction() { public void testIncompleteScrollSecondResultInTransaction() {
try { try {
insertTestData(); insertTestData();
@ -144,7 +145,7 @@ public void testIncompleteScrollSecondResultInTransaction() {
} }
@Test @Test
@FailureExpected( jiraKey = "HHH-1283") @TestForIssue( jiraKey = "HHH-1283")
public void testIncompleteScroll() { public void testIncompleteScroll() {
try { try {
insertTestData(); insertTestData();
@ -179,15 +180,8 @@ else if ( Child.class.isInstance( entity ) ) {
} }
} }
// check that the same second parent is obtained by calling Session.get() // check that the same second parent is obtained by calling Session.get()
assertSame( pOther, s.get( Parent.class, "parent2" ) ); assertNull( pOther );
assertNotNull( pOther ); assertNull( cOther );
assertNotNull( cOther );
// pOther's collection non-lazy, but only 1 element has been loaded so far;
// Should pOther's collection really be initialized???
assertTrue( Hibernate.isInitialized( pOther.getChildren() ) );
assertTrue( pOther.getChildren().contains( cOther ) );
// The following fails because pOther only has 1 element.
assertResultFromOneUser( pOther );
s.close(); s.close();
} }
finally { finally {
@ -196,7 +190,7 @@ else if ( Child.class.isInstance( entity ) ) {
} }
@Test @Test
@FailureExpected( jiraKey = "HHH-1283" ) @TestForIssue( jiraKey = "HHH-1283" )
public void testIncompleteScrollLast() { public void testIncompleteScrollLast() {
try { try {
insertTestData(); insertTestData();
@ -244,7 +238,7 @@ else if ( Child.class.isInstance( entity ) ) {
} }
@Test @Test
@FailureExpected( jiraKey = "HHH-1283" ) @TestForIssue( jiraKey = "HHH-1283" )
public void testScrollOrderParentAsc() { public void testScrollOrderParentAsc() {
try { try {
insertTestData(); insertTestData();
@ -263,7 +257,7 @@ public void testScrollOrderParentAsc() {
} }
@Test @Test
@FailureExpected( jiraKey = "HHH-1283" ) @TestForIssue( jiraKey = "HHH-1283" )
public void testScrollOrderParentDesc() { public void testScrollOrderParentDesc() {
try { try {
insertTestData(); insertTestData();
@ -282,7 +276,7 @@ public void testScrollOrderParentDesc() {
} }
@Test @Test
@FailureExpected( jiraKey = "HHH-1283" ) @TestForIssue( jiraKey = "HHH-1283" )
public void testScrollOrderParentAscChildrenAsc() { public void testScrollOrderParentAscChildrenAsc() {
try { try {
insertTestData(); insertTestData();
@ -301,7 +295,7 @@ public void testScrollOrderParentAscChildrenAsc() {
} }
@Test @Test
@FailureExpected( jiraKey = "HHH-1283" ) @TestForIssue( jiraKey = "HHH-1283" )
public void testScrollOrderParentAscChildrenDesc() { public void testScrollOrderParentAscChildrenDesc() {
try { try {
insertTestData(); insertTestData();