|
Lines 164-169
Link Here
|
| 164 |
suite.addTest(new JUnitJPQLComplexTestSuite("complexNavigatingTwoLevelOfEmbeddeds")); |
164 |
suite.addTest(new JUnitJPQLComplexTestSuite("complexNavigatingTwoLevelOfEmbeddeds")); |
| 165 |
suite.addTest(new JUnitJPQLComplexTestSuite("complexNamedQueryResultPropertiesTest")); |
165 |
suite.addTest(new JUnitJPQLComplexTestSuite("complexNamedQueryResultPropertiesTest")); |
| 166 |
suite.addTest(new JUnitJPQLComplexTestSuite("complexOuterJoinQuery")); |
166 |
suite.addTest(new JUnitJPQLComplexTestSuite("complexOuterJoinQuery")); |
|
|
167 |
suite.addTest(new JUnitJPQLComplexTestSuite("complexCountOuterJoinTest")); |
| 168 |
suite.addTest(new JUnitJPQLComplexTestSuite("complexCountNestedOuterJoinTest")); |
| 169 |
suite.addTest(new JUnitJPQLComplexTestSuite("complexOuterJoinGroupByTest")); |
| 167 |
|
170 |
|
| 168 |
suite.addTest(new JUnitJPQLComplexTestSuite("complexInheritanceTest")); |
171 |
suite.addTest(new JUnitJPQLComplexTestSuite("complexInheritanceTest")); |
| 169 |
suite.addTest(new JUnitJPQLComplexTestSuite("complexInheritanceUsingNamedQueryTest")); |
172 |
suite.addTest(new JUnitJPQLComplexTestSuite("complexInheritanceUsingNamedQueryTest")); |
|
Lines 1711-1716
Link Here
|
| 1711 |
Assert.assertNull ("Complex outer join query (2): unexpected result value (1, 3):", result1[3]); |
1714 |
Assert.assertNull ("Complex outer join query (2): unexpected result value (1, 3):", result1[3]); |
| 1712 |
|
1715 |
|
| 1713 |
} |
1716 |
} |
|
|
1717 |
|
| 1718 |
/** |
| 1719 |
* Test bug 246211: Inner join used outside of the where clause causes unintentional filtering of results. |
| 1720 |
* Ie "Select count(a.b) from A a" can never return 0 since all As with 0 Bs get filtered out if an inner join |
| 1721 |
* is used. |
| 1722 |
*/ |
| 1723 |
public void complexCountOuterJoinTest() |
| 1724 |
{ |
| 1725 |
EntityManager em = createEntityManager(); |
| 1726 |
String jpql = "Select e.lastName, count(e.department) from Employee e group by e.lastName"; |
| 1727 |
Query q = em.createQuery(jpql); |
| 1728 |
List results = q.getResultList(); |
| 1729 |
boolean passed = false; |
| 1730 |
Iterator i = results.iterator(); |
| 1731 |
//check all rows until a row with count=0 is found |
| 1732 |
while (!passed && i.hasNext() ){ |
| 1733 |
Object[] row = (Object[])i.next(); |
| 1734 |
if (((Number)row[1]).intValue() == 0) { |
| 1735 |
passed = true; |
| 1736 |
} |
| 1737 |
} |
| 1738 |
|
| 1739 |
this.assertTrue("complexCountOuterJoinTest did not return results rows with a count of 0", passed); |
| 1740 |
} |
| 1741 |
|
| 1742 |
/** |
| 1743 |
* Test bug 246211: Inner join used outside of the where clause causes unintentional filtering of results. |
| 1744 |
* Ie "Select count(a.b.c) from A a" can never return 0 since all As with 0 Bs get filtered out if an inner join |
| 1745 |
* is used. This test tests that an outer join is used from A->B as well as B->C |
| 1746 |
*/ |
| 1747 |
public void complexCountNestedOuterJoinTest() |
| 1748 |
{ |
| 1749 |
EntityManager em = createEntityManager(); |
| 1750 |
String jpql = "Select e.lastName, count(e.department.managers) from Employee e group by e.lastName"; |
| 1751 |
Query q = em.createQuery(jpql); |
| 1752 |
List results = q.getResultList(); |
| 1753 |
|
| 1754 |
boolean passed = false; |
| 1755 |
Iterator i = results.iterator(); |
| 1756 |
//check all rows until a row with count=0 is found |
| 1757 |
while (!passed && i.hasNext() ){ |
| 1758 |
Object[] row = (Object[])i.next(); |
| 1759 |
if (((Number)row[1]).intValue() == 0) { |
| 1760 |
passed = true; |
| 1761 |
} |
| 1762 |
} |
| 1763 |
|
| 1764 |
this.assertTrue("complexCountNestedOuterJoinTest did not return results rows with a count of 0", passed); |
| 1765 |
} |
| 1766 |
|
| 1767 |
/** |
| 1768 |
* Test bug 246211: Inner join used outside of the where clause causes unintentional filtering of results. |
| 1769 |
* This tests verifies that the group by statement uses an outer join |
| 1770 |
*/ |
| 1771 |
public void complexOuterJoinGroupByTest(){ |
| 1772 |
EntityManager em = createEntityManager(); |
| 1773 |
//Employee to department is a many to one relation. |
| 1774 |
String jpql = "Select count(e), e.department from Employee e group by e.department"; |
| 1775 |
Query q = em.createQuery(jpql); |
| 1776 |
List results = q.getResultList();Employee e; |
| 1777 |
boolean passed = false; |
| 1778 |
Iterator i = results.iterator(); |
| 1779 |
//check all rows until a row with null departments is found |
| 1780 |
while (!passed && i.hasNext() ){ |
| 1781 |
Object[] row = (Object[])i.next(); |
| 1782 |
if ( row[1] == null ){ |
| 1783 |
//verify that employees with a null department are included in the results |
| 1784 |
passed = true; |
| 1785 |
} |
| 1786 |
} |
| 1787 |
this.assertTrue("complexOuterJoinCountTest did not return results rows with a count of 0", passed); |
| 1788 |
} |
| 1714 |
|
1789 |
|
| 1715 |
// Helper methods and classes for constructor query test cases |
1790 |
// Helper methods and classes for constructor query test cases |
| 1716 |
|
1791 |
|