HHH-6723 : Remove extra join from eager @OneToOne
This commit is contained in:
parent
63ad1467fb
commit
2bbb3074d4
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
Loading…
Reference in New Issue