HHH-1830 - Error during parse query on MS SQL
This commit is contained in:
parent
3d27fa88f5
commit
f07cdde352
|
@ -609,6 +609,18 @@ public class JoinSequence {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public JoinSequence copyForCollectionProperty() {
|
||||||
|
JoinSequence copy = this.copy();
|
||||||
|
copy.joins.clear();
|
||||||
|
Iterator<Join> joinIterator = this.joins.iterator();
|
||||||
|
while (joinIterator.hasNext()) {
|
||||||
|
Join join = joinIterator.next();
|
||||||
|
copy.addJoin(join.getAssociationType(), join.getAlias(),
|
||||||
|
JoinType.INNER_JOIN, join.getLHSColumns());
|
||||||
|
}
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
final StringBuilder buf = new StringBuilder();
|
final StringBuilder buf = new StringBuilder();
|
||||||
|
|
|
@ -622,7 +622,7 @@ class FromElementType {
|
||||||
|
|
||||||
Map enabledFilters = fromElement.getWalker().getEnabledFilters();
|
Map enabledFilters = fromElement.getWalker().getEnabledFilters();
|
||||||
String subquery = CollectionSubqueryFactory.createCollectionSubquery(
|
String subquery = CollectionSubqueryFactory.createCollectionSubquery(
|
||||||
joinSequence.copy().setUseThetaStyle( true ),
|
joinSequence.copyForCollectionProperty().setUseThetaStyle( true ),
|
||||||
enabledFilters,
|
enabledFilters,
|
||||||
collectionPropertyMapping.toColumns( tableAlias, propertyName )
|
collectionPropertyMapping.toColumns( tableAlias, propertyName )
|
||||||
);
|
);
|
||||||
|
|
|
@ -236,7 +236,15 @@ public class ASTParserLoadingTest extends BaseCoreFunctionalTestCase {
|
||||||
session.getTransaction().commit();
|
session.getTransaction().commit();
|
||||||
|
|
||||||
assertEquals( 1, Constructor.getConstructorExecutionCount() );
|
assertEquals( 1, Constructor.getConstructorExecutionCount() );
|
||||||
assertEquals( new Constructor( constructor.getId(), true, true, constructor.getId() + 1, constructor.getId() + "foo" ), result );
|
assertEquals(
|
||||||
|
new Constructor(
|
||||||
|
constructor.getId(),
|
||||||
|
true,
|
||||||
|
true,
|
||||||
|
constructor.getId() + 1,
|
||||||
|
constructor.getId() + "foo"
|
||||||
|
), result
|
||||||
|
);
|
||||||
|
|
||||||
session.close();
|
session.close();
|
||||||
}
|
}
|
||||||
|
@ -700,7 +708,7 @@ public class ASTParserLoadingTest extends BaseCoreFunctionalTestCase {
|
||||||
.setParameter( "name", null )
|
.setParameter( "name", null )
|
||||||
.list();
|
.list();
|
||||||
assertEquals( 1, results.size() );
|
assertEquals( 1, results.size() );
|
||||||
results = s.createQuery( "from Human where name.first = :firstName and ( :name is null or name.last = :name )" )
|
results = s.createQuery( "from Human where name.first = :firstName and ( :name is null or name.last = cast(:name as string) )" )
|
||||||
.setParameter( "firstName", "Bono" )
|
.setParameter( "firstName", "Bono" )
|
||||||
.setParameter( "name", null )
|
.setParameter( "name", null )
|
||||||
.list();
|
.list();
|
||||||
|
@ -720,7 +728,7 @@ public class ASTParserLoadingTest extends BaseCoreFunctionalTestCase {
|
||||||
.setParameter( "intVal", null )
|
.setParameter( "intVal", null )
|
||||||
.list();
|
.list();
|
||||||
assertEquals( 5, results.size() );
|
assertEquals( 5, results.size() );
|
||||||
results = s.createQuery( "from Human where :intVal is null or intValue = :intVal" )
|
results = s.createQuery( "from Human where :intVal is null or intValue is null" )
|
||||||
.setParameter( "intVal", null )
|
.setParameter( "intVal", null )
|
||||||
.list();
|
.list();
|
||||||
assertEquals( 5, results.size() );
|
assertEquals( 5, results.size() );
|
||||||
|
@ -1052,7 +1060,11 @@ public class ASTParserLoadingTest extends BaseCoreFunctionalTestCase {
|
||||||
// resolved to a "id short cut" when part of the order by clause -> no inner join = no weeding out...
|
// resolved to a "id short cut" when part of the order by clause -> no inner join = no weeding out...
|
||||||
checkCounts( "from SimpleAssociatedEntity e order by e.owner", 2, "implicit-join in order-by clause" );
|
checkCounts( "from SimpleAssociatedEntity e order by e.owner", 2, "implicit-join in order-by clause" );
|
||||||
// resolved to a "id short cut" when part of the group by clause -> no inner join = no weeding out...
|
// resolved to a "id short cut" when part of the group by clause -> no inner join = no weeding out...
|
||||||
checkCounts( "select e.owner.id, count(*) from SimpleAssociatedEntity e group by e.owner", 2, "implicit-join in select and group-by clauses" );
|
checkCounts(
|
||||||
|
"select e.owner.id, count(*) from SimpleAssociatedEntity e group by e.owner",
|
||||||
|
2,
|
||||||
|
"implicit-join in select and group-by clauses"
|
||||||
|
);
|
||||||
|
|
||||||
s = openSession();
|
s = openSession();
|
||||||
s.beginTransaction();
|
s.beginTransaction();
|
||||||
|
@ -1750,6 +1762,21 @@ public class ASTParserLoadingTest extends BaseCoreFunctionalTestCase {
|
||||||
s.close();
|
s.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestForIssue(jiraKey = "HHH-1830")
|
||||||
|
public void testAggregatedJoinAlias() {
|
||||||
|
Session s = openSession();
|
||||||
|
s.getTransaction().begin();
|
||||||
|
s.createQuery(
|
||||||
|
"select p.id, size( descendants ) " +
|
||||||
|
"from Animal p " +
|
||||||
|
"left outer join p.offspring descendants " +
|
||||||
|
"group by p.id" )
|
||||||
|
.list();
|
||||||
|
s.getTransaction().commit();
|
||||||
|
s.close();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestForIssue( jiraKey = "HHH-1464" )
|
@TestForIssue( jiraKey = "HHH-1464" )
|
||||||
public void testQueryMetadataRetrievalWithFetching() {
|
public void testQueryMetadataRetrievalWithFetching() {
|
||||||
|
|
Loading…
Reference in New Issue