HHH-6723 : Remove extra join from eager @OneToOne

This commit is contained in:
Gail Badner 2011-10-12 04:26:57 -07:00
parent 63ad1467fb
commit 2bbb3074d4
2 changed files with 17 additions and 1 deletions

View File

@ -24,6 +24,7 @@
*/
package org.hibernate.loader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
@ -185,6 +186,21 @@ public abstract class AbstractEntityJoinWalker extends JoinWalker {
public abstract String getComment();
@Override
protected boolean isDuplicateAssociation(
final String foreignKeyTable,
final String[] foreignKeyColumns
) {
//disable a join back to this same association
final boolean isSameJoin =
persister.getTableName().equals( foreignKeyTable ) &&
Arrays.equals( foreignKeyColumns, persister.getKeyColumnNames() );
return isSameJoin ||
super.isDuplicateAssociation(foreignKeyTable, foreignKeyColumns);
}
protected final Loadable getPersister() {
return persister;
}

View File

@ -331,7 +331,7 @@ public class OneToOneTest extends BaseCoreFunctionalTestCase {
}
@Test
@FailureExpected( jiraKey = "HHH-6723" )
@TestForIssue( jiraKey = "HHH-6723" )
public void testPkOneToOneSelectStatementDoesNotGenerateExtraJoin() {
// This test uses an interceptor to verify that correct number of joins are generated.
Session s = openSession(new JoinCounter(1));