Author: steve.ebersole(a)jboss.com
Date: 2007-11-16 15:26:30 -0500 (Fri, 16 Nov 2007)
New Revision: 14201
Modified:
core/branches/Branch_3_2/src/org/hibernate/hql/ast/tree/DotNode.java
core/branches/Branch_3_2/test/org/hibernate/test/hql/BulkManipulationTest.java
Log:
HHH-2833 : insert-select query fails with NPE when select includes join
Modified: core/branches/Branch_3_2/src/org/hibernate/hql/ast/tree/DotNode.java
===================================================================
--- core/branches/Branch_3_2/src/org/hibernate/hql/ast/tree/DotNode.java 2007-11-16
20:25:59 UTC (rev 14200)
+++ core/branches/Branch_3_2/src/org/hibernate/hql/ast/tree/DotNode.java 2007-11-16
20:26:30 UTC (rev 14201)
@@ -336,7 +336,8 @@
joinIsNeeded = generateJoin && !isReferenceToPrimaryKey(
parentAsDotNode.propertyName, entityType );
}
else if ( ! getWalker().isSelectStatement() ) {
- joinIsNeeded = false;
+ // in non-select queries, the only time we should need to join is if we are in a
subquery from clause
+ joinIsNeeded = getWalker().getCurrentStatementType() == SqlTokenTypes.SELECT
&& getWalker().isInFrom();
}
else if ( REGRESSION_STYLE_JOIN_SUPPRESSION ) {
// this is the regression style determination which matches the logic of the classic
translator
Modified: core/branches/Branch_3_2/test/org/hibernate/test/hql/BulkManipulationTest.java
===================================================================
---
core/branches/Branch_3_2/test/org/hibernate/test/hql/BulkManipulationTest.java 2007-11-16
20:25:59 UTC (rev 14200)
+++
core/branches/Branch_3_2/test/org/hibernate/test/hql/BulkManipulationTest.java 2007-11-16
20:26:30 UTC (rev 14201)
@@ -451,6 +451,17 @@
s.close();
}
+ public void testInsertWithSelectListUsingJoins() {
+ // this is just checking parsing and syntax...
+ Session s = openSession();
+ s.beginTransaction();
+ s.createQuery( "insert into Animal (description, bodyWeight) select h.description,
h.bodyWeight from Human h where h.mother.mother is not null" ).executeUpdate();
+ s.createQuery( "delete from Animal" ).executeUpdate();
+ s.getTransaction().commit();
+ s.close();
+ }
+
+
// UPDATES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
public void testIncorrectSyntax() {
Show replies by date