/* * Copyright 2014 - 2017 Blazebit. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.blazebit.persistence.testsuite.treat.jpql; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import java.util.List; @RunWith(Parameterized.class) public class JoinManyToOneTest extends AbstractTreatVariationsTest { public JoinManyToOneTest(String strategy, String objectPrefix) { super(strategy, objectPrefix); } @Parameterized.Parameters public static Object[] getParameters() { return new Object[] { new Object[] { "Joined", "s" }, new Object[] { "SingleTable", "st" }, new Object[] { "TablePerClass", "tpc" } }; } @Test public void treatJoinManyToOne() { // EclipseLink // - Joined : issues 1 query, all successful // - SingleTable : issues 1 query, FAILS because filters subtype // - TablePerClass : not working, strategy unsupported // Hibernate // - Joined : issues 1 query, FAILS because inner joins on Sub1 for parent relation => should always use left join from bottom up // - SingleTable : issues 1 query, all successful // - TablePerClass : issues 1 query, all successful // DataNucleus // - Joined : // - SingleTable : // - TablePerClass : List<Integer> bases = list("SELECT s1.sub1Value FROM " + strategy + "Base b LEFT JOIN TREAT(b.parent AS " + strategy + "Sub1) s1", Integer.class); System.out.println("treatJoinManyToOne-" + strategy); // From => 4 instances // Left join on b.parent => 4 instances Assert.assertEquals(4, bases.size()); assertRemoved(bases, null); assertRemoved(bases, null); assertRemoved(bases, null); assertRemoved(bases, 101); } @Test public void treatJoinMultipleManyToOne() { // EclipseLink // - Joined : issues 1 query, all successful // - SingleTable : issues 1 query, FAILS because filters subtype // - TablePerClass : not working, strategy unsupported // Hibernate // - Joined : issues 1 query, FAILS because inner joins on Sub1 for parent relation => should always use left join from bottom up // - SingleTable : issues 1 query, all successful // - TablePerClass : issues 1 query, all successful // DataNucleus // - Joined : // - SingleTable : // - TablePerClass : List<Object[]> bases = list("SELECT s1.sub1Value, s2.sub2Value FROM " + strategy + "Base b LEFT JOIN TREAT(b.parent AS " + strategy + "Sub1) s1 LEFT JOIN TREAT(b.parent AS " + strategy + "Sub2) s2", Object[].class); System.out.println("treatJoinMultipleManyToOne-" + strategy); // From => 4 instances // Left join on b.parent => 4 instances // Left join on b.parent => 4 instances Assert.assertEquals(4, bases.size()); assertRemoved(bases, new Object[] { null, null }); assertRemoved(bases, new Object[] { null, null }); assertRemoved(bases, new Object[] { 101, null }); assertRemoved(bases, new Object[] { null, 102 }); } @Test public void treatJoinParentManyToOne() { // EclipseLink // - Joined : not working, subquery parsing fails // - SingleTable : not working, subquery parsing fails // - TablePerClass : not working, strategy unsupported // Hibernate // - Joined : not working, subquery parsing fails // - SingleTable : not working, subquery parsing fails // - TablePerClass : not working, subquery parsing fails // DataNucleus // - Joined : // - SingleTable : // - TablePerClass : List<Integer> bases = list("SELECT (SELECT s1.sub1Value FROM TREAT(b.parent AS " + strategy + "Sub1) s1) FROM " + strategy + "Base b", Integer.class); System.out.println("treatJoinParentManyToOne-" + strategy); // From => 4 instances // There are two parents but only one is Sub1 Assert.assertEquals(4, bases.size()); assertRemoved(bases, null); assertRemoved(bases, null); assertRemoved(bases, null); assertRemoved(bases, 101); } @Test public void treatJoinMultipleParentManyToOne() { // EclipseLink // - Joined : not working, subquery parsing fails // - SingleTable : not working, subquery parsing fails // - TablePerClass : not working, strategy unsupported // Hibernate // - Joined : not working, subquery parsing fails // - SingleTable : not working, subquery parsing fails // - TablePerClass : not working, subquery parsing fails // DataNucleus // - Joined : // - SingleTable : // - TablePerClass : List<Object[]> bases = list("SELECT (SELECT s1.sub1Value FROM TREAT(b.parent AS " + strategy + "Sub1) s1), (SELECT s2.sub2Value FROM TREAT(b.parent AS " + strategy + "Sub2) s2) FROM " + strategy + "Base b", Object[].class); System.out.println("treatJoinMultipleParentManyToOne-" + strategy); // From => 4 instances // There are two parents, one is Sub1 and the other Sub2 Assert.assertEquals(4, bases.size()); assertRemoved(bases, new Object[] { null, null }); assertRemoved(bases, new Object[] { null, null }); assertRemoved(bases, new Object[] { 101, null }); assertRemoved(bases, new Object[] { null, 102 }); } @Test public void treatJoinEmbeddableManyToOne() { // EclipseLink // - Joined : issues 1 query, all successful // - SingleTable : issues 1 query, FAILS because filters subtype // - TablePerClass : not working, strategy unsupported // Hibernate // - Joined : issues 1 query, FAILS because inner joins on Sub1 for parent relation => should always use left join from bottom up // - SingleTable : issues 1 query, all successful // - TablePerClass : issues 1 query, all successful // DataNucleus // - Joined : // - SingleTable : // - TablePerClass : List<Integer> bases = list("SELECT s1.sub1Value FROM " + strategy + "Base b LEFT JOIN TREAT(b.embeddable.parent AS " + strategy + "Sub1) s1", Integer.class); System.out.println("treatJoinEmbeddableManyToOne-" + strategy); // From => 4 instances // Left join on b.embeddable.parent => 4 instances Assert.assertEquals(4, bases.size()); assertRemoved(bases, null); assertRemoved(bases, null); assertRemoved(bases, null); assertRemoved(bases, 101); } @Test public void treatJoinMultipleEmbeddableManyToOne() { // EclipseLink // - Joined : issues 1 query, all successful // - SingleTable : issues 1 query, FAILS because filters subtype // - TablePerClass : not working, strategy unsupported // Hibernate // - Joined : issues 1 query, FAILS because inner joins on Sub1 for parent relation => should always use left join from bottom up // - SingleTable : issues 1 query, all successful // - TablePerClass : issues 1 query, all successful // DataNucleus // - Joined : // - SingleTable : // - TablePerClass : List<Object[]> bases = list("SELECT s1.sub1Value, s2.sub2Value FROM " + strategy + "Base b LEFT JOIN TREAT(b.embeddable.parent AS " + strategy + "Sub1) s1 LEFT JOIN TREAT(b.embeddable.parent AS " + strategy + "Sub2) s2", Object[].class); System.out.println("treatJoinMultipleEmbeddableManyToOne-" + strategy); // From => 4 instances // Left join on b.embeddable.parent => 4 instances // Left join on b.embeddable.parent => 4 instances Assert.assertEquals(4, bases.size()); assertRemoved(bases, new Object[] { null, null }); assertRemoved(bases, new Object[] { null, null }); assertRemoved(bases, new Object[] { 101, null }); assertRemoved(bases, new Object[] { null, 102 }); } @Test public void treatJoinParentEmbeddableManyToOne() { // EclipseLink // - Joined : not working, subquery parsing fails // - SingleTable : not working, subquery parsing fails // - TablePerClass : not working, strategy unsupported // Hibernate // - Joined : not working, subquery parsing fails // - SingleTable : not working, subquery parsing fails // - TablePerClass : not working, subquery parsing fails // DataNucleus // - Joined : // - SingleTable : // - TablePerClass : List<Integer> bases = list("SELECT (SELECT s1.sub1Value FROM TREAT(b.embeddable.parent AS " + strategy + "Sub1) s1) FROM " + strategy + "Base b", Integer.class); System.out.println("treatJoinParentEmbeddableManyToOne-" + strategy); // From => 4 instances // There are two parents but only one is Sub1 Assert.assertEquals(4, bases.size()); assertRemoved(bases, null); assertRemoved(bases, null); assertRemoved(bases, null); assertRemoved(bases, 101); } @Test public void treatJoinMultipleParentEmbeddableManyToOne() { // EclipseLink // - Joined : not working, subquery parsing fails // - SingleTable : not working, subquery parsing fails // - TablePerClass : not working, strategy unsupported // Hibernate // - Joined : not working, subquery parsing fails // - SingleTable : not working, subquery parsing fails // - TablePerClass : not working, subquery parsing fails // DataNucleus // - Joined : // - SingleTable : // - TablePerClass : List<Object[]> bases = list("SELECT (SELECT s1.sub1Value FROM TREAT(b.embeddable.parent AS " + strategy + "Sub1) s1), (SELECT s2.sub2Value FROM TREAT(b.embeddable.parent AS " + strategy + "Sub2) s2) FROM " + strategy + "Base b", Object[].class); System.out.println("treatJoinMultipleParentEmbeddableManyToOne-" + strategy); // From => 4 instances // There are two parents, one is Sub1 and the other Sub2 Assert.assertEquals(4, bases.size()); assertRemoved(bases, new Object[] { null, null }); assertRemoved(bases, new Object[] { null, null }); assertRemoved(bases, new Object[] { 101, null }); assertRemoved(bases, new Object[] { null, 102 }); } @Test // NOTE: This is a special case that the JPA spec does not cover but is required to make TREAT complete public void joinTreatedRootManyToOne() { // EclipseLink // - Joined : not working, join path parsing fails // - SingleTable : not working, join path parsing fails // - TablePerClass : not working, strategy unsupported // Hibernate // - Joined : not working, treated paths unsupported // - SingleTable : not working, treated paths unsupported // - TablePerClass : not working, treated paths unsupported // DataNucleus // - Joined : // - SingleTable : // - TablePerClass : List<Integer> bases = list("SELECT s1.value FROM " + strategy + "Base b LEFT JOIN TREAT(b AS " + strategy + "Sub1).parent1 s1", Integer.class); System.out.println("joinTreatedRootManyToOne-" + strategy); // From => 4 instances // Left join on b.parent1 => 4 instances Assert.assertEquals(4, bases.size()); assertRemoved(bases, null); assertRemoved(bases, null); assertRemoved(bases, null); assertRemoved(bases, 101); } @Test // NOTE: This is a special case that the JPA spec does not cover but is required to make TREAT complete public void joinMultipleTreatedRootManyToOne() { // EclipseLink // - Joined : not working, join path parsing fails // - SingleTable : not working, join path parsing fails // - TablePerClass : not working, strategy unsupported // Hibernate // - Joined : not working, treated paths unsupported // - SingleTable : not working, treated paths unsupported // - TablePerClass : not working, treated paths unsupported // DataNucleus // - Joined : // - SingleTable : // - TablePerClass : List<Object[]> bases = list("SELECT s1.value, s2.value FROM " + strategy + "Base b LEFT JOIN TREAT(b AS " + strategy + "Sub1).parent1 s1 LEFT JOIN TREAT(b AS " + strategy + "Sub2).parent2 s2", Object[].class); System.out.println("joinMultipleTreatedRootManyToOne-" + strategy); // From => 4 instances // Left join on b.parent1 => 4 instances // Left join on b.parent2 => 4 instances Assert.assertEquals(4, bases.size()); assertRemoved(bases, new Object[] { null, null }); assertRemoved(bases, new Object[] { null, null }); assertRemoved(bases, new Object[] { 101, null }); assertRemoved(bases, new Object[] { null, 102 }); } @Test // NOTE: This is a special case that the JPA spec does not cover but is required to make TREAT complete public void joinTreatedParentRootManyToOne() { // EclipseLink // - Joined : not working, subquery parsing fails // - SingleTable : not working, subquery parsing fails // - TablePerClass : not working, strategy unsupported // Hibernate // - Joined : not working, subquery parsing fails // - SingleTable : not working, subquery parsing fails // - TablePerClass : not working, subquery parsing fails // DataNucleus // - Joined : // - SingleTable : // - TablePerClass : List<Integer> bases = list("SELECT (SELECT s1.sub1Value FROM TREAT(b AS " + strategy + "Sub1).parent1 s1) FROM " + strategy + "Base b", Integer.class); System.out.println("joinTreatedParentRootManyToOne-" + strategy); // From => 4 instances // There are two parents but only one is Sub1 Assert.assertEquals(4, bases.size()); assertRemoved(bases, null); assertRemoved(bases, null); assertRemoved(bases, null); assertRemoved(bases, 101); } @Test // NOTE: This is a special case that the JPA spec does not cover but is required to make TREAT complete public void joinMultipleTreatedParentRootManyToOne() { // EclipseLink // - Joined : not working, subquery parsing fails // - SingleTable : not working, subquery parsing fails // - TablePerClass : not working, strategy unsupported // Hibernate // - Joined : not working, subquery parsing fails // - SingleTable : not working, subquery parsing fails // - TablePerClass : not working, subquery parsing fails // DataNucleus // - Joined : // - SingleTable : // - TablePerClass : List<Object[]> bases = list("SELECT (SELECT s1.sub1Value FROM TREAT(b AS " + strategy + "Sub1).parent1 s1), (SELECT s2.sub2Value FROM TREAT(b AS " + strategy + "Sub2).parent2 s2) FROM " + strategy + "Base b", Object[].class); System.out.println("joinMultipleTreatedParentRootManyToOne-" + strategy); // From => 4 instances // There are two parents, one is Sub1 and the other Sub2 Assert.assertEquals(4, bases.size()); assertRemoved(bases, new Object[] { null, null }); assertRemoved(bases, new Object[] { null, null }); assertRemoved(bases, new Object[] { 101, null }); assertRemoved(bases, new Object[] { null, 102 }); } @Test // NOTE: This is a special case that the JPA spec does not cover but is required to make TREAT complete public void joinTreatedRootEmbeddableManyToOne() { // EclipseLink // - Joined : not working, join path parsing fails // - SingleTable : not working, join path parsing fails // - TablePerClass : not working, strategy unsupported // Hibernate // - Joined : not working, treated paths unsupported // - SingleTable : not working, treated paths unsupported // - TablePerClass : not working, treated paths unsupported // DataNucleus // - Joined : // - SingleTable : // - TablePerClass : List<Integer> bases = list("SELECT s1.value FROM " + strategy + "Base b LEFT JOIN TREAT(b AS " + strategy + "Sub1).embeddable1.sub1Parent s1", Integer.class); System.out.println("joinTreatedRootEmbeddableManyToOne-" + strategy); // From => 4 instances // Left join on b.embeddable.sub1Parent => 4 instances Assert.assertEquals(4, bases.size()); assertRemoved(bases, null); assertRemoved(bases, null); assertRemoved(bases, null); assertRemoved(bases, 101); } @Test // NOTE: This is a special case that the JPA spec does not cover but is required to make TREAT complete public void joinMultipleTreatedRootEmbeddableManyToOne() { // EclipseLink // - Joined : not working, join path parsing fails // - SingleTable : not working, join path parsing fails // - TablePerClass : not working, strategy unsupported // Hibernate // - Joined : not working, treated paths unsupported // - SingleTable : not working, treated paths unsupported // - TablePerClass : not working, treated paths unsupported // DataNucleus // - Joined : // - SingleTable : // - TablePerClass : List<Object[]> bases = list("SELECT s1.value, s2.value FROM " + strategy + "Base b LEFT JOIN TREAT(b AS " + strategy + "Sub1).embeddable1.sub1Parent s1 LEFT JOIN TREAT(b AS " + strategy + "Sub2).embeddable2.sub2Parent s2", Object[].class); System.out.println("joinMultipleTreatedRootEmbeddableManyToOne-" + strategy); // From => 4 instances // Left join on b.embeddable1.sub1Parent => 4 instances // Left join on b.embeddable2.sub2Parent => 4 instances Assert.assertEquals(4, bases.size()); assertRemoved(bases, new Object[] { null, null }); assertRemoved(bases, new Object[] { null, null }); assertRemoved(bases, new Object[] { 101, null }); assertRemoved(bases, new Object[] { null, 102 }); } @Test // NOTE: This is a special case that the JPA spec does not cover but is required to make TREAT complete public void joinTreatedParentRootEmbeddableManyToOne() { // EclipseLink // - Joined : not working, subquery parsing fails // - SingleTable : not working, subquery parsing fails // - TablePerClass : not working, strategy unsupported // Hibernate // - Joined : not working, subquery parsing fails // - SingleTable : not working, subquery parsing fails // - TablePerClass : not working, subquery parsing fails // DataNucleus // - Joined : // - SingleTable : // - TablePerClass : List<Integer> bases = list("SELECT (SELECT s1.value FROM TREAT(b AS " + strategy + "Sub1).embeddable1.sub1Parent s1) FROM " + strategy + "Base b", Integer.class); System.out.println("joinTreatedParentRootEmbeddableManyToOne-" + strategy); // From => 4 instances // There are two parents but only one is Sub1 Assert.assertEquals(4, bases.size()); assertRemoved(bases, null); assertRemoved(bases, null); assertRemoved(bases, null); assertRemoved(bases, 101); } @Test // NOTE: This is a special case that the JPA spec does not cover but is required to make TREAT complete public void joinMultipleTreatedParentRootEmbeddableManyToOne() { // EclipseLink // - Joined : not working, subquery parsing fails // - SingleTable : not working, subquery parsing fails // - TablePerClass : not working, strategy unsupported // Hibernate // - Joined : not working, subquery parsing fails // - SingleTable : not working, subquery parsing fails // - TablePerClass : not working, subquery parsing fails // DataNucleus // - Joined : // - SingleTable : // - TablePerClass : List<Object[]> bases = list("SELECT (SELECT s1.value FROM TREAT(b AS " + strategy + "Sub1).embeddable1.sub1Parent s1), (SELECT s2.value FROM TREAT(b AS " + strategy + "Sub2).embeddable2.sub2Parent s2) FROM " + strategy + "Base b", Object[].class); System.out.println("joinMultipleTreatedParentRootEmbeddableManyToOne-" + strategy); // From => 4 instances // There are two parents, one is Sub1 and the other Sub2 Assert.assertEquals(4, bases.size()); assertRemoved(bases, new Object[] { null, null }); assertRemoved(bases, new Object[] { null, null }); assertRemoved(bases, new Object[] { 101, null }); assertRemoved(bases, new Object[] { null, 102 }); } @Test // NOTE: This is a special case that the JPA spec does not cover but is required to make TREAT complete public void treatJoinTreatedRootManyToOne() { // EclipseLink // - Joined : issues 1 query, FAILS because join for parent1 has inner join semantics // - SingleTable : issues 1 query, FAILS because join for parent1 has inner join semantics // - TablePerClass : not working, strategy unsupported // Hibernate // - Joined : not working, treated paths unsupported // - SingleTable : not working, treated paths unsupported // - TablePerClass : not working, treated paths unsupported // DataNucleus // - Joined : // - SingleTable : // - TablePerClass : List<Integer> bases = list("SELECT s1.sub1Value FROM " + strategy + "Base b LEFT JOIN TREAT(TREAT(b AS " + strategy + "Sub1).parent1 AS " + strategy + "Sub1) AS s1", Integer.class); System.out.println("treatJoinTreatedRootManyToOne-" + strategy); // From => 4 instances // Left join on b.parent1 => 4 instances Assert.assertEquals(4, bases.size()); assertRemoved(bases, null); assertRemoved(bases, null); assertRemoved(bases, null); assertRemoved(bases, 101); } @Test // NOTE: This is a special case that the JPA spec does not cover but is required to make TREAT complete public void treatJoinMultipleTreatedRootManyToOne() { // EclipseLink // - Joined : issues 1 query, FAILS because join for parent1 and parent2 have inner join semantics // - SingleTable : issues 1 query, FAILS because join for parent1 and parent2 have inner join semantics // - TablePerClass : not working, strategy unsupported // Hibernate // - Joined : not working, treated paths unsupported // - SingleTable : not working, treated paths unsupported // - TablePerClass : not working, treated paths unsupported // DataNucleus // - Joined : // - SingleTable : // - TablePerClass : List<Object[]> bases = list("SELECT s1.sub1Value, s2.sub2Value FROM " + strategy + "Base b LEFT JOIN TREAT(TREAT(b AS " + strategy + "Sub1).parent1 AS " + strategy + "Sub1) AS s1 LEFT JOIN TREAT(TREAT(b AS " + strategy + "Sub2).parent2 AS " + strategy + "Sub2) AS s2", Object[].class); System.out.println("treatJoinMultipleTreatedRootManyToOne-" + strategy); // From => 4 instances // Left join on b.parent1 => 4 instances // Left join on b.parent2 => 4 instances Assert.assertEquals(4, bases.size()); assertRemoved(bases, new Object[] { null, null }); assertRemoved(bases, new Object[] { null, null }); assertRemoved(bases, new Object[] { 101, null }); assertRemoved(bases, new Object[] { null, 102 }); } @Test // NOTE: This is a special case that the JPA spec does not cover but is required to make TREAT complete public void treatJoinTreatedParentRootManyToOne() { // EclipseLink // - Joined : not working, subquery parsing fails // - SingleTable : not working, subquery parsing fails // - TablePerClass : not working, strategy unsupported // Hibernate // - Joined : not working, subquery parsing fails // - SingleTable : not working, subquery parsing fails // - TablePerClass : not working, subquery parsing fails // DataNucleus // - Joined : // - SingleTable : // - TablePerClass : List<Integer> bases = list("SELECT (SELECT s1.sub1Value FROM TREAT(TREAT(b AS " + strategy + "Sub1).parent1 AS " + strategy + "Sub1) s1) FROM " + strategy + "Base b", Integer.class); System.out.println("treatJoinTreatedParentRootManyToOne-" + strategy); // From => 4 instances // There are two parents but only one is Sub1 Assert.assertEquals(4, bases.size()); assertRemoved(bases, null); assertRemoved(bases, null); assertRemoved(bases, null); assertRemoved(bases, 101); } @Test // NOTE: This is a special case that the JPA spec does not cover but is required to make TREAT complete public void treatJoinMultipleTreatedParentRootManyToOne() { // EclipseLink // - Joined : not working, subquery parsing fails // - SingleTable : not working, subquery parsing fails // - TablePerClass : not working, strategy unsupported // Hibernate // - Joined : not working, subquery parsing fails // - SingleTable : not working, subquery parsing fails // - TablePerClass : not working, subquery parsing fails // DataNucleus // - Joined : // - SingleTable : // - TablePerClass : List<Object[]> bases = list("SELECT (SELECT s1.sub1Value FROM TREAT(TREAT(b AS " + strategy + "Sub1).parent1 AS " + strategy + "Sub1) s1), (SELECT s2.sub2Value FROM TREAT(TREAT(b AS " + strategy + "Sub2).parent2 AS " + strategy + "Sub2) s2) FROM " + strategy + "Base b", Object[].class); System.out.println("treatJoinMultipleTreatedParentRootManyToOne-" + strategy); // From => 4 instances // There are two parents, one is Sub1 and the other Sub2 Assert.assertEquals(4, bases.size()); assertRemoved(bases, new Object[] { null, null }); assertRemoved(bases, new Object[] { null, null }); assertRemoved(bases, new Object[] { 101, null }); assertRemoved(bases, new Object[] { null, 102 }); } @Test // NOTE: This is a special case that the JPA spec does not cover but is required to make TREAT complete public void treatJoinTreatedRootEmbeddableManyToOne() { // EclipseLink // - Joined : issues 1 query, FAILS because filters subtype // - SingleTable : issues 1 query, FAILS because filters subtype // - TablePerClass : not working, strategy unsupported // Hibernate // - Joined : not working, treated paths unsupported // - SingleTable : not working, treated paths unsupported // - TablePerClass : not working, treated paths unsupported // DataNucleus // - Joined : // - SingleTable : // - TablePerClass : List<Integer> bases = list("SELECT s1.sub1Value FROM " + strategy + "Base b LEFT JOIN TREAT(TREAT(b AS " + strategy + "Sub1).embeddable1.sub1Parent AS " + strategy + "Sub1) AS s1", Integer.class); System.out.println("treatJoinTreatedRootEmbeddableManyToOne-" + strategy); // From => 4 instances // Left join on b.embeddable1.sub1Parent => 4 instances Assert.assertEquals(4, bases.size()); assertRemoved(bases, null); assertRemoved(bases, null); assertRemoved(bases, null); assertRemoved(bases, 101); } @Test // NOTE: This is a special case that the JPA spec does not cover but is required to make TREAT complete public void treatJoinMultipleTreatedRootEmbeddableManyToOne() { // EclipseLink // - Joined : issues 1 query, FAILS because filters subtype // - SingleTable : issues 1 query, FAILS because filters subtype // - TablePerClass : not working, strategy unsupported // Hibernate // - Joined : not working, treated paths unsupported // - SingleTable : not working, treated paths unsupported // - TablePerClass : not working, treated paths unsupported // DataNucleus // - Joined : // - SingleTable : // - TablePerClass : List<Object[]> bases = list("SELECT s1.sub1Value, s2.sub2Value FROM " + strategy + "Base b LEFT JOIN TREAT(TREAT(b AS " + strategy + "Sub1).embeddable1.sub1Parent AS " + strategy + "Sub1) AS s1 LEFT JOIN TREAT(TREAT(b AS " + strategy + "Sub2).embeddable2.sub2Parent AS " + strategy + "Sub2) AS s2", Object[].class); System.out.println("treatJoinMultipleTreatedRootEmbeddableManyToOne-" + strategy); // From => 4 instances // Left join on b.embeddable1.sub1Parent => 4 instances // Left join on b.embeddable2.sub2Parent => 4 instances Assert.assertEquals(4, bases.size()); assertRemoved(bases, new Object[] { null, null }); assertRemoved(bases, new Object[] { null, null }); assertRemoved(bases, new Object[] { 101, null }); assertRemoved(bases, new Object[] { null, 102 }); } @Test // NOTE: This is a special case that the JPA spec does not cover but is required to make TREAT complete public void treatJoinTreatedParentRootEmbeddableManyToOne() { // EclipseLink // - Joined : not working, subquery parsing fails // - SingleTable : not working, subquery parsing fails // - TablePerClass : not working, strategy unsupported // Hibernate // - Joined : not working, subquery parsing fails // - SingleTable : not working, subquery parsing fails // - TablePerClass : not working, subquery parsing fails // DataNucleus // - Joined : // - SingleTable : // - TablePerClass : List<Integer> bases = list("SELECT (SELECT s1.sub1Value FROM TREAT(TREAT(b AS " + strategy + "Sub1).embeddable1.sub1Parent AS " + strategy + "Sub1) s1) FROM " + strategy + "Base b", Integer.class); System.out.println("treatJoinTreatedParentRootEmbeddableManyToOne-" + strategy); // From => 4 instances // There are two parents but only one is Sub1 Assert.assertEquals(4, bases.size()); assertRemoved(bases, null); assertRemoved(bases, null); assertRemoved(bases, null); assertRemoved(bases, 101); } @Test // NOTE: This is a special case that the JPA spec does not cover but is required to make TREAT complete public void treatJoinMultipleTreatedParentRootEmbeddableManyToOne() { // EclipseLink // - Joined : not working, subquery parsing fails // - SingleTable : not working, subquery parsing fails // - TablePerClass : not working, strategy unsupported // Hibernate // - Joined : not working, subquery parsing fails // - SingleTable : not working, subquery parsing fails // - TablePerClass : not working, subquery parsing fails // DataNucleus // - Joined : // - SingleTable : // - TablePerClass : List<Object[]> bases = list("SELECT (SELECT s1.sub1Value FROM TREAT(TREAT(b AS " + strategy + "Sub1).embeddable1.sub1Parent AS " + strategy + "Sub1) s1), (SELECT s2.sub2Value FROM TREAT(TREAT(b AS " + strategy + "Sub2).embeddable2.sub2Parent AS " + strategy + "Sub2) s2) FROM " + strategy + "Base b", Object[].class); System.out.println("treatJoinMultipleTreatedParentRootEmbeddableManyToOne-" + strategy); // From => 4 instances // There are two parents, one is Sub1 and the other Sub2 Assert.assertEquals(4, bases.size()); assertRemoved(bases, new Object[] { null, null }); assertRemoved(bases, new Object[] { null, null }); assertRemoved(bases, new Object[] { 101, null }); assertRemoved(bases, new Object[] { null, 102 }); } }