Remove use of session#save, session#saveOrUpdate , session#update and session#remove from tests

This commit is contained in:
Andrea Boriero 2024-07-22 17:47:35 +02:00 committed by Steve Ebersole
parent 02096bd1a5
commit dcdcd257c3
733 changed files with 4455 additions and 6514 deletions

View File

@ -33,10 +33,10 @@ public class StatementCacheTest extends BaseCoreFunctionalTestCase {
//save 2 new entities, one valid, one invalid (neither should be persisted) //save 2 new entities, one valid, one invalid (neither should be persisted)
IrrelevantEntity irrelevantEntity = new IrrelevantEntity(); IrrelevantEntity irrelevantEntity = new IrrelevantEntity();
irrelevantEntity.setName( "valid 1" ); irrelevantEntity.setName( "valid 1" );
session.save( irrelevantEntity ); session.persist( irrelevantEntity );
//name is required //name is required
irrelevantEntity = new IrrelevantEntity(); irrelevantEntity = new IrrelevantEntity();
session.save( irrelevantEntity ); session.persist( irrelevantEntity );
try { try {
session.flush(); session.flush();
Assert.fail( "Validation exception did not occur" ); Assert.fail( "Validation exception did not occur" );
@ -53,7 +53,7 @@ public class StatementCacheTest extends BaseCoreFunctionalTestCase {
//save a new entity and commit it //save a new entity and commit it
IrrelevantEntity irrelevantEntity = new IrrelevantEntity(); IrrelevantEntity irrelevantEntity = new IrrelevantEntity();
irrelevantEntity.setName( "valid 2" ); irrelevantEntity.setName( "valid 2" );
session.save( irrelevantEntity ); session.persist( irrelevantEntity );
session.flush(); session.flush();
} }
); );

View File

@ -57,7 +57,7 @@ public class AltibaseFunctionsTest {
} }
person.setBinaryData( session.getLobHelper().createBlob(arry) ); person.setBinaryData( session.getLobHelper().createBlob(arry) );
person.setComments( session.getLobHelper().createClob("blahblah") ); person.setComments( session.getLobHelper().createClob("blahblah") );
session.save( person ); session.persist( person );
} }
); );
} }

View File

@ -57,7 +57,7 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
} }
@Test @Test
public void testDialectSQLFunctions() throws Exception { public void testDialectSQLFunctions() {
Session s = openSession(); Session s = openSession();
Transaction t = s.beginTransaction(); Transaction t = s.beginTransaction();
@ -66,7 +66,7 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
simple.setAddress("Simple Address"); simple.setAddress("Simple Address");
simple.setPay(new Float(45.8)); simple.setPay(new Float(45.8));
simple.setCount(2); simple.setCount(2);
s.save( simple ); s.persist( simple );
// Test to make sure allocating a specified object operates correctly. // Test to make sure allocating a specified object operates correctly.
assertTrue( assertTrue(
@ -88,7 +88,7 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
assertEquals("round(45.8) result was incorrect ", new Float(46), ( (Object[]) rset.get(0) )[3] ); assertEquals("round(45.8) result was incorrect ", new Float(46), ( (Object[]) rset.get(0) )[3] );
simple.setPay(new Float(-45.8)); simple.setPay(new Float(-45.8));
s.update(simple); simple = s.merge(simple);
// Test type conversions while using nested functions (Float to Int). // Test type conversions while using nested functions (Float to Int).
rset = s.createQuery( "select abs(round(s.pay,0)) from Simple s" ).list(); rset = s.createQuery( "select abs(round(s.pay,0)) from Simple s" ).list();
@ -101,7 +101,7 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
// Test the oracle standard NVL funtion as a test of multi-param functions... // Test the oracle standard NVL funtion as a test of multi-param functions...
simple.setPay(null); simple.setPay(null);
s.update(simple); simple = s.merge(simple);
Double value = (Double) s.createQuery("select mod( nvl(s.pay, 5000), 2 ) from Simple as s where s.id = 10").list().get(0); Double value = (Double) s.createQuery("select mod( nvl(s.pay, 5000), 2 ) from Simple as s where s.id = 10").list().get(0);
assertTrue( 0 == value.intValue() ); assertTrue( 0 == value.intValue() );
@ -111,17 +111,17 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
.get(0); .get(0);
assertTrue( 0 == value.intValue() ); assertTrue( 0 == value.intValue() );
s.delete(simple); s.remove(simple);
t.commit(); t.commit();
s.close(); s.close();
} }
public void testSetProperties() throws Exception { public void testSetProperties() {
Session s = openSession(); Session s = openSession();
Transaction t = s.beginTransaction(); Transaction t = s.beginTransaction();
Simple simple = new Simple( Long.valueOf( 10 ) ); Simple simple = new Simple( Long.valueOf( 10 ) );
simple.setName("Simple 1"); simple.setName("Simple 1");
s.save( simple ); s.persist( simple );
Query q = s.createQuery("from Simple s where s.name=:name and s.count=:count"); Query q = s.createQuery("from Simple s where s.name=:name and s.count=:count");
q.setProperties(simple); q.setProperties(simple);
assertTrue( q.list().get(0)==simple ); assertTrue( q.list().get(0)==simple );
@ -145,18 +145,18 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
q = s.createQuery("from Simple s where s.name in (:stuff)"); q = s.createQuery("from Simple s where s.name in (:stuff)");
q.setProperties(single); q.setProperties(single);
assertTrue( q.list().get(0)==simple ); assertTrue( q.list().get(0)==simple );
s.delete(simple); s.remove(simple);
t.commit(); t.commit();
s.close(); s.close();
} }
public void testBroken() throws Exception { public void testBroken() {
Session s = openSession(); Session s = openSession();
Transaction t = s.beginTransaction(); Transaction t = s.beginTransaction();
Broken b = new Fixed(); Broken b = new Fixed();
b.setId( Long.valueOf( 123 )); b.setId( Long.valueOf( 123 ));
b.setOtherId("foobar"); b.setOtherId("foobar");
s.save(b); s.persist(b);
s.flush(); s.flush();
b.setTimestamp( new Date() ); b.setTimestamp( new Date() );
t.commit(); t.commit();
@ -164,52 +164,52 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
s = openSession(); s = openSession();
t = s.beginTransaction(); t = s.beginTransaction();
s.update(b); b = s.merge(b);
t.commit(); t.commit();
s.close(); s.close();
s = openSession(); s = openSession();
t = s.beginTransaction(); t = s.beginTransaction();
b = (Broken) s.load( Broken.class, b ); b = s.getReference( Broken.class, b );
t.commit(); t.commit();
s.close(); s.close();
s = openSession(); s = openSession();
t = s.beginTransaction(); t = s.beginTransaction();
s.delete(b); s.remove(b);
t.commit(); t.commit();
s.close(); s.close();
} }
public void testNothinToUpdate() throws Exception { public void testNothinToUpdate() {
Session s = openSession(); Session s = openSession();
Transaction t = s.beginTransaction(); Transaction t = s.beginTransaction();
Simple simple = new Simple( Long.valueOf(10) ); Simple simple = new Simple( Long.valueOf(10) );
simple.setName("Simple 1"); simple.setName("Simple 1");
s.save( simple ); s.persist( simple );
t.commit(); t.commit();
s.close(); s.close();
s = openSession(); s = openSession();
t = s.beginTransaction(); t = s.beginTransaction();
s.update( simple ); simple = s.merge( simple );
t.commit(); t.commit();
s.close(); s.close();
s = openSession(); s = openSession();
t = s.beginTransaction(); t = s.beginTransaction();
s.update( simple ); simple = s.merge( simple );
s.delete(simple); s.remove(simple);
t.commit(); t.commit();
s.close(); s.close();
} }
public void testCachedQuery() throws Exception { public void testCachedQuery() {
Session s = openSession(); Session s = openSession();
Transaction t = s.beginTransaction(); Transaction t = s.beginTransaction();
Simple simple = new Simple( Long.valueOf(10) ); Simple simple = new Simple( Long.valueOf(10) );
simple.setName("Simple 1"); simple.setName("Simple 1");
s.save( simple ); s.persist( simple );
t.commit(); t.commit();
s.close(); s.close();
@ -248,8 +248,8 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
s = openSession(); s = openSession();
t = s.beginTransaction(); t = s.beginTransaction();
s.update( simple ); simple = s.merge( simple );
s.delete(simple); s.remove(simple);
t.commit(); t.commit();
s.close(); s.close();
@ -264,12 +264,12 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
s.close(); s.close();
} }
public void testCachedQueryRegion() throws Exception { public void testCachedQueryRegion() {
Session s = openSession(); Session s = openSession();
Transaction t = s.beginTransaction(); Transaction t = s.beginTransaction();
Simple simple = new Simple( Long.valueOf(10) ); Simple simple = new Simple( Long.valueOf(10) );
simple.setName("Simple 1"); simple.setName("Simple 1");
s.save( simple ); s.persist( simple );
t.commit(); t.commit();
s.close(); s.close();
@ -300,8 +300,8 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
s = openSession(); s = openSession();
t = s.beginTransaction(); t = s.beginTransaction();
s.update( simple ); simple = s.merge( simple );
s.delete(simple); s.remove(simple);
t.commit(); t.commit();
s.close(); s.close();
@ -322,7 +322,7 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
Transaction t = s.beginTransaction(); Transaction t = s.beginTransaction();
Simple simple = new Simple( Long.valueOf( 10 ) ); Simple simple = new Simple( Long.valueOf( 10 ) );
simple.setName( "Simple 1" ); simple.setName( "Simple 1" );
s.save( simple ); s.persist( simple );
s.createQuery( "from Simple s where repeat('foo', 3) = 'foofoofoo'" ).list(); s.createQuery( "from Simple s where repeat('foo', 3) = 'foofoofoo'" ).list();
s.createQuery( "from Simple s where repeat(s.name, 3) = 'foofoofoo'" ).list(); s.createQuery( "from Simple s where repeat(s.name, 3) = 'foofoofoo'" ).list();
@ -351,7 +351,7 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
other.setName( "Simple 2" ); other.setName( "Simple 2" );
other.setCount( 12 ); other.setCount( 12 );
simple.setOther( other ); simple.setOther( other );
s.save( other ); s.persist( other );
//s.find("from Simple s where s.name ## 'cat|rat|bag'"); //s.find("from Simple s where s.name ## 'cat|rat|bag'");
assertTrue( assertTrue(
s.createQuery( "from Simple s where upper( s.other.name ) ='SIMPLE 2'" ).list().size() == 1 s.createQuery( "from Simple s where upper( s.other.name ) ='SIMPLE 2'" ).list().size() == 1
@ -373,7 +373,7 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
); );
Simple min = new Simple( Long.valueOf( 30 ) ); Simple min = new Simple( Long.valueOf( 30 ) );
min.setCount( -1 ); min.setCount( -1 );
s.save( min ); s.persist( min );
assertTrue( assertTrue(
s.createQuery( "from Simple s where s.count > ( select min(sim.count) from Simple sim )" ) s.createQuery( "from Simple s where s.count > ( select min(sim.count) from Simple sim )" )
@ -447,7 +447,7 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
assertTrue( q.list().size() == 1 ); assertTrue( q.list().size() == 1 );
q = s.createQuery( "from Simple s where s.name in (:name_list) and s.count > :count" ); q = s.createQuery( "from Simple s where s.name in (:name_list) and s.count > :count", Simple.class );
HashSet set = new HashSet(); HashSet set = new HashSet();
set.add( "Simple 1" ); set.add( "Simple 1" );
set.add( "foo" ); set.add( "foo" );
@ -460,9 +460,9 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
sr.get(); sr.get();
} }
s.delete( other ); s.remove( other );
s.delete( simple ); s.remove( simple );
s.delete( min ); s.remove( min );
t.commit(); t.commit();
} }
@ -474,7 +474,7 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
Blobber b = new Blobber(); Blobber b = new Blobber();
b.setBlob( s.getLobHelper().createBlob( "foo/bar/baz".getBytes() ) ); b.setBlob( s.getLobHelper().createBlob( "foo/bar/baz".getBytes() ) );
b.setClob( s.getLobHelper().createClob("foo/bar/baz") ); b.setClob( s.getLobHelper().createClob("foo/bar/baz") );
s.save(b); s.persist(b);
//s.refresh(b); //s.refresh(b);
//assertTrue( b.getClob() instanceof ClobImpl ); //assertTrue( b.getClob() instanceof ClobImpl );
s.flush(); s.flush();
@ -489,9 +489,9 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
s = openSession(); s = openSession();
s.beginTransaction(); s.beginTransaction();
b = (Blobber) s.load( Blobber.class, new Integer( b.getId() ) ); b = s.getReference( Blobber.class, b.getId() );
Blobber b2 = new Blobber(); Blobber b2 = new Blobber();
s.save(b2); s.persist(b2);
b2.setBlob( b.getBlob() ); b2.setBlob( b.getBlob() );
b.setBlob(null); b.setBlob(null);
//assertTrue( b.getClob().getSubString(1, 3).equals("fab") ); //assertTrue( b.getClob().getSubString(1, 3).equals("fab") );
@ -503,7 +503,7 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
s = openSession(); s = openSession();
s.beginTransaction(); s.beginTransaction();
b = (Blobber) s.load( Blobber.class, new Integer( b.getId() ) ); b = s.getReference( Blobber.class, b.getId() );
b.setClob( s.getLobHelper().createClob("xcvfxvc xcvbx cvbx cvbx cvbxcvbxcvbxcvb") ); b.setClob( s.getLobHelper().createClob("xcvfxvc xcvbx cvbx cvbx cvbxcvbxcvbxcvb") );
s.flush(); s.flush();
s.getTransaction().commit(); s.getTransaction().commit();
@ -511,7 +511,7 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
s = openSession(); s = openSession();
s.beginTransaction(); s.beginTransaction();
b = (Blobber) s.load( Blobber.class, new Integer( b.getId() ) ); b = s.getReference( Blobber.class, b.getId() );
assertTrue( b.getClob().getSubString(1, 7).equals("xcvfxvc") ); assertTrue( b.getClob().getSubString(1, 7).equals("xcvfxvc") );
//b.getClob().setString(5, "1234567890"); //b.getClob().setString(5, "1234567890");
s.flush(); s.flush();
@ -519,7 +519,7 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
s.close(); s.close();
} }
public void testSqlFunctionAsAlias() throws Exception { public void testSqlFunctionAsAlias() {
String functionName = locateAppropriateDialectFunctionNameForAliasTest(); String functionName = locateAppropriateDialectFunctionNameForAliasTest();
if (functionName == null) { if (functionName == null) {
log.info("Dialect does not list any no-arg functions"); log.info("Dialect does not list any no-arg functions");
@ -533,7 +533,7 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
Transaction t = s.beginTransaction(); Transaction t = s.beginTransaction();
Simple simple = new Simple( Long.valueOf(10) ); Simple simple = new Simple( Long.valueOf(10) );
simple.setName("Simple 1"); simple.setName("Simple 1");
s.save( simple ); s.persist( simple );
t.commit(); t.commit();
s.close(); s.close();
@ -542,7 +542,7 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
List result = s.createQuery( query ).list(); List result = s.createQuery( query ).list();
assertTrue( result.size() == 1 ); assertTrue( result.size() == 1 );
assertTrue(result.get(0) instanceof Simple); assertTrue(result.get(0) instanceof Simple);
s.delete( result.get(0) ); s.remove( result.get(0) );
t.commit(); t.commit();
s.close(); s.close();
} }
@ -564,7 +564,7 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
Transaction t = s.beginTransaction(); Transaction t = s.beginTransaction();
Simple simple = new Simple( Long.valueOf(10) ); Simple simple = new Simple( Long.valueOf(10) );
simple.setName("Simple 1"); simple.setName("Simple 1");
s.save( simple ); s.persist( simple );
t.commit(); t.commit();
s.close(); s.close();
@ -588,7 +588,7 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
t = s.beginTransaction(); t = s.beginTransaction();
Simple simple2 = new Simple( Long.valueOf(12) ); Simple simple2 = new Simple( Long.valueOf(12) );
simple2.setCount(133); simple2.setCount(133);
s.save( simple2 ); s.persist( simple2 );
t.commit(); t.commit();
s.close(); s.close();
@ -606,7 +606,7 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
list = q.setCacheable(true).list(); list = q.setCacheable(true).list();
assertTrue( list.size()==2 ); assertTrue( list.size()==2 );
for ( Object o : list ) { for ( Object o : list ) {
s.delete( o ); s.remove( o );
} }
t.commit(); t.commit();
s.close(); s.close();
@ -676,7 +676,7 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
object.setDateText( "1977-07-03" ); object.setDateText( "1977-07-03" );
object.setDate1( testvalue ); object.setDate1( testvalue );
object.setDate3( testvalue3 ); object.setDate3( testvalue3 );
s.save( object ); s.persist( object );
s.getTransaction().commit(); s.getTransaction().commit();
s.close(); s.close();

View File

@ -42,7 +42,7 @@ public class PreUpdateEventListenerVetoTest extends BaseSessionFactoryFunctional
ExampleEntity entity = new ExampleEntity(); ExampleEntity entity = new ExampleEntity();
entity.id = EXAMPLE_ID_VALUE; entity.id = EXAMPLE_ID_VALUE;
entity.name = "old_name"; entity.name = "old_name";
session.save( entity ); session.persist( entity );
} ); } );
} }
@ -53,7 +53,7 @@ public class PreUpdateEventListenerVetoTest extends BaseSessionFactoryFunctional
ExampleEntity entity = session.byId( ExampleEntity.class ).load( EXAMPLE_ID_VALUE ); ExampleEntity entity = session.byId( ExampleEntity.class ).load( EXAMPLE_ID_VALUE );
entity.name = "new_name"; entity.name = "new_name";
session.update( entity ); entity = session.merge( entity );
final Long versionBeforeFlush = entity.version; final Long versionBeforeFlush = entity.version;

View File

@ -85,13 +85,13 @@ public class NewlyInstantiatdCollectionSkipDeleteOrphanTest {
public void cleanup(SessionFactoryScope scope) { public void cleanup(SessionFactoryScope scope) {
scope.inTransaction( s -> { scope.inTransaction( s -> {
if ( up.getId() != null ) { if ( up.getId() != null ) {
s.delete( up ); s.remove( up );
} }
if ( vp.getId() != null ) { if ( vp.getId() != null ) {
s.delete( vp ); s.remove( vp );
} }
if ( c.getId() != null ) { if ( c.getId() != null ) {
s.delete( c ); s.remove( c );
} }
} ); } );
} }
@ -107,15 +107,15 @@ public class NewlyInstantiatdCollectionSkipDeleteOrphanTest {
vp.addChild( vmvp ); vp.addChild( vmvp );
// Persist Child associated with versioned parent // Persist Child associated with versioned parent
s.saveOrUpdate( c ); s.merge( c );
assertNotEquals( Integer.valueOf( 0 ), c.getId() ); assertNotEquals( Integer.valueOf( 0 ), c.getId() );
// Persist VersionParent // Persist VersionParent
s.saveOrUpdate( vp ); s.merge( vp );
assertNotEquals( Integer.valueOf( 0 ), vp.getId() ); assertNotEquals( Integer.valueOf( 0 ), vp.getId() );
// Persist versioned mapping now that parent id is generated // Persist versioned mapping now that parent id is generated
s.saveOrUpdate( vmvp ); s.merge( vmvp );
assertNotNull( vmvp.getId() ); assertNotNull( vmvp.getId() );
assertNotEquals( Integer.valueOf( 0 ), vmvp.getId().getParentId() ); assertNotEquals( Integer.valueOf( 0 ), vmvp.getId().getParentId() );
assertNotEquals( Integer.valueOf( 0 ), vmvp.getId().getChildId() ); assertNotEquals( Integer.valueOf( 0 ), vmvp.getId().getChildId() );
@ -148,15 +148,15 @@ public class NewlyInstantiatdCollectionSkipDeleteOrphanTest {
up.addVersionedMappings( vmup ); up.addVersionedMappings( vmup );
// Persist child associated with versioned mapping of unversioned parent // Persist child associated with versioned mapping of unversioned parent
s.saveOrUpdate( c ); s.merge( c );
assertNotEquals( Integer.valueOf( 0 ), c.getId() ); assertNotEquals( Integer.valueOf( 0 ), c.getId() );
// Persist unversioned parent // Persist unversioned parent
s.saveOrUpdate( up ); s.merge( up );
assertNotEquals( Integer.valueOf( 0 ), up.getId() ); assertNotEquals( Integer.valueOf( 0 ), up.getId() );
// Persist versioned mapping // Persist versioned mapping
s.saveOrUpdate( vmup ); s.merge( vmup );
assertNotNull( vmup.getId() ); assertNotNull( vmup.getId() );
assertNotEquals( Integer.valueOf( 0 ), vmup.getId().getParentId() ); assertNotEquals( Integer.valueOf( 0 ), vmup.getId().getParentId() );
assertNotEquals( Integer.valueOf( 0 ), vmup.getId().getChildId() ); assertNotEquals( Integer.valueOf( 0 ), vmup.getId().getChildId() );

View File

@ -29,12 +29,12 @@ public class AbstractCompositeIdTest {
scope.inTransaction( scope.inTransaction(
session -> { session -> {
session.save( myInterface ); session.persist( myInterface );
session.flush(); session.flush();
session.createQuery( "from MyInterface" ).list(); session.createQuery( "from MyInterface" ).list();
session.delete( myInterface ); session.remove( myInterface );
} }
); );

View File

@ -32,7 +32,7 @@ public class AbstractComponentPropertyRefTest {
AddressImpl address = new AddressImpl(); AddressImpl address = new AddressImpl();
scope.inTransaction( scope.inTransaction(
session -> { session -> {
session.save( server ); session.persist( server );
server.setAddress( address ); server.setAddress( address );
address.setServer( server ); address.setServer( server );
session.flush(); session.flush();
@ -45,8 +45,8 @@ public class AbstractComponentPropertyRefTest {
scope.inTransaction( scope.inTransaction(
session -> { session -> {
session.delete( address ); session.remove( address );
session.delete( server ); session.remove( server );
} }
); );
} }

View File

@ -109,7 +109,7 @@ public class ConfigurationTest {
Transaction tx = s.beginTransaction(); Transaction tx = s.beginTransaction();
boat = (Boat) s.get( Boat.class, boat.getId() ); boat = (Boat) s.get( Boat.class, boat.getId() );
assertTrue( 34 != boat.getWeight(), "Annotation has precedence" ); assertTrue( 34 != boat.getWeight(), "Annotation has precedence" );
s.delete( boat ); s.remove( boat );
//s.getTransaction().commit(); //s.getTransaction().commit();
tx.commit(); tx.commit();
s.close(); s.close();

View File

@ -15,6 +15,8 @@ import java.util.EnumSet;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
import java.util.List; import java.util.List;
import java.util.TimeZone; import java.util.TimeZone;
import jakarta.persistence.OptimisticLockException;
import jakarta.persistence.PersistenceException; import jakarta.persistence.PersistenceException;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
@ -77,7 +79,7 @@ public class EntityTest {
firstOne.setName( "AF3202" ); firstOne.setName( "AF3202" );
firstOne.setDuration( new Long( 1000000 ) ); firstOne.setDuration( new Long( 1000000 ) );
firstOne.setDurationInSec( 2000 ); firstOne.setDurationInSec( 2000 );
session.save( firstOne ); session.persist( firstOne );
session.flush(); session.flush();
} }
); );
@ -105,7 +107,7 @@ public class EntityTest {
firstOne.setName( "AF3202" ); firstOne.setName( "AF3202" );
firstOne.setDuration( Long.valueOf( 1000000 ) ); firstOne.setDuration( Long.valueOf( 1000000 ) );
firstOne.setDurationInSec( 2000 ); firstOne.setDurationInSec( 2000 );
session.save( firstOne ); session.persist( firstOne );
session.flush(); session.flush();
} }
); );
@ -118,7 +120,7 @@ public class EntityTest {
firstOne.setName( null ); firstOne.setName( null );
try { try {
session.save( firstOne ); session.persist( firstOne );
tx.commit(); tx.commit();
fail( "Name column should be not null" ); fail( "Name column should be not null" );
} }
@ -179,9 +181,9 @@ public class EntityTest {
sky.month = "January"; sky.month = "January";
try { try {
session.save( sky ); session.persist( sky );
session.flush(); session.flush();
session.save( sameSky ); session.persist( sameSky );
tx.commit(); tx.commit();
fail( "unique constraints not respected" ); fail( "unique constraints not respected" );
} }
@ -221,10 +223,10 @@ public class EntityTest {
scope.inTransaction( scope.inTransaction(
session -> { session -> {
session.save( sky ); session.persist( sky );
session.flush(); session.flush();
session.save( otherSky ); session.persist( otherSky );
} }
); );
@ -232,7 +234,7 @@ public class EntityTest {
session -> { session -> {
Transaction tx = session.beginTransaction(); Transaction tx = session.beginTransaction();
try { try {
session.save( sameSky ); session.persist( sameSky );
tx.commit(); tx.commit();
fail( "unique constraints not respected" ); fail( "unique constraints not respected" );
} }
@ -255,7 +257,7 @@ public class EntityTest {
firstOne.setId( Long.valueOf( 2 ) ); firstOne.setId( Long.valueOf( 2 ) );
firstOne.setName( "AF3202" ); firstOne.setName( "AF3202" );
firstOne.setDuration( Long.valueOf( 500 ) ); firstOne.setDuration( Long.valueOf( 500 ) );
session.save( firstOne ); session.persist( firstOne );
session.flush(); session.flush();
} }
); );
@ -270,8 +272,7 @@ public class EntityTest {
session -> { session -> {
Flight _concurrentOne = session.get( Flight.class, Long.valueOf( 2 ) ); Flight _concurrentOne = session.get( Flight.class, Long.valueOf( 2 ) );
_concurrentOne.setDuration( Long.valueOf( 1000 ) ); _concurrentOne.setDuration( Long.valueOf( 1000 ) );
session.update( _concurrentOne ); return session.merge( _concurrentOne );
return _concurrentOne;
} }
); );
@ -283,12 +284,12 @@ public class EntityTest {
session -> { session -> {
Transaction tx = session.beginTransaction(); Transaction tx = session.beginTransaction();
firstOne.setName( "Second access" ); firstOne.setName( "Second access" );
session.update( firstOne );
try { try {
session.merge( firstOne );
tx.commit(); tx.commit();
fail( "Optimistic locking should work" ); fail( "Optimistic locking should work" );
} }
catch (PersistenceException expected) { catch (OptimisticLockException expected) {
if ( expected.getCause() instanceof StaleStateException ) { if ( expected.getCause() instanceof StaleStateException ) {
//expected //expected
} }
@ -315,7 +316,7 @@ public class EntityTest {
sky.month = "1"; sky.month = "1";
scope.inTransaction( scope.inTransaction(
session -> session.save( sky ) session -> session.persist( sky )
); );
sky.area = "London"; sky.area = "London";
@ -370,7 +371,7 @@ public class EntityTest {
assertNotNull( _airFrance ); assertNotNull( _airFrance );
assertEquals( Long.valueOf( 10 ), _airFrance.getDuration() ); assertEquals( Long.valueOf( 10 ), _airFrance.getDuration() );
assertFalse( 25 == _airFrance.getFactor( false ) ); assertFalse( 25 == _airFrance.getFactor( false ) );
session.delete( _airFrance ); session.remove( _airFrance );
} }
); );
} }
@ -407,7 +408,7 @@ public class EntityTest {
); );
assertEquals( df.format( airFrance.getBuyDate() ), df.format( copyAirFrance.getBuyDate() ) ); assertEquals( df.format( airFrance.getBuyDate() ), df.format( copyAirFrance.getBuyDate() ) );
session.delete( copyAirFrance ); session.remove( copyAirFrance );
} }
); );
} }

View File

@ -42,7 +42,7 @@ public class JoinedSubclassTest extends BaseCoreFunctionalTestCase {
assertNotNull( f ); assertNotNull( f );
assertEquals( "Channel", f.getSea() ); assertEquals( "Channel", f.getSea() );
assertEquals( 2, f.getSize() ); assertEquals( 2, f.getSize() );
s.delete( f ); s.remove( f );
} }
); );
} }
@ -67,8 +67,8 @@ public class JoinedSubclassTest extends BaseCoreFunctionalTestCase {
assertNotNull( f ); assertNotNull( f );
assertEquals( country, f.getCountry() ); assertEquals( country, f.getCountry() );
assertEquals( 2, f.getSize() ); assertEquals( 2, f.getSize() );
s.delete( f ); s.remove( f );
s.delete( f.getCountry() ); s.remove( f.getCountry() );
} }
); );
} }

View File

@ -8,8 +8,21 @@ package org.hibernate.orm.test.annotations;
import java.util.Date; import java.util.Date;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map;
import java.util.Set; import java.util.Set;
import org.hibernate.Session;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;
import org.hibernate.generator.internal.CurrentTimestampGeneration;
import org.hibernate.testing.orm.junit.EntityManagerFactoryScope;
import org.hibernate.testing.orm.junit.JiraKey;
import org.hibernate.testing.orm.junit.Jpa;
import org.hibernate.testing.orm.junit.SettingProvider;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import jakarta.persistence.CascadeType; import jakarta.persistence.CascadeType;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.ElementCollection; import jakarta.persistence.ElementCollection;
@ -23,46 +36,36 @@ import jakarta.persistence.Table;
import jakarta.persistence.Temporal; import jakarta.persistence.Temporal;
import jakarta.persistence.TemporalType; import jakarta.persistence.TemporalType;
import org.hibernate.Session; import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;
import org.hibernate.generator.internal.CurrentTimestampGeneration;
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
import org.hibernate.testing.orm.junit.JiraKey;
import org.junit.Before;
import org.junit.Test;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNot.not;
import static org.hamcrest.core.IsNull.nullValue;
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/** /**
* @author Andrea Boriero * @author Andrea Boriero
*/ */
@JiraKey("HHH-11867") @JiraKey("HHH-11867")
public class UpdateTimeStampInheritanceTest extends BaseEntityManagerFunctionalTestCase { @Jpa(
annotatedClasses = {
UpdateTimeStampInheritanceTest.Customer.class,
UpdateTimeStampInheritanceTest.AbstractPerson.class,
UpdateTimeStampInheritanceTest.Address.class
},
settingProviders = @SettingProvider(settingName = CurrentTimestampGeneration.CLOCK_SETTING_NAME, provider = UpdateTimeStampInheritanceTest.ClockProvider.class)
)
public class UpdateTimeStampInheritanceTest {
private static final String customerId = "1"; private static final String customerId = "1";
private static final MutableClock clock = new MutableClock(); private static final MutableClock clock = new MutableClock();
@Override public static class ClockProvider implements SettingProvider.Provider<MutableClock> {
protected Class<?>[] getAnnotatedClasses() {
return new Class[] { Customer.class, AbstractPerson.class, Address.class };
}
@Override @Override
protected void addConfigOptions(Map options) { public MutableClock getSetting() {
super.addConfigOptions( options ); return clock;
options.put( CurrentTimestampGeneration.CLOCK_SETTING_NAME, clock ); }
} }
@Before @BeforeEach
public void setUp() { public void setUp(EntityManagerFactoryScope scope) {
clock.reset(); clock.reset();
doInJPA( this::entityManagerFactory, entityManager -> { scope.inTransaction( entityManager -> {
Customer customer = new Customer(); Customer customer = new Customer();
customer.setId( customerId ); customer.setId( customerId );
customer.addAddress( "address" ); customer.addAddress( "address" );
@ -71,50 +74,58 @@ public class UpdateTimeStampInheritanceTest extends BaseEntityManagerFunctionalT
clock.tick(); clock.tick();
} }
@AfterEach
public void tearDown(EntityManagerFactoryScope scope) {
scope.inTransaction( entityManager -> {
entityManager.createQuery( "delete Customer" ).executeUpdate();
entityManager.createQuery( "delete Address" ).executeUpdate();
} );
}
@Test @Test
public void updateParentClassProperty() { public void updateParentClassProperty(EntityManagerFactoryScope scope) {
doInJPA( this::entityManagerFactory, entityManager -> { scope.inTransaction( entityManager -> {
Customer customer = entityManager.find( Customer.class, customerId ); Customer customer = entityManager.find( Customer.class, customerId );
assertThat( customer.getCreatedAt(), is( not( nullValue() ) ) ); assertThat( customer.getCreatedAt() ).isNotNull();
assertThat( customer.getModifiedAt(), is( not( nullValue() ) ) ); assertThat( customer.getModifiedAt() ).isNotNull();
assertModifiedAtWasNotUpdated( customer ); assertModifiedAtWasNotUpdated( customer );
customer.setName( "xyz" ); customer.setName( "xyz" );
} ); } );
clock.tick(); clock.tick();
doInJPA( this::entityManagerFactory, entityManager -> { scope.inTransaction( entityManager -> {
Customer customer = entityManager.find( Customer.class, customerId ); Customer customer = entityManager.find( Customer.class, customerId );
assertThat( customer.getCreatedAt(), is( not( nullValue() ) ) ); assertThat( customer.getCreatedAt() ).isNotNull();
assertThat( customer.getModifiedAt(), is( not( nullValue() ) ) ); assertThat( customer.getModifiedAt() ).isNotNull();
assertModifiedAtWasUpdated( customer ); assertModifiedAtWasUpdated( customer );
} ); } );
} }
@Test @Test
public void updateSubClassProperty() { public void updateSubClassProperty(EntityManagerFactoryScope scope) {
doInJPA( this::entityManagerFactory, entityManager -> { scope.inTransaction( entityManager -> {
Customer customer = entityManager.find( Customer.class, customerId ); Customer customer = entityManager.find( Customer.class, customerId );
assertThat( customer.getCreatedAt(), is( not( nullValue() ) ) ); assertThat( customer.getCreatedAt() ).isNotNull();
assertThat( customer.getModifiedAt(), is( not( nullValue() ) ) ); assertThat( customer.getModifiedAt() ).isNotNull();
assertModifiedAtWasNotUpdated( customer ); assertModifiedAtWasNotUpdated( customer );
customer.setEmail( "xyz@" ); customer.setEmail( "xyz@" );
} ); } );
clock.tick(); clock.tick();
doInJPA( this::entityManagerFactory, entityManager -> { scope.inTransaction( entityManager -> {
Customer customer = entityManager.find( Customer.class, customerId ); Customer customer = entityManager.find( Customer.class, customerId );
assertThat( customer.getCreatedAt(), is( not( nullValue() ) ) ); assertThat( customer.getCreatedAt() ).isNotNull();
assertThat( customer.getModifiedAt(), is( not( nullValue() ) ) ); assertThat( customer.getModifiedAt() ).isNotNull();
assertModifiedAtWasUpdated( customer ); assertModifiedAtWasUpdated( customer );
} ); } );
} }
@Test @Test
public void updateParentClassOneToOneAssociation() throws Exception { public void updateParentClassOneToOneAssociation(EntityManagerFactoryScope scope) {
doInJPA( this::entityManagerFactory, entityManager -> { scope.inTransaction( entityManager -> {
Customer customer = entityManager.find( Customer.class, customerId ); Customer customer = entityManager.find( Customer.class, customerId );
assertThat( customer.getCreatedAt(), is( not( nullValue() ) ) ); assertThat( customer.getCreatedAt() ).isNotNull();
assertThat( customer.getModifiedAt(), is( not( nullValue() ) ) ); assertThat( customer.getModifiedAt() ).isNotNull();
assertModifiedAtWasNotUpdated( customer ); assertModifiedAtWasNotUpdated( customer );
Address a = new Address(); Address a = new Address();
a.setStreet( "Lollard street" ); a.setStreet( "Lollard street" );
@ -122,20 +133,20 @@ public class UpdateTimeStampInheritanceTest extends BaseEntityManagerFunctionalT
} ); } );
clock.tick(); clock.tick();
doInJPA( this::entityManagerFactory, entityManager -> { scope.inTransaction( entityManager -> {
Customer customer = entityManager.find( Customer.class, customerId ); Customer customer = entityManager.find( Customer.class, customerId );
assertThat( customer.getCreatedAt(), is( not( nullValue() ) ) ); assertThat( customer.getCreatedAt() ).isNotNull();
assertThat( customer.getModifiedAt(), is( not( nullValue() ) ) ); assertThat( customer.getModifiedAt() ).isNotNull();
assertModifiedAtWasUpdated( customer ); assertModifiedAtWasUpdated( customer );
} ); } );
} }
@Test @Test
public void updateSubClassOnrToOneAssociation() { public void updateSubClassOnrToOneAssociation(EntityManagerFactoryScope scope) {
doInJPA( this::entityManagerFactory, entityManager -> { scope.inTransaction( entityManager -> {
Customer customer = entityManager.find( Customer.class, customerId ); Customer customer = entityManager.find( Customer.class, customerId );
assertThat( customer.getCreatedAt(), is( not( nullValue() ) ) ); assertThat( customer.getCreatedAt() ).isNotNull();
assertThat( customer.getModifiedAt(), is( not( nullValue() ) ) ); assertThat( customer.getModifiedAt() ).isNotNull();
assertModifiedAtWasNotUpdated( customer ); assertModifiedAtWasNotUpdated( customer );
Address a = new Address(); Address a = new Address();
a.setStreet( "Lollard Street" ); a.setStreet( "Lollard Street" );
@ -143,20 +154,20 @@ public class UpdateTimeStampInheritanceTest extends BaseEntityManagerFunctionalT
} ); } );
clock.tick(); clock.tick();
doInJPA( this::entityManagerFactory, entityManager -> { scope.inTransaction( entityManager -> {
Customer customer = entityManager.find( Customer.class, customerId ); Customer customer = entityManager.find( Customer.class, customerId );
assertThat( customer.getCreatedAt(), is( not( nullValue() ) ) ); assertThat( customer.getCreatedAt() ).isNotNull();
assertThat( customer.getModifiedAt(), is( not( nullValue() ) ) ); assertThat( customer.getModifiedAt() ).isNotNull();
assertModifiedAtWasUpdated( customer ); assertModifiedAtWasUpdated( customer );
} ); } );
} }
@Test @Test
public void replaceParentClassElementCollection() { public void replaceParentClassElementCollection(EntityManagerFactoryScope scope) {
doInJPA( this::entityManagerFactory, entityManager -> { scope.inTransaction( entityManager -> {
Customer customer = entityManager.find( Customer.class, customerId ); Customer customer = entityManager.find( Customer.class, customerId );
assertThat( customer.getCreatedAt(), is( not( nullValue() ) ) ); assertThat( customer.getCreatedAt() ).isNotNull();
assertThat( customer.getModifiedAt(), is( not( nullValue() ) ) ); assertThat( customer.getModifiedAt() ).isNotNull();
assertModifiedAtWasNotUpdated( customer ); assertModifiedAtWasNotUpdated( customer );
Set<String> adresses = new HashSet<>(); Set<String> adresses = new HashSet<>();
adresses.add( "another address" ); adresses.add( "another address" );
@ -164,58 +175,59 @@ public class UpdateTimeStampInheritanceTest extends BaseEntityManagerFunctionalT
} ); } );
clock.tick(); clock.tick();
doInJPA( this::entityManagerFactory, entityManager -> { scope.inTransaction( entityManager -> {
Customer customer = entityManager.find( Customer.class, customerId ); Customer customer = entityManager.find( Customer.class, customerId );
assertThat( customer.getCreatedAt(), is( not( nullValue() ) ) ); assertThat( customer.getCreatedAt() ).isNotNull();
assertThat( customer.getModifiedAt(), is( not( nullValue() ) ) ); assertThat( customer.getModifiedAt() ).isNotNull();
assertModifiedAtWasUpdated( customer ); assertModifiedAtWasUpdated( customer );
} ); } );
} }
@Test @Test
public void replaceSubClassElementCollection() { public void replaceSubClassElementCollection(EntityManagerFactoryScope scope) {
doInJPA( this::entityManagerFactory, entityManager -> { scope.inTransaction( entityManager -> {
Customer customer = entityManager.find( Customer.class, customerId ); Customer customer = entityManager.find( Customer.class, customerId );
assertThat( customer.getCreatedAt(), is( not( nullValue() ) ) ); assertThat( customer.getCreatedAt() ).isNotNull();
assertThat( customer.getModifiedAt(), is( not( nullValue() ) ) ); assertThat( customer.getModifiedAt() ).isNotNull();
assertModifiedAtWasNotUpdated( customer ); assertModifiedAtWasNotUpdated( customer );
Set<String> books = new HashSet<>(); Set<String> books = new HashSet<>();
customer.setBooks( books ); customer.setBooks( books );
} ); } );
clock.tick(); clock.tick();
doInJPA( this::entityManagerFactory, entityManager -> { scope.inTransaction( entityManager -> {
Customer customer = entityManager.find( Customer.class, customerId ); Customer customer = entityManager.find( Customer.class, customerId );
assertThat( customer.getCreatedAt(), is( not( nullValue() ) ) ); assertThat( customer.getCreatedAt() );
assertThat( customer.getModifiedAt(), is( not( nullValue() ) ) ); assertThat( customer.getModifiedAt() );
assertModifiedAtWasUpdated( customer ); assertModifiedAtWasUpdated( customer );
} ); } );
} }
@Test @Test
public void updateDetachedEntity() { public void mergeDetachedEntity(EntityManagerFactoryScope scope) {
Customer customer = doInJPA( this::entityManagerFactory, entityManager -> { Customer customer = scope.fromTransaction(
return entityManager.find( Customer.class, customerId ); entityManager ->
} ); entityManager.find( Customer.class, customerId )
);
assertModifiedAtWasNotUpdated( customer ); assertModifiedAtWasNotUpdated( customer );
doInJPA( this::entityManagerFactory, entityManager -> { scope.inTransaction( entityManager -> {
entityManager.unwrap( Session.class ).update( customer ); entityManager.unwrap( Session.class ).merge( customer );
} ); } );
doInJPA( this::entityManagerFactory, entityManager -> { scope.inTransaction( entityManager -> {
assertModifiedAtWasUpdated( entityManager.find( Customer.class, customerId ) ); assertModifiedAtWasNotUpdated( entityManager.find( Customer.class, customerId ) );
} ); } );
} }
private void assertModifiedAtWasNotUpdated(Customer customer) { private void assertModifiedAtWasNotUpdated(Customer customer) {
assertTrue( (customer.getModifiedAt().getTime() - customer.getCreatedAt().getTime()) < 10 ); assertThat( ( customer.getModifiedAt().getTime() - customer.getCreatedAt().getTime() ) ).isLessThan( 10 );
} }
private void assertModifiedAtWasUpdated(Customer customer) { private void assertModifiedAtWasUpdated(Customer customer) {
assertTrue( (customer.getModifiedAt().getTime() - customer.getCreatedAt().getTime()) > 10 ); assertThat( ( customer.getModifiedAt().getTime() - customer.getCreatedAt().getTime() ) ).isGreaterThan( 10 );
} }
@Entity(name = "person") @Entity(name = "person")

View File

@ -47,7 +47,7 @@ public class BeanValidationGroupsTest extends BaseCoreFunctionalTestCase {
fail( "invalid object should not be validated" ); fail( "invalid object should not be validated" );
} }
try { try {
s.delete( ch ); s.remove( ch );
s.flush(); s.flush();
fail( "invalid object should not be persisted" ); fail( "invalid object should not be persisted" );
} }

View File

@ -66,7 +66,7 @@ public class MergeNotNullCollectionTest extends BaseCoreFunctionalTestCase {
s = openSession(); s = openSession();
t = s.beginTransaction(); t = s.beginTransaction();
s.delete( parent ); s.remove( parent );
t.commit(); t.commit();
s.close(); s.close();
} }
@ -84,7 +84,7 @@ public class MergeNotNullCollectionTest extends BaseCoreFunctionalTestCase {
s = openSession(); s = openSession();
t = s.beginTransaction(); t = s.beginTransaction();
s.delete( parent ); s.remove( parent );
t.commit(); t.commit();
s.close(); s.close();
} }

View File

@ -74,7 +74,7 @@ public class MergeNotNullCollectionUsingIdentityTest extends BaseCoreFunctionalT
s = openSession(); s = openSession();
t = s.beginTransaction(); t = s.beginTransaction();
s.delete( parent ); s.remove( parent );
t.commit(); t.commit();
s.close(); s.close();
} }
@ -93,7 +93,7 @@ public class MergeNotNullCollectionUsingIdentityTest extends BaseCoreFunctionalT
s = openSession(); s = openSession();
t = s.beginTransaction(); t = s.beginTransaction();
s.delete( parent ); s.remove( parent );
t.commit(); t.commit();
s.close(); s.close();
} }

View File

@ -26,7 +26,7 @@ public class ProxyBreakingTest extends BaseCoreFunctionalTestCase {
Session s = openSession(); Session s = openSession();
Transaction tx = s.beginTransaction(); Transaction tx = s.beginTransaction();
Hammer h = new Hammer(); Hammer h = new Hammer();
s.save(h); s.persist(h);
s.flush(); s.flush();
s.clear(); s.clear();
assertNotNull( "The proxy creation failure is breaking things", h.getId() ); assertNotNull( "The proxy creation failure is breaking things", h.getId() );

View File

@ -110,7 +110,7 @@ public class CascadeTest {
session -> { session -> {
Tooth t = session.get( Tooth.class, tooth.id ); Tooth t = session.get( Tooth.class, tooth.id );
assertNotNull( t ); assertNotNull( t );
session.delete( t.mouth ); session.remove( t.mouth );
} }
); );
scope.inTransaction( scope.inTransaction(
@ -148,7 +148,7 @@ public class CascadeTest {
scope.inTransaction( scope.inTransaction(
session -> session ->
session.delete( session.get( Mouth.class, mouth.id ) ) session.remove( session.get( Mouth.class, mouth.id ) )
); );
} }
} }

View File

@ -36,9 +36,9 @@ public class CascadeToEmbeddedManyToOneTest {
pairHolders.forEach( pairHolders.forEach(
pairHolder -> { pairHolder -> {
PersonPair pair = pairHolder.getPair(); PersonPair pair = pairHolder.getPair();
session.delete( pairHolder ); session.remove( pairHolder );
session.delete(pair.getLeft()); session.remove(pair.getLeft());
session.delete(pair.getRight()); session.remove(pair.getRight());
} }
); );
} }

View File

@ -143,18 +143,18 @@ public class MultiCircleJpaCascadeIdentityTest {
scope.inTransaction( scope.inTransaction(
session -> { session -> {
b = (EntityB) session.merge( b ); b = session.merge( b );
c = (EntityC) session.merge( c ); c = session.merge( c );
d = (EntityD) session.merge( d ); d = session.merge( d );
e = (EntityE) session.merge( e ); e = session.merge( e );
f = (EntityF) session.merge( f ); f = session.merge( f );
g = (EntityG) session.merge( g ); g = session.merge( g );
session.delete( f ); session.remove( f );
session.delete( g ); session.remove( g );
session.delete( b ); session.remove( b );
session.delete( d ); session.remove( d );
session.delete( e ); session.remove( e );
session.delete( c ); session.remove( c );
} }
); );
} }

View File

@ -147,12 +147,12 @@ public class MultiCircleJpaCascadeSequenceTest {
e = (E) session.merge( e ); e = (E) session.merge( e );
f = (F) session.merge( f ); f = (F) session.merge( f );
g = (G) session.merge( g ); g = (G) session.merge( g );
session.delete( f ); session.remove( f );
session.delete( g ); session.remove( g );
session.delete( b ); session.remove( b );
session.delete( d ); session.remove( d );
session.delete( e ); session.remove( e );
session.delete( c ); session.remove( c );
} }
); );
} }

View File

@ -145,18 +145,18 @@ public class MultiCircleNonJpaCascadeIdentityTest {
scope.inTransaction( scope.inTransaction(
session -> { session -> {
b = (EntityB) session.merge( b ); b = session.merge( b );
c = (EntityC) session.merge( c ); c = session.merge( c );
d = (EntityD) session.merge( d ); d = session.merge( d );
e = (EntityE) session.merge( e ); e = session.merge( e );
f = (EntityF) session.merge( f ); f = session.merge( f );
g = (EntityG) session.merge( g ); g = session.merge( g );
session.delete( f ); session.remove( f );
session.delete( g ); session.remove( g );
session.delete( b ); session.remove( b );
session.delete( d ); session.remove( d );
session.delete( e ); session.remove( e );
session.delete( c ); session.remove( c );
} }
); );
} }
@ -170,29 +170,11 @@ public class MultiCircleNonJpaCascadeIdentityTest {
check( scope ); check( scope );
} }
@Test
public void testSave(SessionFactoryScope scope) {
scope.inTransaction(
session -> session.save( b )
);
check( scope );
}
@Test
public void testSaveOrUpdate(SessionFactoryScope scope) {
scope.inTransaction(
session -> session.saveOrUpdate( b )
);
check( scope );
}
@Test @Test
public void testMerge(SessionFactoryScope scope) { public void testMerge(SessionFactoryScope scope) {
scope.inTransaction( scope.inTransaction(
session -> { session -> {
b = (EntityB) session.merge( b ); b = session.merge( b );
c = b.getC(); c = b.getC();
d = b.getD(); d = b.getD();
e = d.getE(); e = d.getE();

View File

@ -141,18 +141,18 @@ public class MultiCircleNonJpaCascadeSequenceTest {
scope.inTransaction( scope.inTransaction(
session -> { session -> {
b = (B) session.merge( b ); b = session.merge( b );
c = (C) session.merge( c ); c = session.merge( c );
d = (D) session.merge( d ); d = session.merge( d );
e = (E) session.merge( e ); e = session.merge( e );
f = (F) session.merge( f ); f = session.merge( f );
g = (G) session.merge( g ); g = session.merge( g );
session.delete( f ); session.remove( f );
session.delete( g ); session.remove( g );
session.delete( b ); session.remove( b );
session.delete( d ); session.remove( d );
session.delete( e ); session.remove( e );
session.delete( c ); session.remove( c );
} }
); );
} }
@ -166,29 +166,11 @@ public class MultiCircleNonJpaCascadeSequenceTest {
check( scope ); check( scope );
} }
@Test
public void testSave(SessionFactoryScope scope) {
scope.inTransaction(
session -> session.save( b )
);
check( scope );
}
@Test
public void testSaveOrUpdate(SessionFactoryScope scope) {
scope.inTransaction(
session -> session.saveOrUpdate( b )
);
check( scope );
}
@Test @Test
public void testMerge(SessionFactoryScope scope) { public void testMerge(SessionFactoryScope scope) {
scope.inTransaction( scope.inTransaction(
session -> { session -> {
b = (B) session.merge( b ); b = session.merge( b );
c = b.getC(); c = b.getC();
d = b.getD(); d = b.getD();
e = d.getE(); e = d.getE();

View File

@ -148,8 +148,8 @@ public class CompositeIdTest {
//FIXME mke it work in unambigious cases //FIXME mke it work in unambigious cases
// assertNotNull(c.id.parent.id); // assertNotNull(c.id.parent.id);
// assertEquals(p.id.getFirstName(), c.id.parent.id.getFirstName()); // assertEquals(p.id.getFirstName(), c.id.parent.id.getFirstName());
session.delete( c ); session.remove( c );
session.delete( c.id.parent ); session.remove( c.id.parent );
} }
); );
} }
@ -231,8 +231,8 @@ public class CompositeIdTest {
//FIXME mke it work in unambigious cases //FIXME mke it work in unambigious cases
// assertNotNull(c.id.parent.id); // assertNotNull(c.id.parent.id);
// assertEquals(p.id.getFirstName(), c.id.parent.id.getFirstName()); // assertEquals(p.id.getFirstName(), c.id.parent.id.getFirstName());
session.delete( c ); session.remove( c );
session.delete( c.id.parent ); session.remove( c.id.parent );
} }
); );
} }
@ -262,9 +262,9 @@ public class CompositeIdTest {
assertEquals( channel.id, mag.id.channel.id ); assertEquals( channel.id, mag.id.channel.id );
assertNotNull( mag.id.presenter ); assertNotNull( mag.id.presenter );
assertEquals( pres.name, mag.id.presenter.name ); assertEquals( pres.name, mag.id.presenter.name );
session.delete( mag ); session.remove( mag );
session.delete( mag.id.channel ); session.remove( mag.id.channel );
session.delete( mag.id.presenter ); session.remove( mag.id.presenter );
} }
); );
} }
@ -423,9 +423,9 @@ public class CompositeIdTest {
assertNotNull( program.id.presenter ); assertNotNull( program.id.presenter );
assertNotNull( program.text ); assertNotNull( program.text );
assertEquals( pres.name, program.id.presenter.name ); assertEquals( pres.name, program.id.presenter.name );
session.delete( program ); session.remove( program );
session.delete( program.id.channel ); session.remove( program.id.channel );
session.delete( program.id.presenter ); session.remove( program.id.presenter );
} }
); );
} }
@ -454,9 +454,9 @@ public class CompositeIdTest {
assertNotNull( program.presenter ); assertNotNull( program.presenter );
assertNotNull( program.text ); assertNotNull( program.text );
assertEquals( pres.name, program.presenter.name ); assertEquals( pres.name, program.presenter.name );
session.delete( program ); session.remove( program );
session.delete( program.channel ); session.remove( program.channel );
session.delete( program.presenter ); session.remove( program.presenter );
} }
); );
} }

View File

@ -51,8 +51,8 @@ public class EagerKeyManyToOneTest {
scope.inTransaction( scope.inTransaction(
session -> { session -> {
Card card = session.get( Card.class, CARD_ID ); Card card = session.get( Card.class, CARD_ID );
session.delete( card.getField()); session.remove( card.getField());
session.delete( card ); session.remove( card );
} }
); );
} }

View File

@ -111,7 +111,7 @@ public class DefaultNamingCollectionElementTest {
"select boy from Boy boy join boy.nickNames names where names = :name" ) "select boy from Boy boy join boy.nickNames names where names = :name" )
.setParameter( "name", "Thing" ).list(); .setParameter( "name", "Thing" ).list();
assertEquals( 1, result.size() ); assertEquals( 1, result.size() );
session.delete( boy ); session.remove( boy );
} }
); );
} }
@ -141,7 +141,7 @@ public class DefaultNamingCollectionElementTest {
assertTrue( boy.getFavoriteToys().contains( toy ) ); assertTrue( boy.getFavoriteToys().contains( toy ) );
Toy next = boy.getFavoriteToys().iterator().next(); Toy next = boy.getFavoriteToys().iterator().next();
assertEquals( boy, next.getOwner(), "@Parent is failing" ); assertEquals( boy, next.getOwner(), "@Parent is failing" );
session.delete( boy ); session.remove( boy );
} }
); );
} }
@ -171,8 +171,8 @@ public class DefaultNamingCollectionElementTest {
session.beginTransaction(); session.beginTransaction();
boy = session.get( Boy.class, boy.getId() ); boy = session.get( Boy.class, boy.getId() );
assertTrue( boy.getCountryAttitudes().contains( attitude ) ); assertTrue( boy.getCountryAttitudes().contains( attitude ) );
session.delete( boy ); session.remove( boy );
session.delete( session.get( Country.class, country.getId() ) ); session.remove( session.get( Country.class, country.getId() ) );
} }
); );
} }
@ -220,7 +220,7 @@ public class DefaultNamingCollectionElementTest {
"select boy from Boy boy join boy.nickNames names where names = :name" ) "select boy from Boy boy join boy.nickNames names where names = :name" )
.setParameter( "name", "Thing" ).list(); .setParameter( "name", "Thing" ).list();
assertEquals( 1, result.size() ); assertEquals( 1, result.size() );
session.delete( boy ); session.remove( boy );
} }
); );
} }
@ -234,7 +234,7 @@ public class DefaultNamingCollectionElementTest {
LocalizedString title = new LocalizedString( "title in english" ); LocalizedString title = new LocalizedString( "title in english" );
title.getVariations().put( Locale.FRENCH.getLanguage(), "title en francais" ); title.getVariations().put( Locale.FRENCH.getLanguage(), "title en francais" );
test.setTitle( title ); test.setTitle( title );
session.save( test ); session.persist( test );
session.flush(); session.flush();
session.clear(); session.clear();

View File

@ -64,7 +64,7 @@ public class EmbeddableCollectionElementWithLazyManyToOneTest {
scope.inTransaction( scope.inTransaction(
session -> session ->
session.delete( p ) session.remove( p )
); );
} }
@ -91,7 +91,7 @@ public class EmbeddableCollectionElementWithLazyManyToOneTest {
scope.inTransaction( scope.inTransaction(
session -> session ->
session.delete( p ) session.remove( p )
); );
} }
@ -121,7 +121,7 @@ public class EmbeddableCollectionElementWithLazyManyToOneTest {
scope.inTransaction( scope.inTransaction(
session -> session ->
session.delete( p ) session.remove( p )
); );
} }
@ -147,7 +147,7 @@ public class EmbeddableCollectionElementWithLazyManyToOneTest {
scope.inTransaction( scope.inTransaction(
session -> session ->
session.delete( p ) session.remove( p )
); );
} }

View File

@ -36,14 +36,14 @@ public class QueryTest {
entityWithAnElementCollection.addSomeString( "abc" ); entityWithAnElementCollection.addSomeString( "abc" );
entityWithAnElementCollection.addSomeString( "efg" ); entityWithAnElementCollection.addSomeString( "efg" );
session.save( entityWithAnElementCollection ); session.persist( entityWithAnElementCollection );
EntityWithAnElementCollection entityWithAnElementCollection2 = new EntityWithAnElementCollection(); EntityWithAnElementCollection entityWithAnElementCollection2 = new EntityWithAnElementCollection();
entityWithAnElementCollection2.setId( 2L ); entityWithAnElementCollection2.setId( 2L );
entityWithAnElementCollection2.addSomeString( "hil" ); entityWithAnElementCollection2.addSomeString( "hil" );
entityWithAnElementCollection2.addSomeString( "mnp" ); entityWithAnElementCollection2.addSomeString( "mnp" );
session.save( entityWithAnElementCollection2 ); session.persist( entityWithAnElementCollection2 );
} }
); );
} }

View File

@ -34,7 +34,7 @@ public class TestBasicOps {
Query q = new Query( new Location( "first", Location.Type.COUNTY ) ); Query q = new Query( new Location( "first", Location.Type.COUNTY ) );
scope.inTransaction( scope.inTransaction(
session -> session ->
session.save( q ) session.persist( q )
); );
scope.inTransaction( scope.inTransaction(
@ -43,7 +43,7 @@ public class TestBasicOps {
assertEquals( 1, q1.getIncludedLocations().size() ); assertEquals( 1, q1.getIncludedLocations().size() );
Location l = q1.getIncludedLocations().iterator().next(); Location l = q1.getIncludedLocations().iterator().next();
assertEquals( Location.Type.COUNTY, l.getType() ); assertEquals( Location.Type.COUNTY, l.getType() );
session.delete( q1 ); session.remove( q1 );
} }
); );
} }
@ -54,13 +54,13 @@ public class TestBasicOps {
scope.inTransaction( scope.inTransaction(
session -> { session -> {
Query q = new Query( new Location( null, Location.Type.COMMUNE ) ); Query q = new Query( new Location( null, Location.Type.COMMUNE ) );
session.save( q ); session.persist( q );
session.getTransaction().commit(); session.getTransaction().commit();
session.clear(); session.clear();
Transaction transaction = session.beginTransaction(); Transaction transaction = session.beginTransaction();
q.getIncludedLocations().add( new Location( null, Location.Type.COUNTY ) ); q.getIncludedLocations().add( new Location( null, Location.Type.COUNTY ) );
session.update( q ); session.merge( q );
transaction.commit(); transaction.commit();
session.clear(); session.clear();
@ -74,14 +74,14 @@ public class TestBasicOps {
Iterator<Location> itr = q.getIncludedLocations().iterator(); Iterator<Location> itr = q.getIncludedLocations().iterator();
itr.next(); itr.next();
itr.remove(); itr.remove();
session.update( q ); session.merge( q );
transaction.commit(); transaction.commit();
session.clear(); session.clear();
session.beginTransaction(); session.beginTransaction();
q = session.get( Query.class, q.getId() ); q = session.get( Query.class, q.getId() );
assertEquals( 1, q.getIncludedLocations().size() ); assertEquals( 1, q.getIncludedLocations().size() );
session.delete( q ); session.remove( q );
} }
); );
} }

View File

@ -35,7 +35,7 @@ public class IndexedCollectionOfElementsTest {
scope.inTransaction( scope.inTransaction(
session -> { session -> {
session.save( sale ); session.persist( sale );
session.flush(); session.flush();
session.get( Sale.class, sale.getId() ); session.get( Sale.class, sale.getId() );
assertEquals( 1, sale.getContacts().size() ); assertEquals( 1, sale.getContacts().size() );

View File

@ -83,8 +83,8 @@ public class ElementCollectionSortingTest {
lukasz.getNickNamesDescendingNaturalSort().add( "lantoniak" ); lukasz.getNickNamesDescendingNaturalSort().add( "lantoniak" );
lukasz.getNickNamesDescendingNaturalSort().add( "antoniak" ); lukasz.getNickNamesDescendingNaturalSort().add( "antoniak" );
session.save( steve ); session.persist( steve );
session.save( lukasz ); session.persist( lukasz );
session.flush(); session.flush();
session.clear(); session.clear();

View File

@ -48,12 +48,12 @@ public class RecreateCollectionTest {
Poi poi1 = new Poi( "Poi 1" ); Poi poi1 = new Poi( "Poi 1" );
Poi poi2 = new Poi( "Poi 2" ); Poi poi2 = new Poi( "Poi 2" );
session.save( poi1 ); session.persist( poi1 );
session.save( poi2 ); session.persist( poi2 );
RaceExecution race = new RaceExecution(); RaceExecution race = new RaceExecution();
session.save( race ); session.persist( race );
Date currentTime = new Date(); Date currentTime = new Date();

View File

@ -73,8 +73,8 @@ public class BasicOperationsTest {
session.doWork( new ValidateRowCount( session, SOME_ENTITY_TABLE_NAME, 0 ) ); session.doWork( new ValidateRowCount( session, SOME_ENTITY_TABLE_NAME, 0 ) );
session.doWork( new ValidateRowCount( session, SOME_OTHER_ENTITY_TABLE_NAME, 0 ) ); session.doWork( new ValidateRowCount( session, SOME_OTHER_ENTITY_TABLE_NAME, 0 ) );
session.save( someEntity ); session.persist( someEntity );
session.save( someOtherEntity ); session.persist( someOtherEntity );
} }
); );
@ -86,8 +86,8 @@ public class BasicOperationsTest {
try { try {
session.beginTransaction(); session.beginTransaction();
session.delete( someEntity ); session.remove( someEntity );
session.delete( someOtherEntity ); session.remove( someOtherEntity );
session.getTransaction().commit(); session.getTransaction().commit();
} }
finally { finally {

View File

@ -46,7 +46,7 @@ public class CompositeDerivedIdentityTest {
scope.inTransaction( scope.inTransaction(
session -> { session -> {
session.save( product ); session.persist( product );
} }
); );
@ -56,7 +56,7 @@ public class CompositeDerivedIdentityTest {
scope.inTransaction( scope.inTransaction(
session -> { session -> {
session.save( order ); session.persist( order );
} }
); );
@ -66,7 +66,7 @@ public class CompositeDerivedIdentityTest {
session -> { session -> {
Order o = session.get( Order.class, orderId ); Order o = session.get( Order.class, orderId );
assertEquals( 1, o.getLineItems().size() ); assertEquals( 1, o.getLineItems().size() );
session.delete( o ); session.remove( o );
} }
); );
} }
@ -79,7 +79,7 @@ public class CompositeDerivedIdentityTest {
scope.inTransaction( scope.inTransaction(
session -> session ->
session.save( product ) session.persist( product )
); );
Order order = new Order(); Order order = new Order();
@ -88,7 +88,7 @@ public class CompositeDerivedIdentityTest {
scope.inTransaction( scope.inTransaction(
session -> session ->
session.save( order ) session.persist( order )
); );
scope.inTransaction( scope.inTransaction(

View File

@ -138,7 +138,7 @@ public class ManyToOneEagerDerivedIdFetchModeJoinTest {
@AfterEach @AfterEach
public void cleanupData(SessionFactoryScope scope) { public void cleanupData(SessionFactoryScope scope) {
scope.inTransaction( session -> { scope.inTransaction( session -> {
session.delete( session.find( Foo.class, foo.id ) ); session.remove( session.find( Foo.class, foo.id ) );
} ); } );
this.foo = null; this.foo = null;
} }

View File

@ -55,8 +55,8 @@ public class DerivedIdentitySimpleParentIdClassDepTest {
assertEquals( e.empId, d.getEmp().empId ); assertEquals( e.empId, d.getEmp().empId );
assertEquals( e.empName, d.getEmp().empName ); assertEquals( e.empName, d.getEmp().empName );
assertEquals( e.nickname, d.getEmp().nickname ); assertEquals( e.nickname, d.getEmp().nickname );
session.delete( d ); session.remove( d );
session.delete( d.getEmp() ); session.remove( d.getEmp() );
} }
); );
} }
@ -78,8 +78,8 @@ public class DerivedIdentitySimpleParentIdClassDepTest {
assertEquals( 1, depList.size() ); assertEquals( 1, depList.size() );
Object newDependent = depList.get( 0 ); Object newDependent = depList.get( 0 );
assertSame( d, newDependent ); assertSame( d, newDependent );
session.delete( d ); session.remove( d );
session.delete( d.getEmp() ); session.remove( d.getEmp() );
} }
); );
} }

View File

@ -89,7 +89,7 @@ public class CompositeKeyDeleteTest extends BaseCoreFunctionalTestCase {
Assert.assertEquals(2, list.size()); Assert.assertEquals(2, list.size());
CustomerInventoryTwo ci = list.get(1); CustomerInventoryTwo ci = list.get(1);
list.remove(ci); list.remove(ci);
s.delete(ci); s.remove(ci);
s.flush(); s.flush();
tx.commit();//fail tx.commit();//fail

View File

@ -63,8 +63,8 @@ public class DerivedIdentityIdClassParentIdClassDepTest {
assertNotNull( d.emp ); assertNotNull( d.emp );
assertEquals( e.firstName, d.emp.firstName ); assertEquals( e.firstName, d.emp.firstName );
session.delete( d ); session.remove( d );
session.delete( d.emp ); session.remove( d.emp );
} }
); );
} }

View File

@ -63,8 +63,8 @@ public class DerivedIdentityEmbeddedIdParentIdClassTest {
d = session.get( Dependent.class, dId ); d = session.get( Dependent.class, dId );
assertNotNull( d.emp ); assertNotNull( d.emp );
assertEquals( e.empId.firstName, d.emp.empId.firstName ); assertEquals( e.empId.firstName, d.emp.empId.firstName );
session.delete( d ); session.remove( d );
session.delete( d.emp ); session.remove( d.emp );
} }
); );
} }

View File

@ -109,8 +109,8 @@ public class DerivedIdentitySimpleParentSimpleDepTest {
session -> { session -> {
FinancialHistory history = session.get( FinancialHistory.class, "aaa" ); FinancialHistory history = session.get( FinancialHistory.class, "aaa" );
if ( history != null ) { if ( history != null ) {
session.delete( history ); session.remove( history );
session.delete( history.patient ); session.remove( history.patient );
} }
} }
); );
@ -119,8 +119,8 @@ public class DerivedIdentitySimpleParentSimpleDepTest {
session -> { session -> {
MedicalHistory history = session.get( MedicalHistory.class, "aaa" ); MedicalHistory history = session.get( MedicalHistory.class, "aaa" );
if ( history != null ) { if ( history != null ) {
session.delete( history ); session.remove( history );
session.delete( history.patient ); session.remove( history.patient );
} }
} }
); );

View File

@ -109,8 +109,8 @@ public class DerivedIdentitySimpleParentSimpleDepMapsIdTest extends BaseNonConfi
s = openSession(); s = openSession();
s.beginTransaction(); s.beginTransaction();
s.delete( medicalHistory ); s.remove( medicalHistory );
s.delete( person ); s.remove( person );
s.getTransaction().commit(); s.getTransaction().commit();
s.close(); s.close();
} }

View File

@ -56,8 +56,8 @@ public class DerivedIdentityIdClassParentSameIdTypeIdClassDepTest {
Person p2 = session.get( Person.class, pId ); Person p2 = session.get( Person.class, pId );
assertEquals( pId.firstName, d2.patient.firstName ); assertEquals( pId.firstName, d2.patient.firstName );
assertEquals( pId.firstName, p2.firstName ); assertEquals( pId.firstName, p2.firstName );
session.delete( d2 ); session.remove( d2 );
session.delete( p2 ); session.remove( p2 );
} }
); );
} }
@ -88,8 +88,8 @@ public class DerivedIdentityIdClassParentSameIdTypeIdClassDepTest {
Person p2 = session.get( Person.class, pId ); Person p2 = session.get( Person.class, pId );
assertEquals( pId.firstName, d2.patient.firstName ); assertEquals( pId.firstName, d2.patient.firstName );
assertEquals( pId.firstName, p2.firstName ); assertEquals( pId.firstName, p2.firstName );
session.delete( d2 ); session.remove( d2 );
session.delete( p2 ); session.remove( p2 );
} }
); );
} }

View File

@ -62,8 +62,8 @@ public class DerivedIdentityIdClassParentSameIdTypeEmbeddedIdDepTest {
Person p2 = session.get( Person.class, pId ); Person p2 = session.get( Person.class, pId );
assertEquals( pId.firstName, d2.patient.firstName ); assertEquals( pId.firstName, d2.patient.firstName );
assertEquals( pId.firstName, p2.firstName ); assertEquals( pId.firstName, p2.firstName );
session.delete( d2 ); session.remove( d2 );
session.delete( p2 ); session.remove( p2 );
} }
); );
} }

View File

@ -32,10 +32,10 @@ public class ForeignGeneratorViaMapsIdTest extends BaseNonConfigCoreFunctionalTe
s.persist( d ); s.persist( d );
s.flush(); s.flush();
s.clear(); s.clear();
d = (MedicalHistory) s.get( MedicalHistory.class, e.id); d = s.get( MedicalHistory.class, e.id);
assertEquals( e.id, d.id ); assertEquals( e.id, d.id );
s.delete( d ); s.remove( d );
s.delete( d.patient ); s.remove( d.patient );
s.getTransaction().rollback(); s.getTransaction().rollback();
s.close(); s.close();
} }

View File

@ -59,8 +59,8 @@ public class DerivedIdentityEmbeddedIdParentSameIdTypeIdClassDepTest {
d = session.get( MedicalHistory.class, pId ); d = session.get( MedicalHistory.class, pId );
assertEquals( pId.firstName, d.patient.id.firstName ); assertEquals( pId.firstName, d.patient.id.firstName );
session.delete( d ); session.remove( d );
session.delete( d.patient ); session.remove( d.patient );
} }
); );
} }

View File

@ -51,7 +51,7 @@ public class EmbeddableIntegratorTest {
Investor myInv = getInvestor(); Investor myInv = getInvestor();
myInv.setId( 1L ); myInv.setId( 1L );
sess.save( myInv ); sess.persist( myInv );
sess.flush(); sess.flush();
fail( "A JDBCException expected" ); fail( "A JDBCException expected" );
@ -85,7 +85,7 @@ public class EmbeddableIntegratorTest {
Investor myInv = getInvestor(); Investor myInv = getInvestor();
myInv.setId( 2L ); myInv.setId( 2L );
sess.save( myInv ); sess.persist( myInv );
sess.flush(); sess.flush();
sess.clear(); sess.clear();

View File

@ -5,7 +5,6 @@ import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.BootstrapServiceRegistry; import org.hibernate.boot.registry.BootstrapServiceRegistry;
import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder; import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
import org.hibernate.boot.registry.StandardServiceRegistry; import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.testing.util.ServiceRegistryUtil; import org.hibernate.testing.util.ServiceRegistryUtil;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;

View File

@ -51,7 +51,7 @@ public class EmbeddableBiDirectionalSelfReferenceTest {
embeddable.setStringField( "Fab" ); embeddable.setStringField( "Fab" );
entity.setEmbeddedAttribute( embeddable ); entity.setEmbeddedAttribute( embeddable );
session.save( entity ); session.persist( entity );
} }
); );
} }
@ -62,7 +62,7 @@ public class EmbeddableBiDirectionalSelfReferenceTest {
session -> { session -> {
List<EntityTest> results = session.createQuery( "from EntityTest" ).list(); List<EntityTest> results = session.createQuery( "from EntityTest" ).list();
results.forEach( results.forEach(
result -> session.delete( result ) result -> session.remove( result )
); );
} }
); );
@ -105,9 +105,9 @@ public class EmbeddableBiDirectionalSelfReferenceTest {
embeddable2.setStringField( "Acme2" ); embeddable2.setStringField( "Acme2" );
entity2.setEmbeddedAttribute( embeddable2 ); entity2.setEmbeddedAttribute( embeddable2 );
session.save( entity ); session.persist( entity );
session.save( entity2 ); session.persist( entity2 );
session.save( entity3 ); session.persist( entity3 );
} }
); );

View File

@ -49,8 +49,8 @@ public class EmbeddableWithManyToOneCircularityTest {
entityTest2.setEmbeddedAttribute( embeddable ); entityTest2.setEmbeddedAttribute( embeddable );
entity.setEntity2( entityTest2 ); entity.setEntity2( entityTest2 );
session.save( entity ); session.persist( entity );
session.save( entityTest2 ); session.persist( entityTest2 );
} }
); );
} }

View File

@ -51,8 +51,8 @@ public class EmbeddableWithManyToOneTest {
entityTest2.setEmbeddedAttribute( embeddable ); entityTest2.setEmbeddedAttribute( embeddable );
entity.setEntity2( entityTest2 ); entity.setEntity2( entityTest2 );
session.save( entity ); session.persist( entity );
session.save( entityTest2 ); session.persist( entityTest2 );
} }
); );
} }
@ -104,9 +104,9 @@ public class EmbeddableWithManyToOneTest {
entityTest2.setEmbeddedAttribute( embeddable ); entityTest2.setEmbeddedAttribute( embeddable );
entity.setEntity2( entityTest2 ); entity.setEntity2( entityTest2 );
session.save( entity ); session.persist( entity );
session.save( entity3 ); session.persist( entity3 );
session.save( entityTest2 ); session.persist( entityTest2 );
} }
); );
SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();
@ -143,10 +143,10 @@ public class EmbeddableWithManyToOneTest {
entityTest.setEmbeddedAttribute( embeddable ); entityTest.setEmbeddedAttribute( embeddable );
entity.setEntity2( entityTest ); entity.setEntity2( entityTest );
session.save( entity ); session.persist( entity );
session.save( entity3 ); session.persist( entity3 );
session.save( entityTest ); session.persist( entityTest );
session.save( entityTest2 ); session.persist( entityTest2 );
} }
); );
SQLStatementInspector statementInspector = scope.getCollectingStatementInspector(); SQLStatementInspector statementInspector = scope.getCollectingStatementInspector();

View File

@ -62,10 +62,10 @@ public class EmbeddableWithMany2OneTest {
session.createQuery( "from Person p where p.address.country.id = 'US'" ) session.createQuery( "from Person p where p.address.country.id = 'US'" )
.list(); .list();
Person p = session.load( Person.class, person.getId() ); Person p = session.load( Person.class, person.getId() );
session.delete( p ); session.remove( p );
List countries = session.createQuery( "from Country" ).list(); List countries = session.createQuery( "from Country" ).list();
assertEquals( 1, countries.size() ); assertEquals( 1, countries.size() );
session.delete( countries.get( 0 ) ); session.remove( countries.get( 0 ) );
} }
); );
} }

View File

@ -33,7 +33,7 @@ public class EmbeddableWithOne2ManyTest {
// but i cannot do this checking until HHH-4599 is done. // but i cannot do this checking until HHH-4599 is done.
scope.inTransaction( scope.inTransaction(
session -> { session -> {
session.createQuery( "from Person p join p.name.aliases a where a.source = 'FBI'" ) session.createQuery( "from Person p join p.name.aliases a where a.source = 'FBI'", Person.class )
.list(); .list();
} }
); );
@ -53,9 +53,9 @@ public class EmbeddableWithOne2ManyTest {
); );
scope.inTransaction( scope.inTransaction(
session -> { session -> {
Person p = (Person) session.load( Person.class, person.getId() ); Person p = session.getReference( Person.class, person.getId() );
session.delete( p ); session.remove( p );
List aliases = session.createQuery( "from Alias" ).list(); List<Alias> aliases = session.createQuery( "from Alias", Alias.class ).list();
assertEquals( 0, aliases.size() ); assertEquals( 0, aliases.size() );
} }
); );

View File

@ -34,27 +34,27 @@ public class UnidirCollectionWithMultipleOwnerTest {
try { try {
Father father = new Father(); Father father = new Father();
Mother mother = new Mother(); Mother mother = new Mother();
session.save( father ); session.persist( father );
//s.save( mother ); //s.persist( mother );
Son son = new Son(); Son son = new Son();
father.getOrderedSons().add( son ); father.getOrderedSons().add( son );
son.setFather( father ); son.setFather( father );
mother.getSons().add( son ); mother.getSons().add( son );
son.setMother( mother ); son.setMother( mother );
session.save( mother ); session.persist( mother );
session.save( father ); session.persist( father );
tx.commit(); tx.commit();
session.clear(); session.clear();
tx = session.beginTransaction(); tx = session.beginTransaction();
son = session.get( Son.class, son.getId() ); son = session.get( Son.class, son.getId() );
session.delete( son ); session.remove( son );
session.flush(); session.flush();
father = session.get( Father.class, father.getId() ); father = session.get( Father.class, father.getId() );
mother = session.get( Mother.class, mother.getId() ); mother = session.get( Mother.class, mother.getId() );
session.delete( father ); session.remove( father );
session.delete( mother ); session.remove( mother );
tx.commit(); tx.commit();
} }
catch (Exception e) { catch (Exception e) {

View File

@ -84,7 +84,7 @@ public class BasicHibernateAnnotationsTest extends BaseCoreFunctionalTestCase {
s = openSession(); s = openSession();
tx = s.beginTransaction(); tx = s.beginTransaction();
s.delete( s.get( Forest.class, forest.getId() ) ); s.remove( s.get( Forest.class, forest.getId() ) );
tx.commit(); tx.commit();
s.close(); s.close();
} }
@ -131,7 +131,7 @@ public class BasicHibernateAnnotationsTest extends BaseCoreFunctionalTestCase {
s = openSession(); s = openSession();
tx = s.beginTransaction(); tx = s.beginTransaction();
s.delete( s.get( Forest.class, forest.getId() ) ); s.remove( s.get( Forest.class, forest.getId() ) );
tx.commit(); tx.commit();
s.close(); s.close();
} }
@ -218,10 +218,10 @@ public class BasicHibernateAnnotationsTest extends BaseCoreFunctionalTestCase {
s = openSession(); s = openSession();
tx = s.beginTransaction(); tx = s.beginTransaction();
f = (Forest) s.get( Forest.class, f.getId() ); f = s.get( Forest.class, f.getId() );
assertNotNull( f ); assertNotNull( f );
assertEquals( description, f.getLongDescription() ); assertEquals( description, f.getLongDescription() );
s.delete( f ); s.remove( f );
tx.commit(); tx.commit();
s.close(); s.close();
@ -622,10 +622,10 @@ public class BasicHibernateAnnotationsTest extends BaseCoreFunctionalTestCase {
s = openSession(); s = openSession();
tx = s.beginTransaction(); tx = s.beginTransaction();
airFrance = (Flight) s.get( Flight.class, airFrance.getId() ); airFrance = s.get( Flight.class, airFrance.getId() );
assertNotNull( airFrance ); assertNotNull( airFrance );
assertEquals( 10000000, airFrance.getMaxAltitudeInMilimeter() ); assertEquals( 10000000, airFrance.getMaxAltitudeInMilimeter() );
s.delete( airFrance ); s.remove( airFrance );
tx.commit(); tx.commit();
s.close(); s.close();
} }
@ -646,11 +646,11 @@ public class BasicHibernateAnnotationsTest extends BaseCoreFunctionalTestCase {
s = openSession(); s = openSession();
tx = s.beginTransaction(); tx = s.beginTransaction();
contactDetails = contactDetails =
(ContactDetails) s.get( ContactDetails.class, contactDetails.getId() ); s.get( ContactDetails.class, contactDetails.getId() );
assertNotNull( contactDetails ); assertNotNull( contactDetails );
assertEquals( "999999", contactDetails.getLocalPhoneNumber().getNumber() ); assertEquals( "999999", contactDetails.getLocalPhoneNumber().getNumber() );
assertEquals( "041111111", contactDetails.getOverseasPhoneNumber().getNumber() ); assertEquals( "041111111", contactDetails.getOverseasPhoneNumber().getNumber() );
s.delete(contactDetails); s.remove(contactDetails);
tx.commit(); tx.commit();
s.close(); s.close();

View File

@ -88,13 +88,13 @@ public class Java5FeaturesTest extends BaseCoreFunctionalTestCase {
communityBid = (CommunityBid) s.get( CommunityBid.class, communityBid.getId() ); communityBid = (CommunityBid) s.get( CommunityBid.class, communityBid.getId() );
assertNull( bid.getNote() ); assertNull( bid.getNote() );
assertEquals( Starred.OK, communityBid.getCommunityNote() ); assertEquals( Starred.OK, communityBid.getCommunityNote() );
s.delete( bid ); s.remove( bid );
s.clear(); s.clear();
communityBid = (CommunityBid) s.createNativeQuery( "select {b.*} from Bid b where b.id = ?" ) communityBid = (CommunityBid) s.createNativeQuery( "select {b.*} from Bid b where b.id = ?" )
.addEntity( "b", CommunityBid.class ) .addEntity( "b", CommunityBid.class )
.setParameter( 1, communityBid.getId() ).uniqueResult(); .setParameter( 1, communityBid.getId() ).uniqueResult();
assertEquals( Starred.OK, communityBid.getCommunityNote() ); assertEquals( Starred.OK, communityBid.getCommunityNote() );
s.delete( communityBid ); s.remove( communityBid );
tx.commit(); tx.commit();
s.close(); s.close();
} }
@ -118,7 +118,7 @@ public class Java5FeaturesTest extends BaseCoreFunctionalTestCase {
tx = s.beginTransaction(); tx = s.beginTransaction();
bid = (Bid) s.get( Bid.class, bid.getId() ); bid = (Bid) s.get( Bid.class, bid.getId() );
assertEquals( null, bid.getApproved() ); assertEquals( null, bid.getApproved() );
s.delete( bid ); s.remove( bid );
tx.commit(); tx.commit();
s.close(); s.close();
} }

View File

@ -55,9 +55,9 @@ public class PropertyDefaultMappingsTest extends BaseCoreFunctionalTestCase {
tx.commit(); tx.commit();
s.clear(); s.clear();
tx = s.beginTransaction(); tx = s.beginTransaction();
wm = (WashingMachine) s.get( WashingMachine.class, wm.getId() ); wm = s.get( WashingMachine.class, wm.getId() );
assertFalse( "transient should not be persistent", wm.isActive() ); assertFalse( "transient should not be persistent", wm.isActive() );
s.delete( wm ); s.remove( wm );
tx.commit(); tx.commit();
s.close(); s.close();
} }

View File

@ -43,7 +43,7 @@ public class EntityNonEntityTest extends BaseCoreFunctionalTestCase {
assertTrue( "mapped superclass under entity", gsm.isNumeric ); assertTrue( "mapped superclass under entity", gsm.isNumeric );
assertNull( "non entity under entity", gsm.brand ); assertNull( "non entity under entity", gsm.brand );
assertEquals( "leaf entity", 900, gsm.frequency ); assertEquals( "leaf entity", 900, gsm.frequency );
s.delete( gsm ); s.remove( gsm );
tx.commit(); tx.commit();
s.close(); s.close();
} }

View File

@ -26,20 +26,20 @@ public class MapKeyEnumeratedTest extends BaseCoreFunctionalTestCase {
Session s = openSession(); Session s = openSession();
s.beginTransaction(); s.beginTransaction();
User user = new User("User1", SocialNetwork.STUB_NETWORK_NAME, "facebookId"); User user = new User("User1", SocialNetwork.STUB_NETWORK_NAME, "facebookId");
s.save( user ); s.persist( user );
s.getTransaction().commit(); s.getTransaction().commit();
s.close(); s.close();
s = openSession(); s = openSession();
s.beginTransaction(); s.beginTransaction();
user = (User) s.get( User.class, user.getId() ); user = s.get( User.class, user.getId() );
s.getTransaction().commit(); s.getTransaction().commit();
s.close(); s.close();
s = openSession(); s = openSession();
s.beginTransaction(); s.beginTransaction();
user = (User) s.get( User.class, user.getId() ); user = s.get( User.class, user.getId() );
s.delete( user ); s.remove( user );
s.getTransaction().commit(); s.getTransaction().commit();
s.close(); s.close();
} }

View File

@ -42,7 +42,7 @@ public class FetchingTest extends BaseCoreFunctionalTestCase {
p = (Person) s.createQuery( "from Person p where p.firstName = :name" ) p = (Person) s.createQuery( "from Person p where p.firstName = :name" )
.setParameter( "name", "Gavin" ).uniqueResult(); .setParameter( "name", "Gavin" ).uniqueResult();
assertFalse( Hibernate.isInitialized( p.getStays() ) ); assertFalse( Hibernate.isInitialized( p.getStays() ) );
s.delete( p ); s.remove( p );
tx.commit(); tx.commit();
s.close(); s.close();
} }
@ -67,7 +67,7 @@ public class FetchingTest extends BaseCoreFunctionalTestCase {
assertFalse( Hibernate.isInitialized( p.getOrderedStay() ) ); assertFalse( Hibernate.isInitialized( p.getOrderedStay() ) );
assertEquals( "A380", p.getOrderedStay().get(0).getVessel() ); assertEquals( "A380", p.getOrderedStay().get(0).getVessel() );
assertFalse( Hibernate.isInitialized( p.getOrderedStay() ) ); assertFalse( Hibernate.isInitialized( p.getOrderedStay() ) );
s.delete( p ); s.remove( p );
tx.commit(); tx.commit();
s.close(); s.close();
} }
@ -105,7 +105,7 @@ public class FetchingTest extends BaseCoreFunctionalTestCase {
"FetchMode.JOIN should overrides lazy options", "FetchMode.JOIN should overrides lazy options",
Hibernate.isInitialized( stay3.getVeryOldPerson() ) Hibernate.isInitialized( stay3.getVeryOldPerson() )
); );
s.delete( stay3.getVeryOldPerson() ); s.remove( stay3.getVeryOldPerson() );
tx.commit(); tx.commit();
}finally { }finally {
if ( tx.isActive() ) { if ( tx.isActive() ) {

View File

@ -34,8 +34,8 @@ public class MappedByFetchProfileFunctionTest extends BaseCoreFunctionalTestCase
address = session.get(Address.class, address.getId()); address = session.get(Address.class, address.getId());
assertTrue(Hibernate.isInitialized(address.getCustomer())); assertTrue(Hibernate.isInitialized(address.getCustomer()));
session.delete(address.getCustomer()); session.remove(address.getCustomer());
session.delete(address); session.remove(address);
transaction.commit(); transaction.commit();
session.close(); session.close();

View File

@ -60,12 +60,12 @@ public class MoreFetchProfileTest extends BaseCoreFunctionalTestCase {
} }
final Order order = c.getOrders().iterator().next(); final Order order = c.getOrders().iterator().next();
c.getOrders().remove( order ); c.getOrders().remove( order );
s.delete( c ); s.remove( c );
final Order lastOrder = c.getLastOrder(); final Order lastOrder = c.getLastOrder();
c.setLastOrder( null ); c.setLastOrder( null );
s.delete( order.getCountry() ); s.remove( order.getCountry() );
s.delete( lastOrder ); s.remove( lastOrder );
s.delete( order ); s.remove( order );
transaction.commit(); transaction.commit();
s.close(); s.close();

View File

@ -71,7 +71,7 @@ public class EmbeddedGenericsTest {
session -> { session -> {
Classes.PopularBook retrieved = session.get( Classes.PopularBook.class, b.id ); Classes.PopularBook retrieved = session.get( Classes.PopularBook.class, b.id );
assertEquals( "Second", retrieved.editions.iterator().next().name ); assertEquals( "Second", retrieved.editions.iterator().next().name );
session.delete( retrieved ); session.remove( retrieved );
} }
); );
} }

View File

@ -69,10 +69,10 @@ public class GenericsTest {
s = scope.getSessionFactory().openSession(); s = scope.getSessionFactory().openSession();
tx = s.beginTransaction(); tx = s.beginTransaction();
white = s.get( Paper.class, white.getId() ); white = s.get( Paper.class, white.getId() );
s.delete( white.getType() ); s.remove( white.getType() );
s.delete( white.getOwner() ); s.remove( white.getOwner() );
s.delete( white.getValue() ); s.remove( white.getValue() );
s.delete( white ); s.remove( white );
tx.commit(); tx.commit();
//s.close(); //s.close();
assertFalse( s.isOpen() ); assertFalse( s.isOpen() );

View File

@ -47,7 +47,7 @@ public class EnumIdTest {
session -> { session -> {
PlanetCheatSheet mercuryFromDb = session.get( PlanetCheatSheet.class, mercury.getPlanet() ); PlanetCheatSheet mercuryFromDb = session.get( PlanetCheatSheet.class, mercury.getPlanet() );
assertNotNull( mercuryFromDb ); assertNotNull( mercuryFromDb );
session.delete( mercuryFromDb ); session.remove( mercuryFromDb );
} }
); );

View File

@ -62,7 +62,7 @@ public class IdTest {
Hotel hotel = new Hotel(); Hotel hotel = new Hotel();
hotel.setId( 12L ); hotel.setId( 12L );
hotel.setName( "California" ); hotel.setName( "California" );
session.saveOrUpdate( hotel ); session.merge( hotel );
} }
); );
@ -81,7 +81,7 @@ public class IdTest {
scope.inTransaction( scope.inTransaction(
session -> { session -> {
savedHotel.setName( "Hotel du nord" ); savedHotel.setName( "Hotel du nord" );
session.saveOrUpdate( savedHotel ); session.merge( savedHotel );
} }
); );
@ -90,7 +90,7 @@ public class IdTest {
Hotel hotel = session.get( Hotel.class, 12L ); Hotel hotel = session.get( Hotel.class, 12L );
assertNotNull( hotel ); assertNotNull( hotel );
assertEquals( "Hotel du nord", hotel.getName() ); assertEquals( "Hotel du nord", hotel.getName() );
session.delete( hotel ); session.remove( hotel );
} }
); );
} }
@ -114,8 +114,8 @@ public class IdTest {
Furniture furFromDb = session.get( Furniture.class, fur.getId() ); Furniture furFromDb = session.get( Furniture.class, fur.getId() );
assertNotNull( systemFromDb ); assertNotNull( systemFromDb );
assertNotNull( furFromDb ); assertNotNull( furFromDb );
session.delete( systemFromDb ); session.remove( systemFromDb );
session.delete( furFromDb ); session.remove( furFromDb );
} }
); );
} }
@ -132,7 +132,7 @@ public class IdTest {
session.persist( monkey ); session.persist( monkey );
session.flush(); session.flush();
assertNotNull( monkey.getId() ); assertNotNull( monkey.getId() );
session.delete( monkey ); session.remove( monkey );
} }
); );
} }
@ -157,9 +157,9 @@ public class IdTest {
scope.inTransaction( scope.inTransaction(
session -> { session -> {
session.delete( session.get( Ball.class, 1 ) ); session.remove( session.get( Ball.class, 1 ) );
session.delete( session.get( Dog.class, 1 ) ); session.remove( session.get( Dog.class, 1 ) );
session.delete( session.get( Computer.class, 1L ) ); session.remove( session.get( Computer.class, 1L ) );
} }
); );
} }
@ -176,7 +176,7 @@ public class IdTest {
scope.inTransaction( scope.inTransaction(
session -> session ->
session.delete( session.get( Shoe.class, b.getId() ) ) session.remove( session.get( Shoe.class, b.getId() ) )
); );
} }
@ -192,7 +192,7 @@ public class IdTest {
scope.inTransaction( scope.inTransaction(
session -> session ->
session.delete( session.get( Store.class, b.getId() ) ) session.remove( session.get( Store.class, b.getId() ) )
); );
} }
@ -209,7 +209,7 @@ public class IdTest {
scope.inTransaction( scope.inTransaction(
session -> session ->
session.delete( session.get( Department.class, b.getId() ) ) session.remove( session.get( Department.class, b.getId() ) )
); );
} }
@ -227,7 +227,7 @@ public class IdTest {
session -> { session -> {
Home reloadedHome = session.get( Home.class, h.getId() ); Home reloadedHome = session.get( Home.class, h.getId() );
assertEquals( h.getId(), reloadedHome.getId() ); assertEquals( h.getId(), reloadedHome.getId() );
session.delete( reloadedHome ); session.remove( reloadedHome );
} }
); );
} }
@ -246,7 +246,7 @@ public class IdTest {
session -> { session -> {
Home reloadedHome = session.get( Home.class, h.getId() ); Home reloadedHome = session.get( Home.class, h.getId() );
assertEquals( h.getId(), reloadedHome.getId() ); assertEquals( h.getId(), reloadedHome.getId() );
session.delete( reloadedHome ); session.remove( reloadedHome );
} }
); );
} }
@ -262,7 +262,7 @@ public class IdTest {
session.beginTransaction(); session.beginTransaction();
christmasTree = session.get( FirTree.class, christmasTree.getId() ); christmasTree = session.get( FirTree.class, christmasTree.getId() );
assertNotNull( christmasTree ); assertNotNull( christmasTree );
session.delete( christmasTree ); session.remove( christmasTree );
} }
); );
} }
@ -301,7 +301,7 @@ public class IdTest {
// reattach by saveOrUpdate // reattach by saveOrUpdate
session.beginTransaction(); session.beginTransaction();
fb.setClub( "Bimbo FC SA" ); fb.setClub( "Bimbo FC SA" );
session.saveOrUpdate( fb ); session.merge( fb );
session.getTransaction().commit(); session.getTransaction().commit();
// clean up // clean up
@ -310,8 +310,8 @@ public class IdTest {
fpk = new FootballerPk( "David", "Beckam" ); fpk = new FootballerPk( "David", "Beckam" );
fb = session.get( Footballer.class, fpk ); fb = session.get( Footballer.class, fpk );
assertEquals( "Bimbo FC SA", fb.getClub() ); assertEquals( "Bimbo FC SA", fb.getClub() );
session.delete( fb ); session.remove( fb );
session.delete( keeper ); session.remove( keeper );
} }
); );
} }

View File

@ -49,7 +49,7 @@ public class EnumIdTest {
mercury.getPlanet() mercury.getPlanet()
); );
assertNotNull( mercuryFromDb ); assertNotNull( mercuryFromDb );
session.delete( mercuryFromDb ); session.remove( mercuryFromDb );
} }
); );

View File

@ -58,7 +58,7 @@ public class HibernateSequenceTest {
scope.inTransaction( scope.inTransaction(
session -> { session -> {
entity.setText( "sample text" ); entity.setText( "sample text" );
session.save( entity ); session.persist( entity );
} }
); );

View File

@ -82,8 +82,8 @@ public class IdTest {
Furniture furFromDb = session.get( Furniture.class, fur.getId() ); Furniture furFromDb = session.get( Furniture.class, fur.getId() );
assertNotNull( systemfromDb ); assertNotNull( systemfromDb );
assertNotNull( furFromDb ); assertNotNull( furFromDb );
session.delete( systemfromDb ); session.remove( systemfromDb );
session.delete( furFromDb ); session.remove( furFromDb );
} }
); );
} }
@ -125,9 +125,9 @@ public class IdTest {
scope.inTransaction( scope.inTransaction(
session -> { session -> {
session.delete( session.get( Ball.class, 1 ) ); session.remove( session.get( Ball.class, 1 ) );
session.delete( session.get( Dog.class, 1 ) ); session.remove( session.get( Dog.class, 1 ) );
session.delete( session.get( Computer.class, 1L ) ); session.remove( session.get( Computer.class, 1L ) );
} }
); );
} }
@ -144,7 +144,7 @@ public class IdTest {
scope.inTransaction( scope.inTransaction(
session -> session ->
session.delete( session.get( Shoe.class, b.getId() ) ) session.remove( session.get( Shoe.class, b.getId() ) )
); );
} }
@ -160,7 +160,7 @@ public class IdTest {
scope.inTransaction( scope.inTransaction(
session -> session ->
session.delete( session.get( Store.class, b.getId() ) ) session.remove( session.get( Store.class, b.getId() ) )
); );
} }
@ -176,7 +176,7 @@ public class IdTest {
scope.inTransaction( scope.inTransaction(
session -> session ->
session.delete( session.get( Department.class, b.getId() ) ) session.remove( session.get( Department.class, b.getId() ) )
); );
} }
@ -194,7 +194,7 @@ public class IdTest {
session -> { session -> {
Home reloadedHome = session.get( Home.class, h.getId() ); Home reloadedHome = session.get( Home.class, h.getId() );
assertEquals( h.getId(), reloadedHome.getId() ); assertEquals( h.getId(), reloadedHome.getId() );
session.delete( reloadedHome ); session.remove( reloadedHome );
} }
); );
} }
@ -213,7 +213,7 @@ public class IdTest {
session -> { session -> {
Home reloadedHome = session.get( Home.class, h.getId() ); Home reloadedHome = session.get( Home.class, h.getId() );
assertEquals( h.getId(), reloadedHome.getId() ); assertEquals( h.getId(), reloadedHome.getId() );
session.delete( reloadedHome ); session.remove( reloadedHome );
} }
); );
} }
@ -231,7 +231,7 @@ public class IdTest {
christmasTree = session.get( FirTree.class, christmasTree.getId() ); christmasTree = session.get( FirTree.class, christmasTree.getId() );
assertNotNull( christmasTree ); assertNotNull( christmasTree );
session.delete( christmasTree ); session.remove( christmasTree );
} }
); );
} }
@ -273,7 +273,7 @@ public class IdTest {
// reattach by saveOrUpdate // reattach by saveOrUpdate
session.beginTransaction(); session.beginTransaction();
fb.setClub( "Bimbo FC SA" ); fb.setClub( "Bimbo FC SA" );
session.saveOrUpdate( fb ); session.merge( fb );
session.getTransaction().commit(); session.getTransaction().commit();
// clean up // clean up
@ -282,8 +282,8 @@ public class IdTest {
fpk = new FootballerPk( "David", "Beckam" ); fpk = new FootballerPk( "David", "Beckam" );
fb = session.get( Footballer.class, fpk ); fb = session.get( Footballer.class, fpk );
assertEquals( "Bimbo FC SA", fb.getClub() ); assertEquals( "Bimbo FC SA", fb.getClub() );
session.delete( fb ); session.remove( fb );
session.delete( keeper ); session.remove( keeper );
} }
); );
} }

View File

@ -38,7 +38,7 @@ public class IdClassMappedSuperclassTest {
Simple simple = new Simple(); Simple simple = new Simple();
simple.setSimpleId( "1" ); simple.setSimpleId( "1" );
simple.setCategoryId( "2" ); simple.setCategoryId( "2" );
session.save( simple ); session.persist( simple );
session.getTransaction().commit(); session.getTransaction().commit();

View File

@ -52,7 +52,7 @@ public class ImmutableTest extends BaseCoreFunctionalTestCase {
assertNotNull(germany); assertNotNull(germany);
germany.setName("France"); germany.setName("France");
assertEquals("Local name can be changed", "France", germany.getName()); assertEquals("Local name can be changed", "France", germany.getName());
s.save(germany); s.persist(germany);
tx.commit(); tx.commit();
s.close(); s.close();
@ -97,7 +97,7 @@ public class ImmutableTest extends BaseCoreFunctionalTestCase {
// try adding a state // try adding a state
State foobar = new State(); State foobar = new State();
foobar.setName("foobar"); foobar.setName("foobar");
s.save(foobar); s.persist(foobar);
germany.getStates().add(foobar); germany.getStates().add(foobar);
try { try {
tx.commit(); tx.commit();

View File

@ -135,9 +135,9 @@ public class IndexedCollectionTest {
result = w.getDrawers(); result = w.getDrawers();
assertEquals( 2, result.size() ); assertEquals( 2, result.size() );
assertEquals( d1.getId(), result.get( 1 ).getId() ); assertEquals( d1.getId(), result.get( 1 ).getId() );
s.delete( result.get( 0 ) ); s.remove( result.get( 0 ) );
s.delete( result.get( 1 ) ); s.remove( result.get( 1 ) );
s.delete( w ); s.remove( w );
s.flush(); s.flush();
tx.rollback(); tx.rollback();
} }
@ -193,9 +193,9 @@ public class IndexedCollectionTest {
result = d.getDresses(); result = d.getDresses();
assertEquals( 2, result.size() ); assertEquals( 2, result.size() );
assertEquals( d1.getId(), result.get( 1 ).getId() ); assertEquals( d1.getId(), result.get( 1 ).getId() );
s.delete( result.get( 0 ) ); s.remove( result.get( 0 ) );
s.delete( result.get( 1 ) ); s.remove( result.get( 1 ) );
s.delete( d ); s.remove( d );
s.flush(); s.flush();
tx.rollback(); tx.rollback();
} }
@ -254,9 +254,9 @@ public class IndexedCollectionTest {
hibernate = s.get( Software.class, "Hibernate" ); hibernate = s.get( Software.class, "Hibernate" );
assertEquals( 3, hibernate.getVersions().size(), "So effect on collection changes" ); assertEquals( 3, hibernate.getVersions().size(), "So effect on collection changes" );
for ( Version v : hibernate.getVersions().values() ) { for ( Version v : hibernate.getVersions().values() ) {
s.delete( v ); s.remove( v );
} }
s.delete( hibernate ); s.remove( hibernate );
s.flush(); s.flush();
@ -311,7 +311,7 @@ public class IndexedCollectionTest {
book = s.get( AddressBook.class, book.getId() ); book = s.get( AddressBook.class, book.getId() );
assertEquals( 2, book.getEntries().size() ); assertEquals( 2, book.getEntries().size() );
assertNull( book.getEntries().get( fake ) ); assertNull( book.getEntries().get( fake ) );
s.delete( book ); s.remove( book );
s.flush(); s.flush();
tx.rollback(); tx.rollback();
@ -367,7 +367,7 @@ public class IndexedCollectionTest {
assertEquals( heleneEntry.getCity(), book.getEntries().get( helene ).getCity() ); assertEquals( heleneEntry.getCity(), book.getEntries().get( helene ).getCity() );
assertEquals( "M", book.getEntries().get( helene ).getDirectory().getName() ); assertEquals( "M", book.getEntries().get( helene ).getDirectory().getName() );
s.delete( book ); s.remove( book );
tx.rollback(); tx.rollback();
} }
catch (Exception e) { catch (Exception e) {
@ -421,7 +421,7 @@ public class IndexedCollectionTest {
book = s.get( AddressBook.class, book.getId() ); book = s.get( AddressBook.class, book.getId() );
assertEquals( 2, book.getEntries().size() ); assertEquals( 2, book.getEntries().size() );
assertNull( book.getEntries().get( fake ) ); assertNull( book.getEntries().get( fake ) );
s.delete( book ); s.remove( book );
tx.rollback(); tx.rollback();
} }
catch (Exception e) { catch (Exception e) {
@ -456,8 +456,8 @@ public class IndexedCollectionTest {
News news = lemonde.getNews().get( airplane.getTitle() ); News news = lemonde.getNews().get( airplane.getTitle() );
assertNotNull( news ); assertNotNull( news );
assertEquals( airplane.getTitle(), news.getTitle() ); assertEquals( airplane.getTitle(), news.getTitle() );
s.delete( lemonde ); s.remove( lemonde );
s.delete( news ); s.remove( news );
s.getTransaction().rollback(); s.getTransaction().rollback();
} }
@ -493,8 +493,8 @@ public class IndexedCollectionTest {
News news = schwartz.getProvidedNews().get( hibernate1.getId() ); News news = schwartz.getProvidedNews().get( hibernate1.getId() );
assertNotNull( news ); assertNotNull( news );
assertEquals( hibernate1.getTitle(), news.getTitle() ); assertEquals( hibernate1.getTitle(), news.getTitle() );
s.delete( schwartz ); s.remove( schwartz );
s.delete( news ); s.remove( news );
s.getTransaction().rollback(); s.getTransaction().rollback();
} }
@ -527,7 +527,7 @@ public class IndexedCollectionTest {
Painting painting = picasso.getPaintings().get( famille.getName() ); Painting painting = picasso.getPaintings().get( famille.getName() );
assertNotNull( painting ); assertNotNull( painting );
assertEquals( painting.getName(), famille.getName() ); assertEquals( painting.getName(), famille.getName() );
s.delete( picasso ); s.remove( picasso );
tx.rollback(); tx.rollback();
} }
catch (Exception e) { catch (Exception e) {
@ -856,9 +856,9 @@ public class IndexedCollectionTest {
hibernate = s.get( Software.class, "Hibernate" ); hibernate = s.get( Software.class, "Hibernate" );
for ( Version v : hibernate.getVersions().values() ) { for ( Version v : hibernate.getVersions().values() ) {
s.delete( v ); s.remove( v );
} }
s.delete( hibernate ); s.remove( hibernate );
tx.rollback(); tx.rollback();
} }
catch (Exception e) { catch (Exception e) {

View File

@ -126,7 +126,7 @@ public class SubclassTest {
assertEquals( 10000, p.getAltitude() ); assertEquals( 10000, p.getAltitude() );
assertEquals( "0123456789", p.getSerial() ); assertEquals( "0123456789", p.getSerial() );
assertNotEquals( 3000, p.getMetricAltitude() ); assertNotEquals( 3000, p.getMetricAltitude() );
s.delete( p ); s.remove( p );
} }
); );
@ -155,10 +155,10 @@ public class SubclassTest {
assertEquals( 1, result.size() ); assertEquals( 1, result.size() );
Noise w = (Noise) result.get( 0 ); Noise w = (Noise) result.get( 0 );
assertNull( w.getType() ); assertNull( w.getType() );
s.delete( w ); s.remove( w );
result = createQueryForClass( s, Rock.class ).list(); result = createQueryForClass( s, Rock.class ).list();
assertEquals( 1, result.size() ); assertEquals( 1, result.size() );
s.delete( result.get( 0 ) ); s.remove( result.get( 0 ) );
result = createQueryForClass( s, Funk.class ).list(); result = createQueryForClass( s, Funk.class ).list();
assertEquals( 0, result.size() ); assertEquals( 0, result.size() );
} }

View File

@ -43,7 +43,7 @@ public class JoinedSubclassAndSecondaryTable {
scope.inTransaction( scope.inTransaction(
sesison -> sesison ->
sesison.createQuery( "from Pool" ).list().forEach( sesison.createQuery( "from Pool" ).list().forEach(
pool -> sesison.delete( pool ) pool -> sesison.remove( pool )
) )
); );
} }

View File

@ -114,7 +114,7 @@ public class JoinedSubclassTest {
scope.inTransaction( scope.inTransaction(
session -> { session -> {
Sweater toDelete = session.get( Sweater.class, sw.getId() ); Sweater toDelete = session.get( Sweater.class, sw.getId() );
session.delete( toDelete ); session.remove( toDelete );
} }
); );
} }
@ -225,32 +225,32 @@ public class JoinedSubclassTest {
scope.inTransaction( scope.inTransaction(
session -> { session -> {
session.createQuery( "from Customer" ).list().forEach( session.createQuery( "from Customer" ).list().forEach(
customer -> session.delete( customer ) customer -> session.remove( customer )
); );
session.createQuery( "from Client" ).list().forEach( session.createQuery( "from Client" ).list().forEach(
client -> session.delete( client ) client -> session.remove( client )
); );
session.createQuery( "from Account" ).list().forEach( session.createQuery( "from Account" ).list().forEach(
account -> session.delete( account ) account -> session.remove( account )
); );
session.createQuery( "from ProgramExecution" ).list().forEach( session.createQuery( "from ProgramExecution" ).list().forEach(
programExecution -> session.delete( programExecution ) programExecution -> session.remove( programExecution )
); );
session.createQuery( "from Alarm" ).list().forEach( session.createQuery( "from Alarm" ).list().forEach(
alarm -> session.delete( alarm ) alarm -> session.remove( alarm )
); );
session.createQuery( "from EventInformation" ).list().forEach( session.createQuery( "from EventInformation" ).list().forEach(
eventInformation -> session.delete( eventInformation ) eventInformation -> session.remove( eventInformation )
); );
session.createQuery( "from File" ).list().forEach( session.createQuery( "from File" ).list().forEach(
file -> session.delete( file ) file -> session.remove( file )
); );
} }
); );

View File

@ -62,8 +62,8 @@ public class SubclassTest {
checkClassType( f2, doc, folder ); checkClassType( f2, doc, folder );
f2 = result.get( 1 ); f2 = result.get( 1 );
checkClassType( f2, doc, folder ); checkClassType( f2, doc, folder );
session.delete( result.get( 0 ) ); session.remove( result.get( 0 ) );
session.delete( result.get( 1 ) ); session.remove( result.get( 1 ) );
} }
); );
} }

View File

@ -106,7 +106,7 @@ public class JoinTest extends BaseNonConfigCoreFunctionalTestCase {
Query q = s.createQuery( "from " + Death.class.getName() ); Query q = s.createQuery( "from " + Death.class.getName() );
death = (Death) q.uniqueResult(); death = (Death) q.uniqueResult();
assertEquals( "Well, haven't seen it", death.howDoesItHappen ); assertEquals( "Well, haven't seen it", death.howDoesItHappen );
s.delete( death ); s.remove( death );
tx.commit(); tx.commit();
s.close(); s.close();
} }
@ -140,8 +140,8 @@ public class JoinTest extends BaseNonConfigCoreFunctionalTestCase {
// crit.createCriteria( "owner" ).add( Restrictions.eq( "name", "kitty" ) ); // crit.createCriteria( "owner" ).add( Restrictions.eq( "name", "kitty" ) );
// life = (Life) crit.uniqueResult(); // life = (Life) crit.uniqueResult();
assertEquals( "Long long description", life.fullDescription ); assertEquals( "Long long description", life.fullDescription );
s.delete( life.owner ); s.remove( life.owner );
s.delete( life ); s.remove( life );
tx.commit(); tx.commit();
s.close(); s.close();
} }
@ -154,8 +154,8 @@ public class JoinTest extends BaseNonConfigCoreFunctionalTestCase {
SysUserOrm u=new SysUserOrm(); SysUserOrm u=new SysUserOrm();
u.setGroups( new ArrayList<>() ); u.setGroups( new ArrayList<>() );
u.getGroups().add( g ); u.getGroups().add( g );
s.save( g ); s.persist( g );
s.save( u ); s.persist( u );
s.getTransaction().commit(); s.getTransaction().commit();
s.close(); s.close();
} }

View File

@ -62,8 +62,8 @@ public class LoaderTest extends BaseCoreFunctionalTestCase {
tx = s.beginTransaction(); tx = s.beginTransaction();
t = s.get( Team.class, t2.getId() ); t = s.get( Team.class, t2.getId() );
p = s.get( Player.class, p.getId() ); p = s.get( Player.class, p.getId() );
s.delete( p ); s.remove( p );
s.delete( t ); s.remove( t );
tx.commit(); tx.commit();
s.close(); s.close();
} }

View File

@ -46,7 +46,7 @@ public class ImageTest extends BaseCoreFunctionalTestCase {
Session s = openSession(); Session s = openSession();
s.beginTransaction(); s.beginTransaction();
ImageHolder entity = new ImageHolder(); ImageHolder entity = new ImageHolder();
s.save(entity); s.persist(entity);
s.getTransaction().commit(); s.getTransaction().commit();
s.close(); s.close();
@ -97,11 +97,11 @@ public class ImageTest extends BaseCoreFunctionalTestCase {
s = openSession(); s = openSession();
s.beginTransaction(); s.beginTransaction();
entity = (ImageHolder) s.get(ImageHolder.class, entity.getId()); entity = s.get( ImageHolder.class, entity.getId());
Assert.assertNull( entity.getLongByteArray() ); Assert.assertNull( entity.getLongByteArray() );
Assert.assertNull( entity.getDog() ); Assert.assertNull( entity.getDog() );
Assert.assertNull( entity.getPicByteArray() ); Assert.assertNull( entity.getPicByteArray() );
s.delete(entity); s.remove(entity);
s.getTransaction().commit(); s.getTransaction().commit();
s.close(); s.close();
} }

View File

@ -56,7 +56,7 @@ public class MaterializedBlobTest extends BaseCoreFunctionalTestCase {
Session session = openSession(); Session session = openSession();
session.beginTransaction(); session.beginTransaction();
MaterializedBlobEntity entity = new MaterializedBlobEntity( "test", testData ); MaterializedBlobEntity entity = new MaterializedBlobEntity( "test", testData );
session.save( entity ); session.persist( entity );
session.getTransaction().commit(); session.getTransaction().commit();
session.close(); session.close();
@ -64,7 +64,7 @@ public class MaterializedBlobTest extends BaseCoreFunctionalTestCase {
session.beginTransaction(); session.beginTransaction();
entity = session.get( MaterializedBlobEntity.class, entity.getId() ); entity = session.get( MaterializedBlobEntity.class, entity.getId() );
assertTrue( Arrays.equals( testData, entity.getTheBytes() ) ); assertTrue( Arrays.equals( testData, entity.getTheBytes() ) );
session.delete( entity ); session.remove( entity );
session.getTransaction().commit(); session.getTransaction().commit();
session.close(); session.close();
} }

View File

@ -44,7 +44,7 @@ public class TextTest extends BaseCoreFunctionalTestCase {
Session s = openSession(); Session s = openSession();
s.beginTransaction(); s.beginTransaction();
LongStringHolder entity = new LongStringHolder(); LongStringHolder entity = new LongStringHolder();
s.save(entity); s.persist(entity);
s.getTransaction().commit(); s.getTransaction().commit();
s.close(); s.close();
@ -104,7 +104,7 @@ public class TextTest extends BaseCoreFunctionalTestCase {
assertNull(entity.getLongString()); assertNull(entity.getLongString());
assertNull(entity.getName()); assertNull(entity.getName());
assertNull(entity.getWhatEver()); assertNull(entity.getWhatEver());
s.delete(entity); s.remove(entity);
s.getTransaction().commit(); s.getTransaction().commit();
s.close(); s.close();
} }

View File

@ -70,7 +70,7 @@ public class VersionedLobTest extends AbstractLobTest<VersionedBook, VersionedCo
assertEquals( loadedBook.getVersion(), Integer.valueOf( 0 ) ); assertEquals( loadedBook.getVersion(), Integer.valueOf( 0 ) );
s.flush(); s.flush();
assertEquals( loadedBook.getVersion(), Integer.valueOf( 0 ) ); assertEquals( loadedBook.getVersion(), Integer.valueOf( 0 ) );
s.delete( loadedBook ); s.remove( loadedBook );
tx.commit(); tx.commit();
s.close(); s.close();
@ -97,7 +97,7 @@ public class VersionedLobTest extends AbstractLobTest<VersionedBook, VersionedCo
assertEquals( b2.getVersion(), Integer.valueOf( 0 ) ); assertEquals( b2.getVersion(), Integer.valueOf( 0 ) );
s.flush(); s.flush();
assertEquals( b2.getVersion(), Integer.valueOf( 0 ) ); assertEquals( b2.getVersion(), Integer.valueOf( 0 ) );
s.delete( b2 ); s.remove( b2 );
tx.commit(); tx.commit();
s.close(); s.close();
} }
@ -123,7 +123,7 @@ public class VersionedLobTest extends AbstractLobTest<VersionedBook, VersionedCo
assertEquals( b2.getVersion(), Integer.valueOf( 0 ) ); assertEquals( b2.getVersion(), Integer.valueOf( 0 ) );
s.flush(); s.flush();
assertEquals( b2.getVersion(), Integer.valueOf( 0 ) ); assertEquals( b2.getVersion(), Integer.valueOf( 0 ) );
s.delete( b2 ); s.remove( b2 );
tx.commit(); tx.commit();
s.close(); s.close();
} }
@ -150,7 +150,7 @@ public class VersionedLobTest extends AbstractLobTest<VersionedBook, VersionedCo
assertEquals( recompiled.getVersion(), Integer.valueOf( 0 ) ); assertEquals( recompiled.getVersion(), Integer.valueOf( 0 ) );
s.flush(); s.flush();
assertEquals( recompiled.getVersion(), Integer.valueOf( 0 ) ); assertEquals( recompiled.getVersion(), Integer.valueOf( 0 ) );
s.delete( recompiled ); s.remove( recompiled );
tx.commit(); tx.commit();
s.close(); s.close();
} }
@ -178,7 +178,7 @@ public class VersionedLobTest extends AbstractLobTest<VersionedBook, VersionedCo
assertEquals( recompiled.getVersion(), Integer.valueOf( 0 ) ); assertEquals( recompiled.getVersion(), Integer.valueOf( 0 ) );
s.flush(); s.flush();
assertEquals( recompiled.getVersion(), Integer.valueOf( 0 ) ); assertEquals( recompiled.getVersion(), Integer.valueOf( 0 ) );
s.delete( recompiled ); s.remove( recompiled );
tx.commit(); tx.commit();
s.close(); s.close();
} }

View File

@ -33,7 +33,7 @@ public class LobTest extends BaseCoreFunctionalTestCase {
entity.setId(1L); entity.setId(1L);
entity.setLobValue(session.getLobHelper().createBlob(new byte[9999])); entity.setLobValue(session.getLobHelper().createBlob(new byte[9999]));
entity.setQwerty(randomString(4000)); entity.setQwerty(randomString(4000));
session.save(entity); session.persist(entity);
session.getTransaction().commit(); session.getTransaction().commit();
session.close(); session.close();
} }

View File

@ -269,8 +269,8 @@ public class ManyToManyTest extends BaseCoreFunctionalTestCase {
assertNotNull( ee ); assertNotNull( ee );
er = ee.getEmployers().iterator().next(); er = ee.getEmployers().iterator().next();
assertTrue( "second join non lazy", Hibernate.isInitialized( er ) ); assertTrue( "second join non lazy", Hibernate.isInitialized( er ) );
s.delete( er ); s.remove( er );
s.delete( ee ); s.remove( ee );
tx.commit(); tx.commit();
s.close(); s.close();
} }
@ -415,8 +415,8 @@ public class ManyToManyTest extends BaseCoreFunctionalTestCase {
er = ee.getEmployers().iterator().next(); er = ee.getEmployers().iterator().next();
assertTrue( "second join non lazy", Hibernate.isInitialized( er ) ); assertTrue( "second join non lazy", Hibernate.isInitialized( er ) );
assertEquals( 1, er.getEmployees().size() ); assertEquals( 1, er.getEmployees().size() );
s.delete( er ); s.remove( er );
s.delete( ee ); s.remove( ee );
tx.commit(); tx.commit();
s.close(); s.close();
} }
@ -620,8 +620,8 @@ public class ManyToManyTest extends BaseCoreFunctionalTestCase {
Zone a = new Zone(); Zone a = new Zone();
InspectorPrefixes ip = new InspectorPrefixes( "dgi" ); InspectorPrefixes ip = new InspectorPrefixes( "dgi" );
Transaction tx = s.beginTransaction(); Transaction tx = s.beginTransaction();
s.save( a ); s.persist( a );
s.save( ip ); s.persist( ip );
ip.getAreas().add( a ); ip.getAreas().add( a );
tx.commit(); tx.commit();
s.close(); s.close();
@ -631,8 +631,8 @@ public class ManyToManyTest extends BaseCoreFunctionalTestCase {
assertNotNull( ip ); assertNotNull( ip );
assertEquals( 1, ip.getAreas().size() ); assertEquals( 1, ip.getAreas().size() );
assertEquals( a.getId(), ip.getAreas().get( 0 ).getId() ); assertEquals( a.getId(), ip.getAreas().get( 0 ).getId() );
s.delete( ip ); s.remove( ip );
s.delete( ip.getAreas().get( 0 ) ); s.remove( ip.getAreas().get( 0 ) );
tx.commit(); tx.commit();
s.close(); s.close();
} }
@ -644,8 +644,8 @@ public class ManyToManyTest extends BaseCoreFunctionalTestCase {
InspectorPrefixes ip = new InspectorPrefixes( "dgi" ); InspectorPrefixes ip = new InspectorPrefixes( "dgi" );
ip.setName( "Inspector" ); ip.setName( "Inspector" );
Transaction tx = s.beginTransaction(); Transaction tx = s.beginTransaction();
s.save( a ); s.persist( a );
s.save( ip ); s.persist( ip );
ip.getDesertedAreas().add( a ); ip.getDesertedAreas().add( a );
tx.commit(); tx.commit();
s.close(); s.close();
@ -655,8 +655,8 @@ public class ManyToManyTest extends BaseCoreFunctionalTestCase {
assertNotNull( ip ); assertNotNull( ip );
assertEquals( 1, ip.getDesertedAreas().size() ); assertEquals( 1, ip.getDesertedAreas().size() );
assertEquals( a.getId(), ip.getDesertedAreas().get( 0 ).getId() ); assertEquals( a.getId(), ip.getDesertedAreas().get( 0 ).getId() );
s.delete( ip ); s.remove( ip );
s.delete( ip.getDesertedAreas().get( 0 ) ); s.remove( ip.getDesertedAreas().get( 0 ) );
tx.commit(); tx.commit();
s.close(); s.close();
} }

View File

@ -157,7 +157,7 @@ public class ManyToOneTest extends BaseCoreFunctionalTestCase {
s = openSession(); s = openSession();
tx = s.beginTransaction(); tx = s.beginTransaction();
customer = s.get( Customer.class, customer.getId() ); customer = s.get( Customer.class, customer.getId() );
s.delete( customer ); s.remove( customer );
tx.commit(); tx.commit();
s.close(); s.close();
} }
@ -196,7 +196,7 @@ public class ManyToOneTest extends BaseCoreFunctionalTestCase {
s = openSession(); s = openSession();
tx = s.beginTransaction(); tx = s.beginTransaction();
s.delete( s.get( Discount.class, discount.getId() ) ); s.remove( s.get( Discount.class, discount.getId() ) );
tx.commit(); tx.commit();
s.close(); s.close();
} }

View File

@ -43,7 +43,7 @@ public class NotNullManyToOneTest extends BaseCoreFunctionalTestCase {
inTransaction( inTransaction(
session -> { session -> {
Parent parent = new Parent( new Child() ); Parent parent = new Parent( new Child() );
session.save( parent ); session.persist( parent );
} }
); );
} }
@ -53,7 +53,7 @@ public class NotNullManyToOneTest extends BaseCoreFunctionalTestCase {
inTransaction( inTransaction(
session -> { session -> {
Child child = new Child(); Child child = new Child();
session.save( child ); session.persist( child );
} }
); );
} }

View File

@ -41,8 +41,8 @@ public class NotOptionalManyToOneTest {
Child child = new Child( 1, "Luigi" ); Child child = new Child( 1, "Luigi" );
Parent parent = new Parent( 2, "Roberto", child ); Parent parent = new Parent( 2, "Roberto", child );
session.save( child ); session.persist( child );
session.save( parent ); session.persist( parent );
} }
); );
} }

View File

@ -38,10 +38,10 @@ public class ManyToOneReferencedColumnNameTest extends BaseCoreFunctionalTestCas
wi.setQtyInStock( new BigDecimal( 2 ) ); wi.setQtyInStock( new BigDecimal( 2 ) );
Session s = openSession(); Session s = openSession();
s.getTransaction().begin(); s.getTransaction().begin();
s.save( i ); s.persist( i );
s.save( v ); s.persist( v );
s.save( ic ); s.persist( ic );
s.save( wi ); s.persist( wi );
s.flush(); s.flush();
s.getTransaction().rollback(); s.getTransaction().rollback();
s.close(); s.close();

View File

@ -33,7 +33,7 @@ public class IntermediateMappedSuperclassTest {
scope.inTransaction( scope.inTransaction(
session -> { session -> {
session.createQuery( "from Account" ).list().forEach( session.createQuery( "from Account" ).list().forEach(
account -> session.delete( account ) account -> session.remove( account )
); );
} }
); );
@ -45,7 +45,7 @@ public class IntermediateMappedSuperclassTest {
SavingsAccount savingsAccount = new SavingsAccount( "123", withdrawalLimit ); SavingsAccount savingsAccount = new SavingsAccount( "123", withdrawalLimit );
scope.inTransaction( scope.inTransaction(
session -> { session -> {
session.save( savingsAccount ); session.persist( savingsAccount );
} }
); );

View File

@ -27,7 +27,7 @@ public class EmbeddedAndNaturalIdTest extends BaseCoreFunctionalTestCase {
A account = new A( new AId( 1 ), "testCode" ); A account = new A( new AId( 1 ), "testCode" );
inTransaction( inTransaction(
session -> session ->
session.save( account ) session.persist( account )
); );
} }

View File

@ -67,8 +67,8 @@ public class DefaultNullOrderingTest extends BaseCoreFunctionalTestCase {
// Cleanup data. // Cleanup data.
session.getTransaction().begin(); session.getTransaction().begin();
session.delete( monkey1 ); session.remove( monkey1 );
session.delete( monkey2 ); session.remove( monkey2 );
session.getTransaction().commit(); session.getTransaction().commit();
} }
catch (Exception e) { catch (Exception e) {
@ -111,7 +111,7 @@ public class DefaultNullOrderingTest extends BaseCoreFunctionalTestCase {
// Cleanup data. // Cleanup data.
session.getTransaction().begin(); session.getTransaction().begin();
session.delete( troop ); session.remove( troop );
session.getTransaction().commit(); session.getTransaction().commit();
} }
catch (Exception e) { catch (Exception e) {
@ -156,8 +156,8 @@ public class DefaultNullOrderingTest extends BaseCoreFunctionalTestCase {
// Cleanup data. // Cleanup data.
session.getTransaction().begin(); session.getTransaction().begin();
session.delete( monkey1 ); session.remove( monkey1 );
session.delete( monkey2 ); session.remove( monkey2 );
session.getTransaction().commit(); session.getTransaction().commit();
} }
catch (Exception e) { catch (Exception e) {

View File

@ -87,7 +87,7 @@ public class OneToManyTest extends BaseNonConfigCoreFunctionalTestCase {
s.clear(); s.clear();
Transaction tx = s.beginTransaction(); Transaction tx = s.beginTransaction();
s.delete( s.get( PoliticalParty.class, dream.getName() ) ); s.remove( s.get( PoliticalParty.class, dream.getName() ) );
tx.commit(); tx.commit();
s.close(); s.close();
} }
@ -166,7 +166,7 @@ public class OneToManyTest extends BaseNonConfigCoreFunctionalTestCase {
s = openSession(); s = openSession();
tx = s.beginTransaction(); tx = s.beginTransaction();
trainer = ( Trainer ) s.get( Trainer.class, trainer.getId() ); trainer = s.get( Trainer.class, trainer.getId() );
assertNotNull( trainer ); assertNotNull( trainer );
assertNotNull( trainer.getTrainedTigers() ); assertNotNull( trainer.getTrainedTigers() );
assertEquals( 2, trainer.getTrainedTigers().size() ); assertEquals( 2, trainer.getTrainedTigers().size() );
@ -177,7 +177,7 @@ public class OneToManyTest extends BaseNonConfigCoreFunctionalTestCase {
tx = s.beginTransaction(); tx = s.beginTransaction();
trainer = new Trainer(); trainer = new Trainer();
trainer.setName( "new trainer" ); trainer.setName( "new trainer" );
trainer.setTrainedTigers( new HashSet<Tiger>() ); trainer.setTrainedTigers( new HashSet<>() );
trainer.getTrainedTigers().add( whiteTiger ); trainer.getTrainedTigers().add( whiteTiger );
try { try {
s.persist( trainer ); s.persist( trainer );
@ -220,14 +220,14 @@ public class OneToManyTest extends BaseNonConfigCoreFunctionalTestCase {
s = openSession(); s = openSession();
tx = s.beginTransaction(); tx = s.beginTransaction();
trainer = ( Trainer ) s.get( Trainer.class, trainer.getId() ); trainer = s.get( Trainer.class, trainer.getId() );
assertNotNull( trainer ); assertNotNull( trainer );
assertNotNull( trainer.getTrainedMonkeys() ); assertNotNull( trainer.getTrainedMonkeys() );
assertEquals( 2, trainer.getTrainedMonkeys().size() ); assertEquals( 2, trainer.getTrainedMonkeys().size() );
//test suppression of trainer wo monkey //test suppression of trainer wo monkey
final Set<Monkey> monkeySet = new HashSet( trainer.getTrainedMonkeys() ); final Set<Monkey> monkeySet = new HashSet( trainer.getTrainedMonkeys() );
s.delete( trainer ); s.remove( trainer );
s.flush(); s.flush();
tx.commit(); tx.commit();
@ -242,7 +242,7 @@ public class OneToManyTest extends BaseNonConfigCoreFunctionalTestCase {
//clean up //clean up
for ( Monkey m : monkeySet ) { for ( Monkey m : monkeySet ) {
final Object managedMonkey = s.get( Monkey.class, m.getId() ); final Object managedMonkey = s.get( Monkey.class, m.getId() );
s.delete(managedMonkey); s.remove(managedMonkey);
} }
s.flush(); s.flush();
tx.commit(); tx.commit();
@ -269,7 +269,7 @@ public class OneToManyTest extends BaseNonConfigCoreFunctionalTestCase {
s = openSession(); s = openSession();
tx = s.beginTransaction(); tx = s.beginTransaction();
t = ( Troop ) s.get( Troop.class, t.getId() ); t = s.get( Troop.class, t.getId() );
assertNotNull( t.getSoldiers() ); assertNotNull( t.getSoldiers() );
assertFalse( Hibernate.isInitialized( t.getSoldiers() ) ); assertFalse( Hibernate.isInitialized( t.getSoldiers() ) );
assertEquals( 2, t.getSoldiers().size() ); assertEquals( 2, t.getSoldiers().size() );
@ -287,7 +287,7 @@ public class OneToManyTest extends BaseNonConfigCoreFunctionalTestCase {
s = openSession(); s = openSession();
tx = s.beginTransaction(); tx = s.beginTransaction();
rambo = ( Soldier ) s.get( Soldier.class, rambo.getId() ); rambo = s.get( Soldier.class, rambo.getId() );
assertTrue( Hibernate.isInitialized( rambo.getTroop() ) ); assertTrue( Hibernate.isInitialized( rambo.getTroop() ) );
tx.commit(); tx.commit();
s.close(); s.close();
@ -317,7 +317,7 @@ public class OneToManyTest extends BaseNonConfigCoreFunctionalTestCase {
s.close(); s.close();
s = openSession(); s = openSession();
tx = s.beginTransaction(); tx = s.beginTransaction();
Troop troop = ( Troop ) s.get( Troop.class, disney.getId() ); Troop troop = s.get( Troop.class, disney.getId() );
Soldier soldier = troop.getSoldiers().iterator().next(); Soldier soldier = troop.getSoldiers().iterator().next();
tx.commit(); tx.commit();
s.close(); s.close();
@ -329,10 +329,10 @@ public class OneToManyTest extends BaseNonConfigCoreFunctionalTestCase {
s.close(); s.close();
s = openSession(); s = openSession();
tx = s.beginTransaction(); tx = s.beginTransaction();
soldier = ( Soldier ) s.get( Soldier.class, mickey.getId() ); soldier = s.get( Soldier.class, mickey.getId() );
assertNull( "delete-orphan should work", soldier ); assertNull( "delete-orphan should work", soldier );
troop = ( Troop ) s.get( Troop.class, disney.getId() ); troop = s.get( Troop.class, disney.getId() );
s.delete( troop ); s.remove( troop );
tx.commit(); tx.commit();
s.close(); s.close();
} }
@ -353,8 +353,8 @@ public class OneToManyTest extends BaseNonConfigCoreFunctionalTestCase {
s.close(); s.close();
s = openSession(); s = openSession();
tx = s.beginTransaction(); tx = s.beginTransaction();
Troop troop = ( Troop ) s.get( Troop.class, disney.getId() ); Troop troop = s.get( Troop.class, disney.getId() );
s.delete( troop ); s.remove( troop );
tx.commit(); tx.commit();
s.close(); s.close();
s = openSession(); s = openSession();

View File

@ -138,11 +138,11 @@ public class OrderByTest extends BaseCoreFunctionalTestCase {
// Cleanup data. // Cleanup data.
session.getTransaction().begin(); session.getTransaction().begin();
session.delete( tiger1 ); session.remove( tiger1 );
session.delete( tiger2 ); session.remove( tiger2 );
session.delete( monkey1 ); session.remove( monkey1 );
session.delete( monkey2 ); session.remove( monkey2 );
session.delete( zoo ); session.remove( zoo );
session.getTransaction().commit(); session.getTransaction().commit();
session.close(); session.close();
@ -173,10 +173,10 @@ public class OrderByTest extends BaseCoreFunctionalTestCase {
zoo.getVisitors().add( visitor1 ); zoo.getVisitors().add( visitor1 );
zoo.getVisitors().add( visitor2 ); zoo.getVisitors().add( visitor2 );
zoo.getVisitors().add( visitor3 ); zoo.getVisitors().add( visitor3 );
session.save( zoo ); session.persist( zoo );
session.save( visitor1 ); session.persist( visitor1 );
session.save( visitor2 ); session.persist( visitor2 );
session.save( visitor3 ); session.persist( visitor3 );
session.getTransaction().commit(); session.getTransaction().commit();
session.clear(); session.clear();
@ -194,10 +194,10 @@ public class OrderByTest extends BaseCoreFunctionalTestCase {
// Cleanup data. // Cleanup data.
session.getTransaction().begin(); session.getTransaction().begin();
session.delete( visitor1 ); session.remove( visitor1 );
session.delete( visitor2 ); session.remove( visitor2 );
session.delete( visitor3 ); session.remove( visitor3 );
session.delete( zoo ); session.remove( zoo );
session.getTransaction().commit(); session.getTransaction().commit();
session.close(); session.close();
@ -235,8 +235,8 @@ public class OrderByTest extends BaseCoreFunctionalTestCase {
// Cleanup data. // Cleanup data.
session.getTransaction().begin(); session.getTransaction().begin();
session.delete( zoo1 ); session.remove( zoo1 );
session.delete( zoo2 ); session.remove( zoo2 );
session.getTransaction().commit(); session.getTransaction().commit();
session.close(); session.close();
@ -276,10 +276,10 @@ public class OrderByTest extends BaseCoreFunctionalTestCase {
// Cleanup data. // Cleanup data.
session.getTransaction().begin(); session.getTransaction().begin();
session.delete( item1 ); session.remove( item1 );
session.delete( item2 ); session.remove( item2 );
session.delete( item3 ); session.remove( item3 );
session.delete( box1 ); session.remove( box1 );
session.getTransaction().commit(); session.getTransaction().commit();
session.close(); session.close();
@ -300,7 +300,7 @@ public class OrderByTest extends BaseCoreFunctionalTestCase {
account.addTransaction( "zzzzz" ); account.addTransaction( "zzzzz" );
account.addTransaction( "aaaaa" ); account.addTransaction( "aaaaa" );
account.addTransaction( "mmmmm" ); account.addTransaction( "mmmmm" );
s.save( account ); s.persist( account );
s.getTransaction().commit(); s.getTransaction().commit();
s.close(); s.close();
@ -413,9 +413,9 @@ public class OrderByTest extends BaseCoreFunctionalTestCase {
computer2.setComputerName( "Alice's computer" ); computer2.setComputerName( "Alice's computer" );
computer2.setEmployee( employee ); computer2.setEmployee( employee );
s.save( employee ); s.persist( employee );
s.save( computer2 ); s.persist( computer2 );
s.save( computer ); s.persist( computer );
s.flush(); s.flush();
s.clear(); s.clear();
@ -490,7 +490,7 @@ public class OrderByTest extends BaseCoreFunctionalTestCase {
assertEquals( "c21", b2cs.get( 0 ).getName() ); assertEquals( "c21", b2cs.get( 0 ).getName() );
assertEquals( "c22", b2cs.get( 1 ).getName() ); assertEquals( "c22", b2cs.get( 1 ).getName() );
s.delete( a ); s.remove( a );
s.getTransaction().commit(); s.getTransaction().commit();
s.close(); s.close();

View File

@ -218,8 +218,8 @@ public class OneToOneTest extends BaseNonConfigCoreFunctionalTestCase {
assertNotNull( party.partyAffiliate ); assertNotNull( party.partyAffiliate );
assertEquals( party.partyId, party.partyAffiliate.partyId ); assertEquals( party.partyId, party.partyAffiliate.partyId );
s.delete( party ); s.remove( party );
s.delete( party.partyAffiliate ); s.remove( party.partyAffiliate );
tx.commit(); tx.commit();
} }
catch (Exception e) { catch (Exception e) {
@ -267,8 +267,8 @@ public class OneToOneTest extends BaseNonConfigCoreFunctionalTestCase {
assertNotNull( zip.trousers ); assertNotNull( zip.trousers );
assertEquals( trousers.id, zip.trousers.id ); assertEquals( trousers.id, zip.trousers.id );
s.delete( zip ); s.remove( zip );
s.delete( zip.trousers ); s.remove( zip.trousers );
tx.commit(); tx.commit();
} }
catch (Exception e) { catch (Exception e) {

View File

@ -83,7 +83,7 @@ public class OptionalOneToOneMappedByTest extends BaseCoreFunctionalTestCase {
); );
assertNull( affiliate.party ); assertNull( affiliate.party );
session.delete( affiliate ); session.remove( affiliate );
} ); } );
} }
@ -122,7 +122,7 @@ public class OptionalOneToOneMappedByTest extends BaseCoreFunctionalTestCase {
); );
assertNull( personAddress.getPerson() ); assertNull( personAddress.getPerson() );
session.delete( personAddress ); session.remove( personAddress );
} ); } );
} }
@ -182,7 +182,7 @@ public class OptionalOneToOneMappedByTest extends BaseCoreFunctionalTestCase {
// .add( Restrictions.eq( "personAddress", personAddress ) ) // .add( Restrictions.eq( "personAddress", personAddress ) )
// .uniqueResult(); // .uniqueResult();
session.delete( personAddress ); session.remove( personAddress );
assertNotSame( person, personAddress.getPerson() ); assertNotSame( person, personAddress.getPerson() );
personAddress.getPerson().setPersonAddress( null ); personAddress.getPerson().setPersonAddress( null );
} ); } );

View File

@ -54,7 +54,7 @@ public class OptionalOneToOneMapsIdQueryTest extends BaseNonConfigCoreFunctional
doInHibernate( this::sessionFactory, session -> { doInHibernate( this::sessionFactory, session -> {
final FooHasBarWithIdNamedId foo = session.get( FooHasBarWithIdNamedId.class, 1L ); final FooHasBarWithIdNamedId foo = session.get( FooHasBarWithIdNamedId.class, 1L );
session.delete( foo.bar ); session.remove( foo.bar );
foo.bar = null; foo.bar = null;
}); });
@ -105,7 +105,7 @@ public class OptionalOneToOneMapsIdQueryTest extends BaseNonConfigCoreFunctional
doInHibernate( this::sessionFactory, session -> { doInHibernate( this::sessionFactory, session -> {
final FooHasBarWithNoIdOrPropNamedId foo = session.get( FooHasBarWithNoIdOrPropNamedId.class, 1L ); final FooHasBarWithNoIdOrPropNamedId foo = session.get( FooHasBarWithNoIdOrPropNamedId.class, 1L );
session.delete( foo.bar ); session.remove( foo.bar );
foo.bar = null; foo.bar = null;
}); });
@ -176,7 +176,7 @@ public class OptionalOneToOneMapsIdQueryTest extends BaseNonConfigCoreFunctional
doInHibernate( this::sessionFactory, session -> { doInHibernate( this::sessionFactory, session -> {
final FooHasBarWithNonIdPropNamedId foo = session.get( FooHasBarWithNonIdPropNamedId.class, 1L ); final FooHasBarWithNonIdPropNamedId foo = session.get( FooHasBarWithNonIdPropNamedId.class, 1L );
session.delete( foo.bar ); session.remove( foo.bar );
foo.bar = null; foo.bar = null;
}); });

View File

@ -52,7 +52,7 @@ public class OptionalOneToOnePKJCQueryTest extends BaseNonConfigCoreFunctionalTe
doInHibernate( this::sessionFactory, session -> { doInHibernate( this::sessionFactory, session -> {
final FooHasBarWithIdNamedId foo = session.get( FooHasBarWithIdNamedId.class, 1L ); final FooHasBarWithIdNamedId foo = session.get( FooHasBarWithIdNamedId.class, 1L );
session.delete( foo.bar ); session.remove( foo.bar );
foo.bar = null; foo.bar = null;
}); });
@ -103,7 +103,7 @@ public class OptionalOneToOnePKJCQueryTest extends BaseNonConfigCoreFunctionalTe
doInHibernate( this::sessionFactory, session -> { doInHibernate( this::sessionFactory, session -> {
final FooHasBarWithNoIdOrPropNamedId foo = session.get( FooHasBarWithNoIdOrPropNamedId.class, 1L ); final FooHasBarWithNoIdOrPropNamedId foo = session.get( FooHasBarWithNoIdOrPropNamedId.class, 1L );
session.delete( foo.bar ); session.remove( foo.bar );
foo.bar = null; foo.bar = null;
}); });
@ -174,7 +174,7 @@ public class OptionalOneToOnePKJCQueryTest extends BaseNonConfigCoreFunctionalTe
doInHibernate( this::sessionFactory, session -> { doInHibernate( this::sessionFactory, session -> {
final FooHasBarWithNonIdPropNamedId foo = session.get( FooHasBarWithNonIdPropNamedId.class, 1L ); final FooHasBarWithNonIdPropNamedId foo = session.get( FooHasBarWithNonIdPropNamedId.class, 1L );
session.delete( foo.bar ); session.remove( foo.bar );
foo.bar = null; foo.bar = null;
}); });

View File

@ -110,7 +110,7 @@ public class OptionalOneToOnePKJCTest extends BaseCoreFunctionalTestCase {
// .uniqueResult(); // .uniqueResult();
assertNotNull( owner ); assertNotNull( owner );
assertNull( owner.getAddress() ); assertNull( owner.getAddress() );
s.delete( owner ); s.remove( owner );
s.getTransaction().commit(); s.getTransaction().commit();
s.close(); s.close();
} }
@ -148,7 +148,7 @@ public class OptionalOneToOnePKJCTest extends BaseCoreFunctionalTestCase {
assertNotNull( party ); assertNotNull( party );
assertEquals( "id", party.partyId ); assertEquals( "id", party.partyId );
assertNull( party.partyAffiliate ); assertNull( party.partyAffiliate );
s.delete( party ); s.remove( party );
s.getTransaction().commit(); s.getTransaction().commit();
s.close(); s.close();
} }

View File

@ -6,64 +6,64 @@
*/ */
package org.hibernate.orm.test.annotations.onetoone.hhh4851; package org.hibernate.orm.test.annotations.onetoone.hhh4851;
import org.junit.Test;
import org.hibernate.PropertyValueException; import org.hibernate.PropertyValueException;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment; import org.hibernate.cfg.Environment;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.fail; import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.JiraKey;
import org.hibernate.testing.orm.junit.ServiceRegistry;
import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.hibernate.testing.orm.junit.Setting;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Fail.fail;
/** /**
* @author Emmanuel Bernard * @author Emmanuel Bernard
*/ */
@TestForIssue( jiraKey = "HHH-4851" ) @JiraKey("HHH-4851")
public class HHH4851Test extends BaseCoreFunctionalTestCase { @DomainModel(
@Test annotatedClasses = {
public void testHHH4851() throws Exception {
Session session = openSession();
Transaction trx = session.beginTransaction();
Owner org = new Owner();
org.setName( "root" );
session.saveOrUpdate( org );
ManagedDevice lTerminal = new ManagedDevice();
lTerminal.setName( "test" );
lTerminal.setOwner( org );
session.saveOrUpdate( lTerminal );
Device terminal = new Device();
terminal.setTag( "test" );
terminal.setOwner( org );
try {
session.saveOrUpdate( terminal );
}
catch ( PropertyValueException e ) {
fail( "not-null checking should not be raised: " + e.getMessage() );
}
trx.commit();
session.close();
}
@Override
protected void configure(Configuration cfg) {
super.configure( cfg );
cfg.setProperty( Environment.CHECK_NULLABILITY, true );
}
@Override
protected Class<?>[] getAnnotatedClasses() {
return new Class<?>[] {
Hardware.class, Hardware.class,
DeviceGroupConfig.class, DeviceGroupConfig.class,
Hardware.class, Hardware.class,
ManagedDevice.class, ManagedDevice.class,
Device.class, Device.class,
Owner.class Owner.class
};
} }
)
@SessionFactory
@ServiceRegistry(
settings = @Setting(name = Environment.CHECK_NULLABILITY, value = "true")
)
public class HHH4851Test {
@Test
public void testHHH4851(SessionFactoryScope scope) {
scope.inTransaction(
session -> {
Owner org = new Owner();
org.setName( "root" );
session.persist( org );
ManagedDevice lTerminal = new ManagedDevice();
lTerminal.setName( "test" );
lTerminal.setOwner( org );
session.persist( lTerminal );
Device terminal = new Device();
terminal.setTag( "test" );
terminal.setOwner( org );
try {
session.merge( terminal );
}
catch (PropertyValueException e) {
fail( "not-null checking should not be raised: " + e.getMessage() );
}
}
);
}
} }

View File

@ -48,7 +48,7 @@ public class NamedQueryTest {
session -> { session -> {
for ( String title : GAME_TITLES ) { for ( String title : GAME_TITLES ) {
Game game = new Game( title ); Game game = new Game( title );
session.save( game ); session.persist( game );
} }
} ); } );
} }

View File

@ -321,7 +321,7 @@ public class QueryAndSQLTest {
session.persist( p ); session.persist( p );
Query q = session.getNamedQuery( "plane.getAll" ); Query q = session.getNamedQuery( "plane.getAll" );
assertEquals( 1, q.list().size() ); assertEquals( 1, q.list().size() );
session.delete( q.list().get( 0 ) ); session.remove( q.list().get( 0 ) );
} }
); );
} }
@ -361,7 +361,7 @@ public class QueryAndSQLTest {
assertEquals( 1, stats.getQueryCachePutCount() ); assertEquals( 1, stats.getQueryCachePutCount() );
q = session.getNamedQuery( "night.duration" ); q = session.getNamedQuery( "night.duration" );
q.setParameter( "duration", 14l ); q.setParameter( "duration", 14l );
session.delete( q.list().get( 0 ) ); session.remove( q.list().get( 0 ) );
assertEquals( 1, stats.getQueryCacheHitCount() ); assertEquals( 1, stats.getQueryCacheHitCount() );
} }
); );
@ -401,8 +401,8 @@ public class QueryAndSQLTest {
List areas = session.getNamedQuery( "getAreaByNative" ).list(); List areas = session.getNamedQuery( "getAreaByNative" ).list();
assertTrue( 1 == areas.size() ); assertTrue( 1 == areas.size() );
assertEquals( area.getName(), ( (Area) areas.get( 0 ) ).getName() ); assertEquals( area.getName(), ( (Area) areas.get( 0 ) ).getName() );
session.delete( areas.get( 0 ) ); session.remove( areas.get( 0 ) );
session.delete( n2 ); session.remove( n2 );
tx.commit(); tx.commit();
} }
finally { finally {
@ -476,8 +476,8 @@ public class QueryAndSQLTest {
assertEquals( 1, stats.getQueryCacheHitCount() ); assertEquals( 1, stats.getQueryCacheHitCount() );
Night n2 = (Night) ( (Object[]) result.get( 0 ) )[0]; Night n2 = (Night) ( (Object[]) result.get( 0 ) )[0];
assertEquals( n2.getDuration(), n.getDuration() ); assertEquals( n2.getDuration(), n.getDuration() );
session.delete( n2.getArea() ); session.remove( n2.getArea() );
session.delete( n2 ); session.remove( n2 );
} }
); );
@ -503,7 +503,7 @@ public class QueryAndSQLTest {
List result = q.list(); List result = q.list();
assertEquals( 1, result.size() ); assertEquals( 1, result.size() );
assertEquals( ship.getModel(), ( (SpaceShip) result.get( 0 ) ).getModel() ); assertEquals( ship.getModel(), ( (SpaceShip) result.get( 0 ) ).getModel() );
session.delete( result.get( 0 ) ); session.remove( result.get( 0 ) );
tx.commit(); tx.commit();
} }
finally { finally {
@ -551,8 +551,8 @@ public class QueryAndSQLTest {
//FIXME vary depending on databases //FIXME vary depending on databases
assertTrue( row[1].toString().startsWith( "50" ) ); assertTrue( row[1].toString().startsWith( "50" ) );
assertTrue( row[2].toString().startsWith( "500" ) ); assertTrue( row[2].toString().startsWith( "500" ) );
session.delete( spaceShip.getCaptain() ); session.remove( spaceShip.getCaptain() );
session.delete( spaceShip ); session.remove( spaceShip );
tx.commit(); tx.commit();
} }
finally { finally {
@ -587,8 +587,8 @@ public class QueryAndSQLTest {
results.get( 0 ) instanceof SynonymousDictionary results.get( 0 ) instanceof SynonymousDictionary
|| results.get( 1 ) instanceof SynonymousDictionary || results.get( 1 ) instanceof SynonymousDictionary
); );
session.delete( results.get( 0 ) ); session.remove( results.get( 0 ) );
session.delete( results.get( 1 ) ); session.remove( results.get( 1 ) );
tx.commit(); tx.commit();
} }
finally { finally {
@ -629,7 +629,7 @@ public class QueryAndSQLTest {
scope.inTransaction( scope.inTransaction(
session -> session ->
session.delete( session.get( Plane.class, plane.getId() ) ) session.remove( session.get( Plane.class, plane.getId() ) )
); );
} }

View File

@ -33,7 +33,7 @@ public class ExplicitSqlResultSetMappingTest extends BaseCoreFunctionalTestCase
char close = getDialect().closeQuote(); char close = getDialect().closeQuote();
queryString="select t."+open+"NAME"+close+" as "+open+"QuotEd_nAMe"+close+" from "+open+"MY_ENTITY_TABLE"+close+" t"; queryString="select t."+open+"NAME"+close+" as "+open+"QuotEd_nAMe"+close+" from "+open+"MY_ENTITY_TABLE"+close+" t";
inTransaction( inTransaction(
s -> s.save( new MyEntity( "mine" ) ) s -> s.persist( new MyEntity( "mine" ) )
); );
} }

View File

@ -47,8 +47,8 @@ public class ReferencedColumnNameTest extends BaseCoreFunctionalTestCase {
assertNotNull( h.getPostman() ); assertNotNull( h.getPostman() );
assertEquals( "Bob", h.getPostman().getName() ); assertEquals( "Bob", h.getPostman().getName() );
Postman pm = h.getPostman(); Postman pm = h.getPostman();
s.delete( h ); s.remove( h );
s.delete( pm ); s.remove( pm );
} }
); );
} }
@ -74,8 +74,8 @@ public class ReferencedColumnNameTest extends BaseCoreFunctionalTestCase {
assertNotNull( rambler ); assertNotNull( rambler );
assertNotNull( rambler.getBags() ); assertNotNull( rambler.getBags() );
assertEquals( 1, rambler.getBags().size() ); assertEquals( 1, rambler.getBags().size() );
s.delete( rambler.getBags().iterator().next() ); s.remove( rambler.getBags().iterator().next() );
s.delete( rambler ); s.remove( rambler );
} }
); );
} }
@ -99,8 +99,8 @@ public class ReferencedColumnNameTest extends BaseCoreFunctionalTestCase {
assertNotNull( luggage.getHasInside() ); assertNotNull( luggage.getHasInside() );
assertEquals( 1, luggage.getHasInside().size() ); assertEquals( 1, luggage.getHasInside().size() );
s.delete( luggage.getHasInside().iterator().next() ); s.remove( luggage.getHasInside().iterator().next() );
s.delete( luggage ); s.remove( luggage );
} }
); );
@ -144,10 +144,10 @@ public class ReferencedColumnNameTest extends BaseCoreFunctionalTestCase {
assertEquals( whiteHouse.getAddress(), bill.getLivesIn().iterator().next().getAddress() ); assertEquals( whiteHouse.getAddress(), bill.getLivesIn().iterator().next().getAddress() );
whiteHouse = bill.getLivesIn().iterator().next(); whiteHouse = bill.getLivesIn().iterator().next();
s.delete( whiteHouse ); s.remove( whiteHouse );
Iterator it = whiteHouse.getHasInhabitants().iterator(); Iterator it = whiteHouse.getHasInhabitants().iterator();
while ( it.hasNext() ) { while ( it.hasNext() ) {
s.delete( it.next() ); s.remove( it.next() );
} }
tx.commit(); tx.commit();
s.close(); s.close();
@ -206,7 +206,7 @@ public class ReferencedColumnNameTest extends BaseCoreFunctionalTestCase {
inTransaction( inTransaction(
s -> { s -> {
s.save( house ); s.persist( house );
s.flush(); s.flush();
HousePlaces get = s.get( HousePlaces.class, house.id ); HousePlaces get = s.get( HousePlaces.class, house.id );
@ -257,7 +257,7 @@ public class ReferencedColumnNameTest extends BaseCoreFunctionalTestCase {
// assertNotNull( s.createCriteria( HousePlaces.class ) // assertNotNull( s.createCriteria( HousePlaces.class )
// .add( Restrictions.eq( "neighbourPlaces.livingRoom.owner", "his" ) ).uniqueResult() ); // .add( Restrictions.eq( "neighbourPlaces.livingRoom.owner", "his" ) ).uniqueResult() );
s.delete( house ); s.remove( house );
} }
); );

Some files were not shown because too many files have changed in this diff Show More