Update of /cvsroot/hibernate/Hibernate3/test/org/hibernate/test/hql
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3359/test/org/hibernate/test/hql
Modified Files:
Tag: Branch_3_1
BulkManipulationTest.java
Log Message:
HHH-1419 : bulk deletes/updates, subqueries and column qualifications
Index: BulkManipulationTest.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate3/test/org/hibernate/test/hql/BulkManipulationTest.java,v
retrieving revision 1.50
retrieving revision 1.50.2.1
diff -u -d -r1.50 -r1.50.2.1
--- BulkManipulationTest.java 18 Jan 2006 06:33:26 -0000 1.50
+++ BulkManipulationTest.java 10 Feb 2006 17:29:26 -0000 1.50.2.1
@@ -3,6 +3,7 @@
import java.util.Date;
import java.util.List;
+import java.util.ArrayList;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -373,6 +374,37 @@
// UPDATES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ public void testUpdateWithWhereExistsSubquery() {
+ Session s = openSession();
+ Transaction t = s.beginTransaction();
+ Human joe = new Human();
+ joe.setName( new Name( "Joe", 'Q', "Public" ) );
+ s.save( joe );
+ Human doll = new Human();
+ doll.setName( new Name( "Kyu", 'P', "Doll" ) );
+ doll.setFriends( new ArrayList() );
+ doll.getFriends().add( joe );
+ s.save( doll );
+ t.commit();
+ s.close();
+
+ s = openSession();
+ t = s.beginTransaction();
+ String updateQryString = "update Human h " +
+ "set h.description = 'updated' " +
+ "where exists (" +
+ " select f.id " +
+ " from h.friends f " +
+ " where f.name.last = 'Public' " +
+ ")";
+ int count = s.createQuery( updateQryString ).executeUpdate();
+ assertEquals( 1, count );
+ s.delete( doll );
+ s.delete( joe );
+ t.commit();
+ s.close();
+ }
+
public void testIncrementCounterVersion() {
Session s = openSession();
Transaction t = s.beginTransaction();
|