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)
IrrelevantEntity irrelevantEntity = new IrrelevantEntity();
irrelevantEntity.setName( "valid 1" );
session.save( irrelevantEntity );
session.persist( irrelevantEntity );
//name is required
irrelevantEntity = new IrrelevantEntity();
session.save( irrelevantEntity );
session.persist( irrelevantEntity );
try {
session.flush();
Assert.fail( "Validation exception did not occur" );
@ -53,7 +53,7 @@ public class StatementCacheTest extends BaseCoreFunctionalTestCase {
//save a new entity and commit it
IrrelevantEntity irrelevantEntity = new IrrelevantEntity();
irrelevantEntity.setName( "valid 2" );
session.save( irrelevantEntity );
session.persist( irrelevantEntity );
session.flush();
}
);

View File

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

View File

@ -57,7 +57,7 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
}
@Test
public void testDialectSQLFunctions() throws Exception {
public void testDialectSQLFunctions() {
Session s = openSession();
Transaction t = s.beginTransaction();
@ -66,7 +66,7 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
simple.setAddress("Simple Address");
simple.setPay(new Float(45.8));
simple.setCount(2);
s.save( simple );
s.persist( simple );
// Test to make sure allocating a specified object operates correctly.
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] );
simple.setPay(new Float(-45.8));
s.update(simple);
simple = s.merge(simple);
// Test type conversions while using nested functions (Float to Int).
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...
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);
assertTrue( 0 == value.intValue() );
@ -111,17 +111,17 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
.get(0);
assertTrue( 0 == value.intValue() );
s.delete(simple);
s.remove(simple);
t.commit();
s.close();
}
public void testSetProperties() throws Exception {
public void testSetProperties() {
Session s = openSession();
Transaction t = s.beginTransaction();
Simple simple = new Simple( Long.valueOf( 10 ) );
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");
q.setProperties(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.setProperties(single);
assertTrue( q.list().get(0)==simple );
s.delete(simple);
s.remove(simple);
t.commit();
s.close();
}
public void testBroken() throws Exception {
public void testBroken() {
Session s = openSession();
Transaction t = s.beginTransaction();
Broken b = new Fixed();
b.setId( Long.valueOf( 123 ));
b.setOtherId("foobar");
s.save(b);
s.persist(b);
s.flush();
b.setTimestamp( new Date() );
t.commit();
@ -164,52 +164,52 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
s = openSession();
t = s.beginTransaction();
s.update(b);
b = s.merge(b);
t.commit();
s.close();
s = openSession();
t = s.beginTransaction();
b = (Broken) s.load( Broken.class, b );
b = s.getReference( Broken.class, b );
t.commit();
s.close();
s = openSession();
t = s.beginTransaction();
s.delete(b);
s.remove(b);
t.commit();
s.close();
}
public void testNothinToUpdate() throws Exception {
public void testNothinToUpdate() {
Session s = openSession();
Transaction t = s.beginTransaction();
Simple simple = new Simple( Long.valueOf(10) );
simple.setName("Simple 1");
s.save( simple );
s.persist( simple );
t.commit();
s.close();
s = openSession();
t = s.beginTransaction();
s.update( simple );
simple = s.merge( simple );
t.commit();
s.close();
s = openSession();
t = s.beginTransaction();
s.update( simple );
s.delete(simple);
simple = s.merge( simple );
s.remove(simple);
t.commit();
s.close();
}
public void testCachedQuery() throws Exception {
public void testCachedQuery() {
Session s = openSession();
Transaction t = s.beginTransaction();
Simple simple = new Simple( Long.valueOf(10) );
simple.setName("Simple 1");
s.save( simple );
s.persist( simple );
t.commit();
s.close();
@ -248,8 +248,8 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
s = openSession();
t = s.beginTransaction();
s.update( simple );
s.delete(simple);
simple = s.merge( simple );
s.remove(simple);
t.commit();
s.close();
@ -264,12 +264,12 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
s.close();
}
public void testCachedQueryRegion() throws Exception {
public void testCachedQueryRegion() {
Session s = openSession();
Transaction t = s.beginTransaction();
Simple simple = new Simple( Long.valueOf(10) );
simple.setName("Simple 1");
s.save( simple );
s.persist( simple );
t.commit();
s.close();
@ -300,8 +300,8 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
s = openSession();
t = s.beginTransaction();
s.update( simple );
s.delete(simple);
simple = s.merge( simple );
s.remove(simple);
t.commit();
s.close();
@ -322,7 +322,7 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
Transaction t = s.beginTransaction();
Simple simple = new Simple( Long.valueOf( 10 ) );
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(s.name, 3) = 'foofoofoo'" ).list();
@ -351,7 +351,7 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
other.setName( "Simple 2" );
other.setCount( 12 );
simple.setOther( other );
s.save( other );
s.persist( other );
//s.find("from Simple s where s.name ## 'cat|rat|bag'");
assertTrue(
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 ) );
min.setCount( -1 );
s.save( min );
s.persist( min );
assertTrue(
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 );
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();
set.add( "Simple 1" );
set.add( "foo" );
@ -460,9 +460,9 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
sr.get();
}
s.delete( other );
s.delete( simple );
s.delete( min );
s.remove( other );
s.remove( simple );
s.remove( min );
t.commit();
}
@ -474,7 +474,7 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
Blobber b = new Blobber();
b.setBlob( s.getLobHelper().createBlob( "foo/bar/baz".getBytes() ) );
b.setClob( s.getLobHelper().createClob("foo/bar/baz") );
s.save(b);
s.persist(b);
//s.refresh(b);
//assertTrue( b.getClob() instanceof ClobImpl );
s.flush();
@ -489,9 +489,9 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
s = openSession();
s.beginTransaction();
b = (Blobber) s.load( Blobber.class, new Integer( b.getId() ) );
b = s.getReference( Blobber.class, b.getId() );
Blobber b2 = new Blobber();
s.save(b2);
s.persist(b2);
b2.setBlob( b.getBlob() );
b.setBlob(null);
//assertTrue( b.getClob().getSubString(1, 3).equals("fab") );
@ -503,7 +503,7 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
s = openSession();
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") );
s.flush();
s.getTransaction().commit();
@ -511,7 +511,7 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
s = openSession();
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") );
//b.getClob().setString(5, "1234567890");
s.flush();
@ -519,7 +519,7 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
s.close();
}
public void testSqlFunctionAsAlias() throws Exception {
public void testSqlFunctionAsAlias() {
String functionName = locateAppropriateDialectFunctionNameForAliasTest();
if (functionName == null) {
log.info("Dialect does not list any no-arg functions");
@ -533,7 +533,7 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
Transaction t = s.beginTransaction();
Simple simple = new Simple( Long.valueOf(10) );
simple.setName("Simple 1");
s.save( simple );
s.persist( simple );
t.commit();
s.close();
@ -542,7 +542,7 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
List result = s.createQuery( query ).list();
assertTrue( result.size() == 1 );
assertTrue(result.get(0) instanceof Simple);
s.delete( result.get(0) );
s.remove( result.get(0) );
t.commit();
s.close();
}
@ -564,7 +564,7 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
Transaction t = s.beginTransaction();
Simple simple = new Simple( Long.valueOf(10) );
simple.setName("Simple 1");
s.save( simple );
s.persist( simple );
t.commit();
s.close();
@ -588,7 +588,7 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
t = s.beginTransaction();
Simple simple2 = new Simple( Long.valueOf(12) );
simple2.setCount(133);
s.save( simple2 );
s.persist( simple2 );
t.commit();
s.close();
@ -606,7 +606,7 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
list = q.setCacheable(true).list();
assertTrue( list.size()==2 );
for ( Object o : list ) {
s.delete( o );
s.remove( o );
}
t.commit();
s.close();
@ -676,7 +676,7 @@ public class SQLFunctionsInterSystemsTest extends BaseCoreFunctionalTestCase {
object.setDateText( "1977-07-03" );
object.setDate1( testvalue );
object.setDate3( testvalue3 );
s.save( object );
s.persist( object );
s.getTransaction().commit();
s.close();

View File

@ -42,7 +42,7 @@ public class PreUpdateEventListenerVetoTest extends BaseSessionFactoryFunctional
ExampleEntity entity = new ExampleEntity();
entity.id = EXAMPLE_ID_VALUE;
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 );
entity.name = "new_name";
session.update( entity );
entity = session.merge( entity );
final Long versionBeforeFlush = entity.version;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -110,7 +110,7 @@ public class CascadeTest {
session -> {
Tooth t = session.get( Tooth.class, tooth.id );
assertNotNull( t );
session.delete( t.mouth );
session.remove( t.mouth );
}
);
scope.inTransaction(
@ -148,7 +148,7 @@ public class CascadeTest {
scope.inTransaction(
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(
pairHolder -> {
PersonPair pair = pairHolder.getPair();
session.delete( pairHolder );
session.delete(pair.getLeft());
session.delete(pair.getRight());
session.remove( pairHolder );
session.remove(pair.getLeft());
session.remove(pair.getRight());
}
);
}

View File

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

View File

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

View File

@ -145,18 +145,18 @@ public class MultiCircleNonJpaCascadeIdentityTest {
scope.inTransaction(
session -> {
b = (EntityB) session.merge( b );
c = (EntityC) session.merge( c );
d = (EntityD) session.merge( d );
e = (EntityE) session.merge( e );
f = (EntityF) session.merge( f );
g = (EntityG) session.merge( g );
session.delete( f );
session.delete( g );
session.delete( b );
session.delete( d );
session.delete( e );
session.delete( c );
b = session.merge( b );
c = session.merge( c );
d = session.merge( d );
e = session.merge( e );
f = session.merge( f );
g = session.merge( g );
session.remove( f );
session.remove( g );
session.remove( b );
session.remove( d );
session.remove( e );
session.remove( c );
}
);
}
@ -170,29 +170,11 @@ public class MultiCircleNonJpaCascadeIdentityTest {
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
public void testMerge(SessionFactoryScope scope) {
scope.inTransaction(
session -> {
b = (EntityB) session.merge( b );
b = session.merge( b );
c = b.getC();
d = b.getD();
e = d.getE();

View File

@ -141,18 +141,18 @@ public class MultiCircleNonJpaCascadeSequenceTest {
scope.inTransaction(
session -> {
b = (B) session.merge( b );
c = (C) session.merge( c );
d = (D) session.merge( d );
e = (E) session.merge( e );
f = (F) session.merge( f );
g = (G) session.merge( g );
session.delete( f );
session.delete( g );
session.delete( b );
session.delete( d );
session.delete( e );
session.delete( c );
b = session.merge( b );
c = session.merge( c );
d = session.merge( d );
e = session.merge( e );
f = session.merge( f );
g = session.merge( g );
session.remove( f );
session.remove( g );
session.remove( b );
session.remove( d );
session.remove( e );
session.remove( c );
}
);
}
@ -166,29 +166,11 @@ public class MultiCircleNonJpaCascadeSequenceTest {
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
public void testMerge(SessionFactoryScope scope) {
scope.inTransaction(
session -> {
b = (B) session.merge( b );
b = session.merge( b );
c = b.getC();
d = b.getD();
e = d.getE();

View File

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

View File

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

View File

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

View File

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

View File

@ -36,14 +36,14 @@ public class QueryTest {
entityWithAnElementCollection.addSomeString( "abc" );
entityWithAnElementCollection.addSomeString( "efg" );
session.save( entityWithAnElementCollection );
session.persist( entityWithAnElementCollection );
EntityWithAnElementCollection entityWithAnElementCollection2 = new EntityWithAnElementCollection();
entityWithAnElementCollection2.setId( 2L );
entityWithAnElementCollection2.addSomeString( "hil" );
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 ) );
scope.inTransaction(
session ->
session.save( q )
session.persist( q )
);
scope.inTransaction(
@ -43,7 +43,7 @@ public class TestBasicOps {
assertEquals( 1, q1.getIncludedLocations().size() );
Location l = q1.getIncludedLocations().iterator().next();
assertEquals( Location.Type.COUNTY, l.getType() );
session.delete( q1 );
session.remove( q1 );
}
);
}
@ -54,13 +54,13 @@ public class TestBasicOps {
scope.inTransaction(
session -> {
Query q = new Query( new Location( null, Location.Type.COMMUNE ) );
session.save( q );
session.persist( q );
session.getTransaction().commit();
session.clear();
Transaction transaction = session.beginTransaction();
q.getIncludedLocations().add( new Location( null, Location.Type.COUNTY ) );
session.update( q );
session.merge( q );
transaction.commit();
session.clear();
@ -74,14 +74,14 @@ public class TestBasicOps {
Iterator<Location> itr = q.getIncludedLocations().iterator();
itr.next();
itr.remove();
session.update( q );
session.merge( q );
transaction.commit();
session.clear();
session.beginTransaction();
q = session.get( Query.class, q.getId() );
assertEquals( 1, q.getIncludedLocations().size() );
session.delete( q );
session.remove( q );
}
);
}

View File

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

View File

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

View File

@ -48,12 +48,12 @@ public class RecreateCollectionTest {
Poi poi1 = new Poi( "Poi 1" );
Poi poi2 = new Poi( "Poi 2" );
session.save( poi1 );
session.save( poi2 );
session.persist( poi1 );
session.persist( poi2 );
RaceExecution race = new RaceExecution();
session.save( race );
session.persist( race );
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_OTHER_ENTITY_TABLE_NAME, 0 ) );
session.save( someEntity );
session.save( someOtherEntity );
session.persist( someEntity );
session.persist( someOtherEntity );
}
);
@ -86,8 +86,8 @@ public class BasicOperationsTest {
try {
session.beginTransaction();
session.delete( someEntity );
session.delete( someOtherEntity );
session.remove( someEntity );
session.remove( someOtherEntity );
session.getTransaction().commit();
}
finally {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -62,10 +62,10 @@ public class EmbeddableWithMany2OneTest {
session.createQuery( "from Person p where p.address.country.id = 'US'" )
.list();
Person p = session.load( Person.class, person.getId() );
session.delete( p );
session.remove( p );
List countries = session.createQuery( "from Country" ).list();
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.
scope.inTransaction(
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();
}
);
@ -53,9 +53,9 @@ public class EmbeddableWithOne2ManyTest {
);
scope.inTransaction(
session -> {
Person p = (Person) session.load( Person.class, person.getId() );
session.delete( p );
List aliases = session.createQuery( "from Alias" ).list();
Person p = session.getReference( Person.class, person.getId() );
session.remove( p );
List<Alias> aliases = session.createQuery( "from Alias", Alias.class ).list();
assertEquals( 0, aliases.size() );
}
);

View File

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

View File

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

View File

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

View File

@ -55,9 +55,9 @@ public class PropertyDefaultMappingsTest extends BaseCoreFunctionalTestCase {
tx.commit();
s.clear();
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() );
s.delete( wm );
s.remove( wm );
tx.commit();
s.close();
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -71,7 +71,7 @@ public class EmbeddedGenericsTest {
session -> {
Classes.PopularBook retrieved = session.get( Classes.PopularBook.class, b.id );
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();
tx = s.beginTransaction();
white = s.get( Paper.class, white.getId() );
s.delete( white.getType() );
s.delete( white.getOwner() );
s.delete( white.getValue() );
s.delete( white );
s.remove( white.getType() );
s.remove( white.getOwner() );
s.remove( white.getValue() );
s.remove( white );
tx.commit();
//s.close();
assertFalse( s.isOpen() );

View File

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

View File

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

View File

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

View File

@ -58,7 +58,7 @@ public class HibernateSequenceTest {
scope.inTransaction(
session -> {
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() );
assertNotNull( systemfromDb );
assertNotNull( furFromDb );
session.delete( systemfromDb );
session.delete( furFromDb );
session.remove( systemfromDb );
session.remove( furFromDb );
}
);
}
@ -125,9 +125,9 @@ public class IdTest {
scope.inTransaction(
session -> {
session.delete( session.get( Ball.class, 1 ) );
session.delete( session.get( Dog.class, 1 ) );
session.delete( session.get( Computer.class, 1L ) );
session.remove( session.get( Ball.class, 1 ) );
session.remove( session.get( Dog.class, 1 ) );
session.remove( session.get( Computer.class, 1L ) );
}
);
}
@ -144,7 +144,7 @@ public class IdTest {
scope.inTransaction(
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(
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(
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 -> {
Home reloadedHome = session.get( Home.class, h.getId() );
assertEquals( h.getId(), reloadedHome.getId() );
session.delete( reloadedHome );
session.remove( reloadedHome );
}
);
}
@ -213,7 +213,7 @@ public class IdTest {
session -> {
Home reloadedHome = session.get( Home.class, h.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() );
assertNotNull( christmasTree );
session.delete( christmasTree );
session.remove( christmasTree );
}
);
}
@ -273,7 +273,7 @@ public class IdTest {
// reattach by saveOrUpdate
session.beginTransaction();
fb.setClub( "Bimbo FC SA" );
session.saveOrUpdate( fb );
session.merge( fb );
session.getTransaction().commit();
// clean up
@ -282,8 +282,8 @@ public class IdTest {
fpk = new FootballerPk( "David", "Beckam" );
fb = session.get( Footballer.class, fpk );
assertEquals( "Bimbo FC SA", fb.getClub() );
session.delete( fb );
session.delete( keeper );
session.remove( fb );
session.remove( keeper );
}
);
}

View File

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

View File

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

View File

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

View File

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

View File

@ -43,7 +43,7 @@ public class JoinedSubclassAndSecondaryTable {
scope.inTransaction(
sesison ->
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(
session -> {
Sweater toDelete = session.get( Sweater.class, sw.getId() );
session.delete( toDelete );
session.remove( toDelete );
}
);
}
@ -225,32 +225,32 @@ public class JoinedSubclassTest {
scope.inTransaction(
session -> {
session.createQuery( "from Customer" ).list().forEach(
customer -> session.delete( customer )
customer -> session.remove( customer )
);
session.createQuery( "from Client" ).list().forEach(
client -> session.delete( client )
client -> session.remove( client )
);
session.createQuery( "from Account" ).list().forEach(
account -> session.delete( account )
account -> session.remove( account )
);
session.createQuery( "from ProgramExecution" ).list().forEach(
programExecution -> session.delete( programExecution )
programExecution -> session.remove( programExecution )
);
session.createQuery( "from Alarm" ).list().forEach(
alarm -> session.delete( alarm )
alarm -> session.remove( alarm )
);
session.createQuery( "from EventInformation" ).list().forEach(
eventInformation -> session.delete( eventInformation )
eventInformation -> session.remove( eventInformation )
);
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 );
f2 = result.get( 1 );
checkClassType( f2, doc, folder );
session.delete( result.get( 0 ) );
session.delete( result.get( 1 ) );
session.remove( result.get( 0 ) );
session.remove( result.get( 1 ) );
}
);
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -43,7 +43,7 @@ public class NotNullManyToOneTest extends BaseCoreFunctionalTestCase {
inTransaction(
session -> {
Parent parent = new Parent( new Child() );
session.save( parent );
session.persist( parent );
}
);
}
@ -53,7 +53,7 @@ public class NotNullManyToOneTest extends BaseCoreFunctionalTestCase {
inTransaction(
session -> {
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" );
Parent parent = new Parent( 2, "Roberto", child );
session.save( child );
session.save( parent );
session.persist( child );
session.persist( parent );
}
);
}

View File

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

View File

@ -33,7 +33,7 @@ public class IntermediateMappedSuperclassTest {
scope.inTransaction(
session -> {
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 );
scope.inTransaction(
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" );
inTransaction(
session ->
session.save( account )
session.persist( account )
);
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -6,64 +6,64 @@
*/
package org.hibernate.orm.test.annotations.onetoone.hhh4851;
import org.junit.Test;
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.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
*/
@TestForIssue( jiraKey = "HHH-4851" )
public class HHH4851Test extends BaseCoreFunctionalTestCase {
@Test
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<?>[] {
@JiraKey("HHH-4851")
@DomainModel(
annotatedClasses = {
Hardware.class,
DeviceGroupConfig.class,
Hardware.class,
ManagedDevice.class,
Device.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 -> {
for ( String title : GAME_TITLES ) {
Game game = new Game( title );
session.save( game );
session.persist( game );
}
} );
}

View File

@ -321,7 +321,7 @@ public class QueryAndSQLTest {
session.persist( p );
Query q = session.getNamedQuery( "plane.getAll" );
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() );
q = session.getNamedQuery( "night.duration" );
q.setParameter( "duration", 14l );
session.delete( q.list().get( 0 ) );
session.remove( q.list().get( 0 ) );
assertEquals( 1, stats.getQueryCacheHitCount() );
}
);
@ -401,8 +401,8 @@ public class QueryAndSQLTest {
List areas = session.getNamedQuery( "getAreaByNative" ).list();
assertTrue( 1 == areas.size() );
assertEquals( area.getName(), ( (Area) areas.get( 0 ) ).getName() );
session.delete( areas.get( 0 ) );
session.delete( n2 );
session.remove( areas.get( 0 ) );
session.remove( n2 );
tx.commit();
}
finally {
@ -476,8 +476,8 @@ public class QueryAndSQLTest {
assertEquals( 1, stats.getQueryCacheHitCount() );
Night n2 = (Night) ( (Object[]) result.get( 0 ) )[0];
assertEquals( n2.getDuration(), n.getDuration() );
session.delete( n2.getArea() );
session.delete( n2 );
session.remove( n2.getArea() );
session.remove( n2 );
}
);
@ -503,7 +503,7 @@ public class QueryAndSQLTest {
List result = q.list();
assertEquals( 1, result.size() );
assertEquals( ship.getModel(), ( (SpaceShip) result.get( 0 ) ).getModel() );
session.delete( result.get( 0 ) );
session.remove( result.get( 0 ) );
tx.commit();
}
finally {
@ -551,8 +551,8 @@ public class QueryAndSQLTest {
//FIXME vary depending on databases
assertTrue( row[1].toString().startsWith( "50" ) );
assertTrue( row[2].toString().startsWith( "500" ) );
session.delete( spaceShip.getCaptain() );
session.delete( spaceShip );
session.remove( spaceShip.getCaptain() );
session.remove( spaceShip );
tx.commit();
}
finally {
@ -587,8 +587,8 @@ public class QueryAndSQLTest {
results.get( 0 ) instanceof SynonymousDictionary
|| results.get( 1 ) instanceof SynonymousDictionary
);
session.delete( results.get( 0 ) );
session.delete( results.get( 1 ) );
session.remove( results.get( 0 ) );
session.remove( results.get( 1 ) );
tx.commit();
}
finally {
@ -629,7 +629,7 @@ public class QueryAndSQLTest {
scope.inTransaction(
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();
queryString="select t."+open+"NAME"+close+" as "+open+"QuotEd_nAMe"+close+" from "+open+"MY_ENTITY_TABLE"+close+" t";
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() );
assertEquals( "Bob", h.getPostman().getName() );
Postman pm = h.getPostman();
s.delete( h );
s.delete( pm );
s.remove( h );
s.remove( pm );
}
);
}
@ -74,8 +74,8 @@ public class ReferencedColumnNameTest extends BaseCoreFunctionalTestCase {
assertNotNull( rambler );
assertNotNull( rambler.getBags() );
assertEquals( 1, rambler.getBags().size() );
s.delete( rambler.getBags().iterator().next() );
s.delete( rambler );
s.remove( rambler.getBags().iterator().next() );
s.remove( rambler );
}
);
}
@ -99,8 +99,8 @@ public class ReferencedColumnNameTest extends BaseCoreFunctionalTestCase {
assertNotNull( luggage.getHasInside() );
assertEquals( 1, luggage.getHasInside().size() );
s.delete( luggage.getHasInside().iterator().next() );
s.delete( luggage );
s.remove( luggage.getHasInside().iterator().next() );
s.remove( luggage );
}
);
@ -144,10 +144,10 @@ public class ReferencedColumnNameTest extends BaseCoreFunctionalTestCase {
assertEquals( whiteHouse.getAddress(), bill.getLivesIn().iterator().next().getAddress() );
whiteHouse = bill.getLivesIn().iterator().next();
s.delete( whiteHouse );
s.remove( whiteHouse );
Iterator it = whiteHouse.getHasInhabitants().iterator();
while ( it.hasNext() ) {
s.delete( it.next() );
s.remove( it.next() );
}
tx.commit();
s.close();
@ -206,7 +206,7 @@ public class ReferencedColumnNameTest extends BaseCoreFunctionalTestCase {
inTransaction(
s -> {
s.save( house );
s.persist( house );
s.flush();
HousePlaces get = s.get( HousePlaces.class, house.id );
@ -257,7 +257,7 @@ public class ReferencedColumnNameTest extends BaseCoreFunctionalTestCase {
// assertNotNull( s.createCriteria( HousePlaces.class )
// .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