HHH-18539 update tests after removal of load()

Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
Gavin King 2024-08-29 11:24:31 +02:00
parent 6fe0553fb9
commit d38971f75b
120 changed files with 386 additions and 386 deletions

View File

@ -30,7 +30,7 @@ public class ProxyBreakingTest extends BaseCoreFunctionalTestCase {
s.flush();
s.clear();
assertNotNull( "The proxy creation failure is breaking things", h.getId() );
h = (Hammer) s.load( Hammer.class, h.getId() );
h = (Hammer) s.getReference( Hammer.class, h.getId() );
assertFalse( Hibernate.isInitialized( h ) );
tx.rollback();
s.close();

View File

@ -61,7 +61,7 @@ public class EmbeddableWithMany2OneTest {
// same query!
session.createQuery( "from Person p where p.address.country.id = 'US'" )
.list();
Person p = session.load( Person.class, person.getId() );
Person p = session.getReference( Person.class, person.getId() );
session.remove( p );
List countries = session.createQuery( "from Country" ).list();
assertEquals( 1, countries.size() );

View File

@ -295,10 +295,10 @@ public class BasicHibernateAnnotationsTest extends BaseCoreFunctionalTestCase {
s = openSession();
tx = s.beginTransaction();
topic = (Topic) s.load( Topic.class, topic.getId() );
topic = (Topic) s.getReference( Topic.class, topic.getId() );
s.enableFilter("byState").setParameter("state", "published");
topic = (Topic) s.load( Topic.class, topic.getId() );
topic = (Topic) s.getReference( Topic.class, topic.getId() );
assertNotNull(topic);
assertTrue(topic.getNarratives().size() == 1);
assertEquals("published", topic.getNarratives().iterator().next().getState());
@ -392,8 +392,8 @@ public class BasicHibernateAnnotationsTest extends BaseCoreFunctionalTestCase {
tx = s.beginTransaction();
s.clear();
team2 = (SoccerTeam)s.load(team2.getClass(), team2.getId());
team = (SoccerTeam)s.load(team.getClass(), team.getId());
team2 = (SoccerTeam)s.getReference(team2.getClass(), team2.getId());
team = (SoccerTeam)s.getReference(team.getClass(), team.getId());
int count = ( (Long) s.createQuery( "select count(*) from Player" ).list().get( 0 ) ).intValue();
assertEquals("expected count of 2 but got = " + count, count, 2);

View File

@ -61,7 +61,7 @@ public class IdClassGeneratedValueTest {
session -> {
List<Simple> simpleList = session.createQuery( "select s from Simple s" ).list();
assertEquals( 2, simpleList.size() );
Simple s1 = session.load( Simple.class, new SimplePK( 1L, 2L ) );
Simple s1 = session.getReference( Simple.class, new SimplePK( 1L, 2L ) );
assertEquals( s1.getQuantity(), 10 );
session.clear();
}
@ -82,7 +82,7 @@ public class IdClassGeneratedValueTest {
session -> {
List<Simple> simpleList = session.createQuery( "select s from Simple s" ).list();
assertEquals( 1, simpleList.size() );
Simple s1 = session.load( Simple.class, new SimplePK( 1L, 2L ) );
Simple s1 = session.getReference( Simple.class, new SimplePK( 1L, 2L ) );
assertEquals( s1.getQuantity(), 10 );
}
);
@ -105,7 +105,7 @@ public class IdClassGeneratedValueTest {
session -> {
List<Simple2> simpleList = session.createQuery( "select s from Simple2 s" ).list();
assertEquals( simpleList.size(), 2 );
Simple2 s1 = session.load( Simple2.class, new SimplePK( s1Id1, 200L ) );
Simple2 s1 = session.getReference( Simple2.class, new SimplePK( s1Id1, 200L ) );
assertEquals( s1.getQuantity(), 10 );
session.clear();
}
@ -132,7 +132,7 @@ public class IdClassGeneratedValueTest {
session -> {
List<Multiple> simpleList = session.createQuery( "select m from Multiple m" ).list();
assertEquals( simpleList.size(), 2 );
Multiple m1 = session.load(
Multiple m1 = session.getReference(
Multiple.class,
new MultiplePK( m1Ids.get( 0 ), m1Ids.get( 1 ), 1000L )
);

View File

@ -167,13 +167,13 @@ public class JoinedSubclassTest {
session.flush();
session.clear();
c1 = session.load( Client.class, c1.getId() );
c1 = session.getReference( Client.class, c1.getId() );
assertEquals( 5000.0, c1.getAccount().getBalance(), 0.01 );
session.flush();
session.clear();
a1 = session.load( Account.class, a1.getId() );
a1 = session.getReference( Account.class, a1.getId() );
Set<Client> clients = a1.getClients();
assertEquals( 1, clients.size() );
Iterator<Client> it = clients.iterator();

View File

@ -50,7 +50,7 @@ public class LoaderTest extends BaseCoreFunctionalTestCase {
s = openSession();
tx = s.beginTransaction();
Team t2 = s.load( Team.class, t.getId() );
Team t2 = s.getReference( Team.class, t.getId() );
Set<Player> players = t2.getPlayers();
Iterator<Player> iterator = players.iterator();
assertEquals( "me", iterator.next().getName() );
@ -75,7 +75,7 @@ public class LoaderTest extends BaseCoreFunctionalTestCase {
try {
long notExistingId = 1l;
s.load( Team.class, notExistingId );
s.getReference( Team.class, notExistingId );
s.get( Team.class, notExistingId );
s.getTransaction().commit();
}

View File

@ -245,7 +245,7 @@ public class ManyToManyTest extends BaseCoreFunctionalTestCase {
s = openSession();
tx = s.beginTransaction();
er = s.load( Employer.class, er.getId() );
er = s.getReference( Employer.class, er.getId() );
assertNotNull( er );
assertNotNull( er.getEmployees() );
assertEquals( 1, er.getEmployees().size() );
@ -384,7 +384,7 @@ public class ManyToManyTest extends BaseCoreFunctionalTestCase {
s = openSession();
tx = s.beginTransaction();
er = s.load( Employer.class, er.getId() );
er = s.getReference( Employer.class, er.getId() );
assertNotNull( er );
assertNotNull( er.getEmployees() );
assertEquals( 2, er.getEmployees().size() );
@ -441,7 +441,7 @@ public class ManyToManyTest extends BaseCoreFunctionalTestCase {
s = openSession();
tx = s.beginTransaction();
f = s.load( Friend.class, f.getId() );
f = s.getReference( Friend.class, f.getId() );
assertNotNull( f );
assertNotNull( f.getFriends() );
assertEquals( 1, f.getFriends().size() );
@ -509,10 +509,10 @@ public class ManyToManyTest extends BaseCoreFunctionalTestCase {
s = openSession();
tx = s.beginTransaction();
m1 = s.load( Man.class, m1pk );
m1 = s.getReference( Man.class, m1pk );
assertFalse( m1.getWomens().isEmpty() );
assertEquals( 1, m1.getWomens().size() );
w1 = s.load( Woman.class, w1pk );
w1 = s.getReference( Woman.class, w1pk );
assertFalse( w1.getMens().isEmpty() );
assertEquals( 2, w1.getMens().size() );

View File

@ -189,7 +189,7 @@ public class ManyToOneTest extends BaseCoreFunctionalTestCase {
s = openSession();
tx = s.beginTransaction();
discount = s.load( Discount.class, discount.getId() );
discount = s.getReference( Discount.class, discount.getId() );
assertNotNull( discount );
assertFalse( Hibernate.isInitialized( discount.getOwner() ) );
tx.commit();

View File

@ -428,7 +428,7 @@ public class OneToManyTest extends BaseNonConfigCoreFunctionalTestCase {
s = openSession();
tx = s.beginTransaction();
c = ( Customer ) s.load( Customer.class, c.getId() );
c = ( Customer ) s.getReference( Customer.class, c.getId() );
assertNotNull( c );
assertTrue( Hibernate.isInitialized( c.getTickets() ) );
assertNotNull( c.getTickets() );
@ -458,7 +458,7 @@ public class OneToManyTest extends BaseNonConfigCoreFunctionalTestCase {
s = openSession();
tx = s.beginTransaction();
c = ( Customer ) s.load( Customer.class, c.getId() );
c = ( Customer ) s.getReference( Customer.class, c.getId() );
assertNotNull( c );
assertFalse( Hibernate.isInitialized( c.getDiscountTickets() ) );
assertNotNull( c.getDiscountTickets() );

View File

@ -652,7 +652,7 @@ public class QueryAndSQLTest {
session.clear();
session.getSessionFactory().getCache().evictEntityData( Chaos.class );
Chaos resultChaos = session.load( Chaos.class, chaos.getId() );
Chaos resultChaos = session.getReference( Chaos.class, chaos.getId() );
assertEquals( upperName, resultChaos.getName() );
assertEquals( "nickname", resultChaos.getNickname() );
}
@ -686,14 +686,14 @@ public class QueryAndSQLTest {
session.clear();
session.getSessionFactory().getCache().evictEntityData( Chaos.class );
Chaos resultChaos = session.load( Chaos.class, chaos.getId() );
Chaos resultChaos = session.getReference( Chaos.class, chaos.getId() );
assertEquals( 2, resultChaos.getParticles().size() );
resultChaos.getParticles().remove( resultChaos.getParticles().iterator().next() );
resultChaos.getParticles().remove( resultChaos.getParticles().iterator().next() );
session.flush();
session.clear();
resultChaos = session.load( Chaos.class, chaos.getId() );
resultChaos = session.getReference( Chaos.class, chaos.getId() );
assertEquals( 0, resultChaos.getParticles().size() );
}
);

View File

@ -149,13 +149,13 @@ public class BatchFetchTest {
session -> {
// load them all as proxies
for ( int i = 0; i < size; i++ ) {
BatchLoadableEntity entity = session.load( BatchLoadableEntity.class, i );
BatchLoadableEntity entity = session.getReference( BatchLoadableEntity.class, i );
assertFalse( Hibernate.isInitialized( entity ) );
}
scope.getSessionFactory().getStatistics().clear();
// now start initializing them...
for ( int i = 0; i < size; i++ ) {
BatchLoadableEntity entity = session.load( BatchLoadableEntity.class, i );
BatchLoadableEntity entity = session.getReference( BatchLoadableEntity.class, i );
Hibernate.initialize( entity );
assertTrue( Hibernate.isInitialized( entity ) );
}

View File

@ -41,7 +41,7 @@ public class InvocationTargetExceptionTest extends BaseCoreFunctionalTestCase {
s = openSession();
s.beginTransaction();
bean = ( Bean ) s.load( Bean.class, bean.getSomeString() );
bean = ( Bean ) s.getReference( Bean.class, bean.getSomeString() );
assertFalse( Hibernate.isInitialized( bean ) );
try {
bean.throwException();

View File

@ -91,7 +91,7 @@ public class LazyCollectionLoadingTest {
@Test
public void testTransaction(SessionFactoryScope scope) {
scope.inTransaction( s -> {
Parent parent = s.load( Parent.class, parentID );
Parent parent = s.getReference( Parent.class, parentID );
assertThat( parent, notNullValue() );
assertThat( parent, not( instanceOf( HibernateProxy.class ) ) );
assertFalse( isPropertyInitialized( parent, "children" ) );
@ -141,7 +141,7 @@ public class LazyCollectionLoadingTest {
@Test
public void testNoTransaction(SessionFactoryScope scope) {
scope.inTransaction( s -> {
parent = s.load( Parent.class, parentID );
parent = s.getReference( Parent.class, parentID );
assertThat( parent, notNullValue() );
assertThat( parent, not( instanceOf( HibernateProxy.class ) ) );
assertFalse( isPropertyInitialized( parent, "children" ) );

View File

@ -64,7 +64,7 @@ public class LazyLoadingAndInheritanceTest {
@Test
public void test(SessionFactoryScope scope) {
scope.inTransaction( s -> {
Containing containing = s.load( Containing.class, containingID );
Containing containing = s.getReference( Containing.class, containingID );
Contained contained = containing.contained;
assertThat( contained ).isNotNull();
assertThat( Hibernate.isPropertyInitialized( contained, "name" ) ).isFalse();

View File

@ -73,7 +73,7 @@ public class LazyLoadingIntegrationTest {
@Test
public void test(SessionFactoryScope scope) {
scope.inTransaction( s -> {
Child loadedChild = s.load( Child.class, lastChildID );
Child loadedChild = s.getReference( Child.class, lastChildID );
checkDirtyTracking( loadedChild );
loadedChild.name = "Barrabas";

View File

@ -86,7 +86,7 @@ public class LazyLoadingTest {
@Test
public void test(SessionFactoryScope scope) {
scope.inTransaction( s -> {
Child loadedChild = s.load( Child.class, lastChildID );
Child loadedChild = s.getReference( Child.class, lastChildID );
assertThat( loadedChild, not( instanceOf( HibernateProxy.class ) ) );
assertThat( loadedChild, instanceOf( PersistentAttributeInterceptable.class ) );
final PersistentAttributeInterceptable interceptable = (PersistentAttributeInterceptable) loadedChild;

View File

@ -90,7 +90,7 @@ public class MultiPathCascadeTest {
scope.inTransaction(
session -> {
A aLoaded = session.load( A.class, new Long( a.getId() ) );
A aLoaded = session.getReference( A.class, new Long( a.getId() ) );
assertInstanceOf( HibernateProxy.class, aLoaded );
assertSame( aLoaded, session.merge( a ) );
}

View File

@ -71,7 +71,7 @@ public class BasicAttributesLazyGroupTest {
@Test
public void testLoad(SessionFactoryScope scope) {
scope.inTransaction( session -> {
final Review review = session.load( Review.class, 1L );
final Review review = session.getReference( Review.class, 1L );
assertFalse( Hibernate.isPropertyInitialized( review, "rating" ) );
assertFalse( Hibernate.isPropertyInitialized( review, "comment" ) );
@ -86,7 +86,7 @@ public class BasicAttributesLazyGroupTest {
@Test
public void testLoad2(SessionFactoryScope scope) {
scope.inTransaction( session -> {
final Review review = session.load( Review.class, 1L );
final Review review = session.getReference( Review.class, 1L );
assertFalse( Hibernate.isPropertyInitialized( review, "rating" ) );
assertFalse( Hibernate.isPropertyInitialized( review, "comment" ) );
@ -101,7 +101,7 @@ public class BasicAttributesLazyGroupTest {
@Test
public void testLoad3(SessionFactoryScope scope) {
scope.inTransaction( session -> {
final Review review = session.load( Review.class, 1L );
final Review review = session.getReference( Review.class, 1L );
assertThat( review.getComment(), is( "My first review" ) );
assertThat( review.getRating(), is( Rating.ONE ) );
@ -111,7 +111,7 @@ public class BasicAttributesLazyGroupTest {
@Test
public void testLoad4(SessionFactoryScope scope) {
scope.inTransaction( session -> {
final Review review = session.load( Review.class, 1L );
final Review review = session.getReference( Review.class, 1L );
assertThat( review.getRating(), is( Rating.ONE ) );
assertThat( review.getComment(), is( "My first review" ) );
} );

View File

@ -134,7 +134,7 @@ public class BatchFetchProxyTest {
List<Employer> employers = new ArrayList<>();
for ( int i = 0 ; i < NUMBER_OF_ENTITIES ; i++ ) {
employers.add( session.load( Employer.class, i + 1) );
employers.add( session.getReference( Employer.class, i + 1) );
}
assertEquals( 0, statistics.getPrepareStatementCount() );
@ -167,7 +167,7 @@ public class BatchFetchProxyTest {
List<Employer> employers = new ArrayList<>();
for ( int i = 0 ; i < NUMBER_OF_ENTITIES ; i++ ) {
employers.add( session.load( Employer.class, i + 1) );
employers.add( session.getReference( Employer.class, i + 1) );
}
assertEquals( 0, statistics.getPrepareStatementCount() );

View File

@ -74,7 +74,7 @@ public class BytecodeEnhancedLazyLoadingOnDeletedEntityTest {
s.persist( owner );
} );
assertThatThrownBy( () -> scope.inTransaction( session -> {
AssociationOwner owner = session.load( AssociationOwner.class, 1 );
AssociationOwner owner = session.getReference( AssociationOwner.class, 1 );
session.remove( owner );
session.flush();
owner.getNonOwners().size();
@ -92,7 +92,7 @@ public class BytecodeEnhancedLazyLoadingOnDeletedEntityTest {
s.persist( nonOwner );
} );
assertThatThrownBy( () -> scope.inTransaction( session -> {
AssociationNonOwner nonOwner = session.load( AssociationNonOwner.class, 1 );
AssociationNonOwner nonOwner = session.getReference( AssociationNonOwner.class, 1 );
session.remove( nonOwner );
session.flush();
nonOwner.getOwners().size();

View File

@ -107,7 +107,7 @@ public class FetchGraphTest {
scope.inSession(
session -> {
final DEntity entityD = session.load( DEntity.class, 1L );
final DEntity entityD = session.getReference( DEntity.class, 1L );
assertThat( stats.getPrepareStatementCount(), is( 0L ) );
assert !Hibernate.isPropertyInitialized( entityD, "a" );
assert !Hibernate.isPropertyInitialized( entityD, "c" );
@ -141,7 +141,7 @@ public class FetchGraphTest {
scope.inSession(
session -> {
final EEntity entityE = session.load( EEntity.class, 17L );
final EEntity entityE = session.getReference( EEntity.class, 17L );
assertThat( stats.getPrepareStatementCount(), is( 0L ) );
assert !Hibernate.isPropertyInitialized( entityE, "d" );
@ -356,7 +356,7 @@ public class FetchGraphTest {
session -> {
final AEntity entityA = session.get( AEntity.class, 1L );
final DEntity entityD = session.load( DEntity.class, 1L );
final DEntity entityD = session.getReference( DEntity.class, 1L );
assert !Hibernate.isInitialized( entityD );
Hibernate.initialize( entityD );
assert Hibernate.isPropertyInitialized( entityD, "a" );
@ -383,7 +383,7 @@ public class FetchGraphTest {
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Load a D
final DEntity entityD = session.load( DEntity.class, 1L );
final DEntity entityD = session.getReference( DEntity.class, 1L );
assertThat( entityD instanceof HibernateProxy, is( false ) );
assertThat( entityD instanceof PersistentAttributeInterceptable, is( true ) );
@ -611,7 +611,7 @@ public class FetchGraphTest {
public void testLoadAndDeleteDEntity(SessionFactoryScope scope) {
scope.inTransaction(
session -> {
DEntity entity = session.load( DEntity.class, 1L );
DEntity entity = session.getReference( DEntity.class, 1L );
session.remove( entity );
session.remove( entity.getE() );
session.remove( entity.getA() );
@ -654,7 +654,7 @@ public class FetchGraphTest {
public void testLoadAndDeleteEEntity(SessionFactoryScope scope) {
scope.inTransaction(
session -> {
EEntity entity = session.load( EEntity.class, 17L );
EEntity entity = session.getReference( EEntity.class, 17L );
session.remove( entity );
session.remove( entity.getD() );
}

View File

@ -80,7 +80,7 @@ public class LazyToOnesProxyWithSubclassesTest {
assertEquals( 1, stats.getPrepareStatementCount() );
Animal animal = session.load( Animal.class, "A Human" );
Animal animal = session.getReference( Animal.class, "A Human" );
assertFalse( Hibernate.isInitialized( animal ) );
assertEquals( 1, stats.getPrepareStatementCount() );
}

View File

@ -72,7 +72,7 @@ public class LoadANonExistingEntityTest {
statistics.clear();
scope.inTransaction( session -> {
Employer nonExisting = session.load( Employer.class, -1 );
Employer nonExisting = session.getReference( Employer.class, -1 );
assertEquals( 0, statistics.getPrepareStatementCount() );
assertFalse( Hibernate.isInitialized( nonExisting ) );
try {
@ -93,7 +93,7 @@ public class LoadANonExistingEntityTest {
final StatisticsImplementor statistics = scope.getSessionFactory().getStatistics();
statistics.clear();
scope.inTransaction( session -> {
Employer nonExisting = session.load( Employer.class, -1 );
Employer nonExisting = session.getReference( Employer.class, -1 );
assertEquals( 0, statistics.getPrepareStatementCount() );
assertFalse( Hibernate.isInitialized( nonExisting ) );
try {
@ -114,7 +114,7 @@ public class LoadANonExistingEntityTest {
final StatisticsImplementor statistics = scope.getSessionFactory().getStatistics();
statistics.clear();
scope.inTransaction( session -> {
Employer nonExisting = session.load( Employer.class, -1 );
Employer nonExisting = session.getReference( Employer.class, -1 );
assertEquals( 0, statistics.getPrepareStatementCount() );
assertFalse( Hibernate.isInitialized( nonExisting ) );
try {

View File

@ -82,7 +82,7 @@ public class LoadANonExistingNotFoundBatchEntityTest {
scope.inTransaction( (session) -> {
List<Employee> employees = new ArrayList<>( NUMBER_OF_ENTITIES );
for ( int i = 0 ; i < NUMBER_OF_ENTITIES ; i++ ) {
employees.add( session.load( Employee.class, i + 1 ) );
employees.add( session.getReference( Employee.class, i + 1 ) );
}
for ( int i = 0 ; i < NUMBER_OF_ENTITIES ; i++ ) {
Hibernate.initialize( employees.get( i ) );

View File

@ -75,7 +75,7 @@ public class LoadANonExistingNotFoundEntityTest {
statistics.clear();
scope.inTransaction( session -> {
Employee employee = session.load( Employee.class, 1 );
Employee employee = session.getReference( Employee.class, 1 );
Hibernate.initialize( employee );
assertNull( employee.employer );
}

View File

@ -83,7 +83,7 @@ public class LoadANonExistingNotFoundLazyBatchEntityTest {
scope.inTransaction( (session) -> {
List<Employee> employees = new ArrayList<>( NUMBER_OF_ENTITIES );
for ( int i = 0 ; i < NUMBER_OF_ENTITIES ; i++ ) {
employees.add( session.load( Employee.class, i + 1 ) );
employees.add( session.getReference( Employee.class, i + 1 ) );
}
for ( int i = 0 ; i < NUMBER_OF_ENTITIES ; i++ ) {
Hibernate.initialize( employees.get( i ) );

View File

@ -95,7 +95,7 @@ public class MergeProxyTest {
public void testMergeDetachInitializedProxy(SessionFactoryScope scope) {
final Activity activityProxy = scope.fromTransaction(
session -> {
final Activity activity = session.load( Activity.class, 0 );
final Activity activity = session.getReference( Activity.class, 0 );
assertFalse( Hibernate.isInitialized( activity) );
Hibernate.initialize( activity );
return activity;
@ -140,7 +140,7 @@ public class MergeProxyTest {
public void testMergeDetachInitializedByAccessProxy(SessionFactoryScope scope) {
final Activity activityProxy = scope.fromTransaction(
session -> {
final Activity activity = session.load( Activity.class, 0 );
final Activity activity = session.getReference( Activity.class, 0 );
assertFalse( Hibernate.isInitialized( activity) );
activity.getDescription();
return activity;

View File

@ -70,7 +70,7 @@ public class ProxyInitializeAndUpdateInlineDirtyTrackingDynamicUpdateTest {
scope.inTransaction(
session -> {
Animal animal = session.load( Animal.class, "animal" );
Animal animal = session.getReference( Animal.class, "animal" );
assertFalse( Hibernate.isInitialized( animal ) );
assertEquals( LoadState.NOT_LOADED , PersistenceUtilHelper.isLoadedWithoutReference( animal, "sex", metadataCache ) );
assertEquals( "female", animal.getSex() );
@ -108,7 +108,7 @@ public class ProxyInitializeAndUpdateInlineDirtyTrackingDynamicUpdateTest {
scope.inTransaction(
session -> {
Animal animal = session.load( Animal.class, "animal" );
Animal animal = session.getReference( Animal.class, "animal" );
assertFalse( Hibernate.isInitialized( animal ) );
assertEquals( LoadState.NOT_LOADED , PersistenceUtilHelper.isLoadedWithoutReference( animal, "sex", metadataCache ) );
animal.setSex( "other" );
@ -156,7 +156,7 @@ public class ProxyInitializeAndUpdateInlineDirtyTrackingDynamicUpdateTest {
scope.inTransaction(
session -> {
final Animal animal = session.load( Animal.class, "animal" );
final Animal animal = session.getReference( Animal.class, "animal" );
assertFalse( Hibernate.isInitialized( animal ) );
assertEquals( LoadState.NOT_LOADED , PersistenceUtilHelper.isLoadedWithoutReference( animal, "age", metadataCache ) );
session.merge( animalInitialized );
@ -236,7 +236,7 @@ public class ProxyInitializeAndUpdateInlineDirtyTrackingDynamicUpdateTest {
);
final Animal animalUninitialized = scope.fromTransaction( session -> {
final Animal animal = session.load( Animal.class, "animal" );
final Animal animal = session.getReference( Animal.class, "animal" );
assertFalse( Hibernate.isInitialized( animal ) );
assertEquals( LoadState.NOT_LOADED , PersistenceUtilHelper.isLoadedWithoutReference( animal, "age", metadataCache ) );
assertFalse( Hibernate.isInitialized( animal ) ); //checking again against side effects of using PersistenceUtilHelper
@ -246,7 +246,7 @@ public class ProxyInitializeAndUpdateInlineDirtyTrackingDynamicUpdateTest {
scope.inTransaction(
session -> {
final Animal animal = session.load( Animal.class, "animal" );
final Animal animal = session.getReference( Animal.class, "animal" );
assertFalse( Hibernate.isInitialized( animal ) );
assertEquals( LoadState.NOT_LOADED , PersistenceUtilHelper.isLoadedWithoutReference( animal, "age", metadataCache ) );
session.merge( animalUninitialized );
@ -279,7 +279,7 @@ public class ProxyInitializeAndUpdateInlineDirtyTrackingDynamicUpdateTest {
);
final Animal animalUninitialized = scope.fromTransaction( session -> {
final Animal animal = session.load( Animal.class, "animal" );
final Animal animal = session.getReference( Animal.class, "animal" );
assertFalse( Hibernate.isInitialized( animal ) );
assertEquals( LoadState.NOT_LOADED , PersistenceUtilHelper.isLoadedWithoutReference( animal, "age", metadataCache ) );
assertFalse( Hibernate.isInitialized( animal ) );

View File

@ -65,7 +65,7 @@ public class ProxyInitializeAndUpdateInlineDirtyTrackingTest {
scope.inTransaction(
session -> {
Animal animal = session.load( Animal.class, "animal" );
Animal animal = session.getReference( Animal.class, "animal" );
assertFalse( Hibernate.isInitialized( animal ) );
assertEquals( "female", animal.getSex() );
assertTrue( Hibernate.isInitialized( animal ) );
@ -100,7 +100,7 @@ public class ProxyInitializeAndUpdateInlineDirtyTrackingTest {
scope.inTransaction(
session -> {
Animal animal = session.load( Animal.class, "animal" );
Animal animal = session.getReference( Animal.class, "animal" );
assertFalse( Hibernate.isInitialized( animal ) );
animal.setSex( "other" );
// Setting the attribute value should have initialized animal.
@ -145,7 +145,7 @@ public class ProxyInitializeAndUpdateInlineDirtyTrackingTest {
scope.inTransaction(
session -> {
final Animal animal = session.load( Animal.class, "animal" );
final Animal animal = session.getReference( Animal.class, "animal" );
assertFalse( Hibernate.isInitialized( animal ) );
session.merge( animalInitialized );
assertTrue( Hibernate.isInitialized( animal ) );
@ -223,7 +223,7 @@ public class ProxyInitializeAndUpdateInlineDirtyTrackingTest {
);
final Animal animalUninitialized = scope.fromTransaction( session -> {
final Animal animal = session.load( Animal.class, "animal" );
final Animal animal = session.getReference( Animal.class, "animal" );
assertFalse( Hibernate.isInitialized( animal ) );
return animal;
}
@ -231,7 +231,7 @@ public class ProxyInitializeAndUpdateInlineDirtyTrackingTest {
scope.inTransaction(
session -> {
final Animal animal = session.load( Animal.class, "animal" );
final Animal animal = session.getReference( Animal.class, "animal" );
assertFalse( Hibernate.isInitialized( animal ) );
session.merge( animalUninitialized );
assertFalse( Hibernate.isInitialized( animal ) );
@ -261,7 +261,7 @@ public class ProxyInitializeAndUpdateInlineDirtyTrackingTest {
);
final Animal animalUninitialized = scope.fromTransaction( session -> {
final Animal animal = session.load( Animal.class, "animal" );
final Animal animal = session.getReference( Animal.class, "animal" );
assertFalse( Hibernate.isInitialized( animal ) );
return animal;
}

View File

@ -66,7 +66,7 @@ public class ProxyInitializeAndUpdateTest {
scope.inTransaction(
session -> {
Animal animal = session.load( Animal.class, "animal" );
Animal animal = session.getReference( Animal.class, "animal" );
assertFalse( Hibernate.isInitialized( animal ) );
assertEquals( "female", animal.getSex() );
assertTrue( Hibernate.isInitialized( animal ) );
@ -101,7 +101,7 @@ public class ProxyInitializeAndUpdateTest {
scope.inTransaction(
session -> {
Animal animal = session.load( Animal.class, "animal" );
Animal animal = session.getReference( Animal.class, "animal" );
assertFalse( Hibernate.isInitialized( animal ) );
animal.setSex( "other" );
// Setting the attribute value should have initialized animal.
@ -146,7 +146,7 @@ public class ProxyInitializeAndUpdateTest {
scope.inTransaction(
session -> {
final Animal animal = session.load( Animal.class, "animal" );
final Animal animal = session.getReference( Animal.class, "animal" );
assertFalse( Hibernate.isInitialized( animal ) );
final Animal animalMerged = (Animal) session.merge( animalInitialized );
assertSame( animal, animalMerged );
@ -226,7 +226,7 @@ public class ProxyInitializeAndUpdateTest {
);
final Animal animalUninitialized = scope.fromTransaction( session -> {
final Animal animal = session.load( Animal.class, "animal" );
final Animal animal = session.getReference( Animal.class, "animal" );
assertFalse( Hibernate.isInitialized( animal ) );
return animal;
}
@ -234,7 +234,7 @@ public class ProxyInitializeAndUpdateTest {
scope.inTransaction(
session -> {
final Animal animal = session.load( Animal.class, "animal" );
final Animal animal = session.getReference( Animal.class, "animal" );
assertFalse( Hibernate.isInitialized( animal ) );
final Animal animalMerged = (Animal) session.merge( animalUninitialized );
assertSame( animal, animalMerged );
@ -265,7 +265,7 @@ public class ProxyInitializeAndUpdateTest {
);
final Animal animalUninitialized = scope.fromTransaction( session -> {
final Animal animal = session.load( Animal.class, "animal" );
final Animal animal = session.getReference( Animal.class, "animal" );
assertFalse( Hibernate.isInitialized( animal ) );
return animal;
}
@ -273,7 +273,7 @@ public class ProxyInitializeAndUpdateTest {
scope.inTransaction(
session -> {
final Animal animal = session.load( Animal.class, "animal" );
final Animal animal = session.getReference( Animal.class, "animal" );
assertFalse( Hibernate.isInitialized( animal ) );
animal.setSex( "other" );
assertTrue( Hibernate.isInitialized( animal ) );

View File

@ -85,7 +85,7 @@ public class SetIdentifierOnAEnhancedProxyTest {
scope.inTransaction(
session -> {
stats.clear();
Child loadedChild = session.load( Child.class, lastChildID );
Child loadedChild = session.getReference( Child.class, lastChildID );
final PersistentAttributeInterceptable interceptable = (PersistentAttributeInterceptable) loadedChild;
final PersistentAttributeInterceptor interceptor = interceptable.$$_hibernate_getInterceptor();
@ -102,7 +102,7 @@ public class SetIdentifierOnAEnhancedProxyTest {
scope.inTransaction(
session -> {
Child loadedChild = session.load( Child.class, lastChildID );
Child loadedChild = session.getReference( Child.class, lastChildID );
assertThat( loadedChild ).isNotNull();
}
);
@ -120,7 +120,7 @@ public class SetIdentifierOnAEnhancedProxyTest {
ModelId id = new ModelId();
id.setId1( 1L );
id.setId2( 2L );
Parent parent = session.load( Parent.class, id );
Parent parent = session.getReference( Parent.class, id );
final PersistentAttributeInterceptable interceptable = (PersistentAttributeInterceptable) parent;
final PersistentAttributeInterceptor interceptor = interceptable.$$_hibernate_getInterceptor();
@ -142,7 +142,7 @@ public class SetIdentifierOnAEnhancedProxyTest {
scope.inTransaction(
session -> {
Child loadedChild = session.load( Child.class, lastChildID );
Child loadedChild = session.getReference( Child.class, lastChildID );
assertThat( loadedChild ).isNotNull();
}
);
@ -160,7 +160,7 @@ public class SetIdentifierOnAEnhancedProxyTest {
ModelId id = new ModelId();
id.setId1( 1L );
id.setId2( 2L );
Parent parent = session.load( Parent.class, id );
Parent parent = session.getReference( Parent.class, id );
final PersistentAttributeInterceptable interceptable = (PersistentAttributeInterceptable) parent;
final PersistentAttributeInterceptor interceptor = interceptable.$$_hibernate_getInterceptor();
@ -189,7 +189,7 @@ public class SetIdentifierOnAEnhancedProxyTest {
() -> scope.inTransaction(
session -> {
stats.clear();
Child loadedChild = session.load( Child.class, lastChildID );
Child loadedChild = session.getReference( Child.class, lastChildID );
final PersistentAttributeInterceptable interceptable = (PersistentAttributeInterceptable) loadedChild;
final PersistentAttributeInterceptor interceptor = interceptable.$$_hibernate_getInterceptor();

View File

@ -120,7 +120,7 @@ public class SimpleUpdateTestWithLazyLoading {
scope.inTransaction(
session -> {
stats.clear();
Child loadedChild = session.load( Child.class, lastChildID );
Child loadedChild = session.getReference( Child.class, lastChildID );
final PersistentAttributeInterceptable interceptable = (PersistentAttributeInterceptable) loadedChild;
final PersistentAttributeInterceptor interceptor = interceptable.$$_hibernate_getInterceptor();
@ -152,7 +152,7 @@ public class SimpleUpdateTestWithLazyLoading {
scope.inTransaction(
session -> {
Child loadedChild = session.load( Child.class, lastChildID );
Child loadedChild = session.getReference( Child.class, lastChildID );
assertThat( loadedChild.getName(), is( updatedName ) );
assertFalse( Hibernate.isInitialized( loadedChild.getRelatives() ) );
@ -168,7 +168,7 @@ public class SimpleUpdateTestWithLazyLoading {
scope.inTransaction( s -> {
final Statistics stats = scope.getSessionFactory().getStatistics();
stats.clear();
Child loadedChild = s.load( Child.class, lastChildID );
Child loadedChild = s.getReference( Child.class, lastChildID );
loadedChild.setName( updatedName );
@ -184,7 +184,7 @@ public class SimpleUpdateTestWithLazyLoading {
} );
scope.inTransaction( s -> {
Child loadedChild = s.load( Child.class, lastChildID );
Child loadedChild = s.getReference( Child.class, lastChildID );
assertThat( Hibernate.isInitialized( loadedChild ), is( false ) );
assertThat( loadedChild.getName(), is( updatedName ) );
assertThat( Hibernate.isInitialized( loadedChild ), is( true ) );
@ -199,7 +199,7 @@ public class SimpleUpdateTestWithLazyLoading {
scope.inTransaction( s -> {
final Statistics stats = scope.getSessionFactory().getStatistics();
stats.clear();
Child loadedChild = s.load( Child.class, lastChildID );
Child loadedChild = s.getReference( Child.class, lastChildID );
assertEquals( 0, stats.getPrepareStatementCount() );
@ -213,7 +213,7 @@ public class SimpleUpdateTestWithLazyLoading {
} );
scope.inTransaction( s -> {
Child loadedChild = s.load( Child.class, lastChildID );
Child loadedChild = s.getReference( Child.class, lastChildID );
assertThat( loadedChild.getRelatives().size(), is( 2 ) );
} );
}

View File

@ -108,7 +108,7 @@ public class SimpleUpdateTestWithLazyLoadingAndInlineDirtyTracking {
String updatedName = "Barrabas_";
scope.inTransaction( s -> {
stats.clear();
Child loadedChild = s.load( Child.class, lastChildID );
Child loadedChild = s.getReference( Child.class, lastChildID );
final PersistentAttributeInterceptable interceptable = (PersistentAttributeInterceptable) loadedChild;
final PersistentAttributeInterceptor interceptor = interceptable.$$_hibernate_getInterceptor();
@ -124,7 +124,7 @@ public class SimpleUpdateTestWithLazyLoadingAndInlineDirtyTracking {
assertEquals( 2, stats.getPrepareStatementCount() );
scope.inTransaction( s -> {
Child loadedChild = s.load( Child.class, lastChildID );
Child loadedChild = s.getReference( Child.class, lastChildID );
assertThat( loadedChild.getName(), is( updatedName ) );
} );
}
@ -136,7 +136,7 @@ public class SimpleUpdateTestWithLazyLoadingAndInlineDirtyTracking {
scope.inTransaction( s -> {
final Statistics stats = scope.getSessionFactory().getStatistics();
stats.clear();
Child loadedChild = s.load( Child.class, lastChildID );
Child loadedChild = s.getReference( Child.class, lastChildID );
loadedChild.setName( updatedName );
@ -152,7 +152,7 @@ public class SimpleUpdateTestWithLazyLoadingAndInlineDirtyTracking {
} );
scope.inTransaction( s -> {
Child loadedChild = s.load( Child.class, lastChildID );
Child loadedChild = s.getReference( Child.class, lastChildID );
assertThat( loadedChild.getName(), is( updatedName ) );
assertThat( loadedChild.getParent().getName(), is( parentName ) );
} );
@ -163,7 +163,7 @@ public class SimpleUpdateTestWithLazyLoadingAndInlineDirtyTracking {
scope.inTransaction( s -> {
final Statistics stats = scope.getSessionFactory().getStatistics();
stats.clear();
Child loadedChild = s.load( Child.class, lastChildID );
Child loadedChild = s.getReference( Child.class, lastChildID );
assertEquals( 0, stats.getPrepareStatementCount() );
Person relative = new Person();
@ -177,7 +177,7 @@ public class SimpleUpdateTestWithLazyLoadingAndInlineDirtyTracking {
} );
scope.inTransaction( s -> {
Child loadedChild = s.load( Child.class, lastChildID );
Child loadedChild = s.getReference( Child.class, lastChildID );
assertThat( loadedChild.getRelatives().size(), is( 2 ) );
} );
}

View File

@ -128,7 +128,7 @@ public class SimpleUpdateWithLazyLoadingWithCollectionInDefaultFetchGroupFalseTe
scope.inTransaction(
session -> {
stats.clear();
Child loadedChild = session.load( Child.class, lastChildID );
Child loadedChild = session.getReference( Child.class, lastChildID );
final PersistentAttributeInterceptable interceptable = (PersistentAttributeInterceptable) loadedChild;
final PersistentAttributeInterceptor interceptor = interceptable.$$_hibernate_getInterceptor();
@ -167,7 +167,7 @@ public class SimpleUpdateWithLazyLoadingWithCollectionInDefaultFetchGroupFalseTe
scope.inTransaction(
session -> {
Child loadedChild = session.load( Child.class, lastChildID );
Child loadedChild = session.getReference( Child.class, lastChildID );
assertThat( loadedChild.getName(), is( updatedName ) );
final EntityEntry entry = session.getPersistenceContext().getEntry( loadedChild );
@ -187,7 +187,7 @@ public class SimpleUpdateWithLazyLoadingWithCollectionInDefaultFetchGroupFalseTe
scope.inTransaction( s -> {
final Statistics stats = scope.getSessionFactory().getStatistics();
stats.clear();
Child loadedChild = s.load( Child.class, lastChildID );
Child loadedChild = s.getReference( Child.class, lastChildID );
loadedChild.setName( updatedName );
@ -203,7 +203,7 @@ public class SimpleUpdateWithLazyLoadingWithCollectionInDefaultFetchGroupFalseTe
} );
scope.inTransaction( s -> {
Child loadedChild = s.load( Child.class, lastChildID );
Child loadedChild = s.getReference( Child.class, lastChildID );
assertThat( Hibernate.isInitialized( loadedChild ), is( false ) );
assertThat( loadedChild.getName(), is( updatedName ) );
assertThat( Hibernate.isInitialized( loadedChild ), is( true ) );
@ -218,7 +218,7 @@ public class SimpleUpdateWithLazyLoadingWithCollectionInDefaultFetchGroupFalseTe
scope.inTransaction( s -> {
final Statistics stats = scope.getSessionFactory().getStatistics();
stats.clear();
Child loadedChild = s.load( Child.class, lastChildID );
Child loadedChild = s.getReference( Child.class, lastChildID );
assertEquals( 0, stats.getPrepareStatementCount() );
@ -232,7 +232,7 @@ public class SimpleUpdateWithLazyLoadingWithCollectionInDefaultFetchGroupFalseTe
} );
scope.inTransaction( s -> {
Child loadedChild = s.load( Child.class, lastChildID );
Child loadedChild = s.getReference( Child.class, lastChildID );
assertThat( loadedChild.getRelatives().size(), is( 2 ) );
} );
}

View File

@ -100,7 +100,7 @@ public class EntityWithMutableAttributesTest {
public void testLoad(SessionFactoryScope scope) {
scope.inTransaction(
session -> {
User user = session.load( User.class, 1 );
User user = session.getReference( User.class, 1 );
assertThat(
user, instanceOf( PersistentAttributeInterceptable.class )
);
@ -117,7 +117,7 @@ public class EntityWithMutableAttributesTest {
public void testMutableAttributeIsUpdated(SessionFactoryScope scope) {
scope.inTransaction(
session -> {
User user = session.load( User.class, 1 );
User user = session.getReference( User.class, 1 );
user.getDate().setTime( 0 );
}
);

View File

@ -83,7 +83,7 @@ public class OnDemandLoadTest {
scope.inTransaction( s -> {
// first load the store, making sure it is not initialized
store[0] = s.load( Store.class, 1L );
store[0] = s.getReference( Store.class, 1L );
assertNotNull( store[0] );
assertFalse( isPropertyInitialized( store[0], "inventories" ) );

View File

@ -93,7 +93,7 @@ public class OnDemandLoadWithCollectionInDefaultFetchGroupFalseTest {
scope.inTransaction( s -> {
// first load the store, making sure it is not initialized
store[0] = s.load( Store.class, 1L );
store[0] = s.getReference( Store.class, 1L );
assertNotNull( store[0] );
assertFalse( isPropertyInitialized( store[0], "inventories" ) );

View File

@ -72,7 +72,7 @@ public class ByteCodeEnhancedImmutableReferenceCacheTest extends BaseCoreFunctio
s = openSession();
s.beginTransaction();
// MyEnhancedReferenceData loaded = (MyEnhancedReferenceData) s.get( MyEnhancedReferenceData.class, 1 );
MyEnhancedReferenceData loaded = (MyEnhancedReferenceData) s.load( MyEnhancedReferenceData.class, 1 );
MyEnhancedReferenceData loaded = s.getReference( MyEnhancedReferenceData.class, 1 );
s.getTransaction().commit();
s.close();

View File

@ -67,7 +67,7 @@ public class CacheAnnotationTests extends BaseCoreFunctionalTestCase {
} );
doInHibernate( this::sessionFactory, session -> {
NoCacheConcurrencyStrategyEntity entity = session.load( NoCacheConcurrencyStrategyEntity.class, this.entityId );
NoCacheConcurrencyStrategyEntity entity = session.getReference( NoCacheConcurrencyStrategyEntity.class, this.entityId );
assertEquals( "name", entity.getName() );
} );
}

View File

@ -60,7 +60,7 @@ public class ReferenceCacheTest extends BaseCoreFunctionalTestCase {
s = openSession();
s.beginTransaction();
// MyReferenceData loaded = (MyReferenceData) s.get( MyReferenceData.class, 1 );
MyReferenceData loaded = (MyReferenceData) s.load( MyReferenceData.class, 1 );
MyReferenceData loaded = (MyReferenceData) s.getReference( MyReferenceData.class, 1 );
s.getTransaction().commit();
s.close();

View File

@ -81,7 +81,7 @@ public class MultiPathCascadeTest {
scope.inTransaction(
session -> {
A aLoaded = session.load( A.class, new Long( a.getId() ) );
A aLoaded = session.getReference( A.class, new Long( a.getId() ) );
assertTrue( aLoaded instanceof HibernateProxy );
assertSame( aLoaded, session.merge( a ) );
}

View File

@ -52,7 +52,7 @@ public class TempTest {
@AfterEach
public void dropTestData(SessionFactoryScope scope) {
scope.inTransaction( (session) -> {
session.remove( session.load( Client.class, 1 ) );
session.remove( session.getReference( Client.class, 1 ) );
} );
}

View File

@ -113,8 +113,8 @@ public class EmbeddedCompositeIdTest {
session -> {
Course ucid = new Course( "mat2000", "Monash", null );
Course cid = new Course( "eng5000", "BHS", null );
Course luc = session.load( Course.class, ucid );
Course lc = session.load( Course.class, cid );
Course luc = session.getReference( Course.class, ucid );
Course lc = session.getReference( Course.class, cid );
assertFalse( Hibernate.isInitialized( luc ) );
assertFalse( Hibernate.isInitialized( lc ) );
assertEquals( UniversityCourse.class, Hibernate.getClass( luc ) );

View File

@ -51,8 +51,8 @@ public class MappedByEmbeddableTest extends BaseCoreFunctionalTestCase {
} );
inTransaction( session -> {
Containing containing1 = session.load( Containing.class, 1 );
Containing containing2 = session.load( Containing.class, 2 );
Containing containing1 = session.getReference( Containing.class, 1 );
Containing containing2 = session.getReference( Containing.class, 2 );
Embed embed1 = containing1.getEmbed();
Embed embed2 = containing2.getEmbed();
@ -117,7 +117,7 @@ public class MappedByEmbeddableTest extends BaseCoreFunctionalTestCase {
}
private void loadContaining(Session session, Integer containingId, Integer containedId) {
Contained contained = session.load( Contained.class, containedId );
Contained contained = session.getReference( Contained.class, containedId );
Containing containing = contained.getContaining();
assertThat( containing.getId() ).isEqualTo( containingId );

View File

@ -114,7 +114,7 @@ public class DynamicFilterTest extends BaseNonConfigCoreFunctionalTestCase {
CollectionCacheEntry cachedData = fromSession(
session -> {
// Force a collection into the second level cache, with its non-filtered elements
Salesperson sp = session.load( Salesperson.class, testData.steveId );
Salesperson sp = session.getReference( Salesperson.class, testData.steveId );
Hibernate.initialize( sp.getOrders() );
assertTrue( "No cache for collection", persister.hasCache() );
Object cacheKey = cache.generateCacheKey(
@ -156,7 +156,7 @@ public class DynamicFilterTest extends BaseNonConfigCoreFunctionalTestCase {
inSession(
session -> {
session.enableFilter( "fulfilledOrders" ).setParameter( "asOfDate", testData.lastMonth.getTime() );
Salesperson sp = session.load( Salesperson.class, testData.steveId );
Salesperson sp = session.getReference( Salesperson.class, testData.steveId );
assertEquals( "Filtered-collection not bypassing 2L-cache", 1, sp.getOrders().size() );
}
);
@ -164,7 +164,7 @@ public class DynamicFilterTest extends BaseNonConfigCoreFunctionalTestCase {
// Finally, make sure that the original cached version did not get over-written
inSession(
session -> {
Salesperson sp = session.load( Salesperson.class, testData.steveId );
Salesperson sp = session.getReference( Salesperson.class, testData.steveId );
assertEquals( "Actual cached version got over-written", 2, sp.getOrders().size() );
}
);
@ -767,7 +767,7 @@ public class DynamicFilterTest extends BaseNonConfigCoreFunctionalTestCase {
.setParameter( "asOfDate", testData.lastMonth.getTime() );
log.info( "Performing load of Department..." );
Department department = session.load( Department.class, testData.deptId );
Department department = session.getReference( Department.class, testData.deptId );
Set salespersons = department.getSalespersons();
assertEquals( "Incorrect salesperson count", 1, salespersons.size() );

View File

@ -58,9 +58,9 @@ public class TestClearBatchFetchQueueAfterFlush extends BaseCoreFunctionalTestCa
s.getTransaction().commit();
s.clear();
bookStore1 = s.load( BookStore.class, bookStore1.getId() );
bookStore2 = s.load( BookStore.class, bookStore2.getId() );
bookStore3 = s.load( BookStore.class, bookStore3.getId() );
bookStore1 = s.getReference( BookStore.class, bookStore1.getId() );
bookStore2 = s.getReference( BookStore.class, bookStore2.getId() );
bookStore3 = s.getReference( BookStore.class, bookStore3.getId() );
s.beginTransaction();
s.remove( bookStore2 );

View File

@ -1656,7 +1656,7 @@ public class ASTParserLoadingTest extends BaseCoreFunctionalTestCase {
s.createQuery( "from PropertySet p join p.generalProperties gp where gp.id is not null" ).list();
s.remove( s.load( PropertySet.class, id ) );
s.remove( s.getReference( PropertySet.class, id ) );
s.getTransaction().commit();
s.close();
@ -2127,7 +2127,7 @@ public class ASTParserLoadingTest extends BaseCoreFunctionalTestCase {
s.persist( plat );
s.flush();
s.clear();
plat = (Mammal) s.load(Mammal.class, plat.getId() );
plat = (Mammal) s.getReference(Mammal.class, plat.getId() );
assertFalse( Hibernate.isInitialized(plat) );
Object plat2 = s.createQuery("from Animal a").uniqueResult();
assertSame( plat, plat2 );
@ -2941,7 +2941,7 @@ public class ASTParserLoadingTest extends BaseCoreFunctionalTestCase {
Transaction txn = session.beginTransaction();
for ( Long createdAnimalId : createdAnimalIds ) {
Animal animal = session.load( Animal.class, createdAnimalId );
Animal animal = session.getReference( Animal.class, createdAnimalId );
session.remove( animal );
}

View File

@ -859,7 +859,7 @@ public class BulkManipulationTest extends BaseCoreFunctionalTestCase {
t.commit();
t = s.beginTransaction();
entity = (IntegerVersioned) s.load( IntegerVersioned.class, entity.getId() );
entity = (IntegerVersioned) s.getReference( IntegerVersioned.class, entity.getId() );
assertEquals( "version not incremented", initialVersion + 1, entity.getVersion() );
s.remove( entity );
@ -894,7 +894,7 @@ public class BulkManipulationTest extends BaseCoreFunctionalTestCase {
t.commit();
t = s.beginTransaction();
entity = (TimestampVersioned) s.load( TimestampVersioned.class, entity.getId() );
entity = (TimestampVersioned) s.getReference( TimestampVersioned.class, entity.getId() );
assertTrue( "version not incremented", entity.getVersion().after( initialVersion ) );
s.remove( entity );
@ -1035,7 +1035,7 @@ public class BulkManipulationTest extends BaseCoreFunctionalTestCase {
.executeUpdate();
assertEquals( "Incorrect entity-updated count", 1, count );
Animal tadpole = (Animal) s.load( Animal.class, data.polliwog.getId() );
Animal tadpole = (Animal) s.getReference( Animal.class, data.polliwog.getId() );
assertEquals( "Update did not take effect", "Tadpole", tadpole.getDescription() );
count = s.createQuery( "update Animal set bodyWeight = bodyWeight + :w1 + :w2" )

View File

@ -115,7 +115,7 @@ public class WithClauseTest {
scope.inTransaction(
(session) -> {
List list = session.createQuery( "from Human h inner join h.offspring o with o.mother.father = :cousin" )
.setParameter( "cousin", session.load( Human.class, Long.valueOf( "123" ) ) )
.setParameter( "cousin", session.getReference( Human.class, Long.valueOf( "123" ) ) )
.list();
assertTrue( list.isEmpty(), "ad-hoc did take effect" );
}

View File

@ -56,16 +56,16 @@ public class IdBagTest {
criteria.from( User.class );
User gavin = s.createQuery( criteria ).uniqueResult();
// User gavin = (User) s.createCriteria( User.class ).uniqueResult();
Group admins = s.load( Group.class, "admins" );
Group plebs = s.load( Group.class, "plebs" );
Group banned = s.load( Group.class, "banned" );
Group admins = s.getReference( Group.class, "admins" );
Group plebs = s.getReference( Group.class, "plebs" );
Group banned = s.getReference( Group.class, "banned" );
gavin.getGroups().add( admins );
gavin.getGroups().remove( plebs );
//gavin.getGroups().add(banned);
s.remove( plebs );
s.remove( banned );
s.remove( s.load( Group.class, "moderators" ) );
s.remove( s.getReference( Group.class, "moderators" ) );
s.remove( admins );
s.remove( gavin );
}

View File

@ -99,7 +99,7 @@ public class ImmutableTest extends BaseSessionFactoryFunctionalTest {
s -> {
s.beginTransaction();
try {
Contract c = s.load( Contract.class, contract.getId() );
Contract c = s.getReference( Contract.class, contract.getId() );
// Contract c = (Contract) s.createCriteria(Contract.class).uniqueResult();
assertTrue( s.isReadOnly( c ) );
assertEquals( "gavin", c.getCustomerName() );
@ -161,7 +161,7 @@ public class ImmutableTest extends BaseSessionFactoryFunctionalTest {
inSession(
s -> {
Contract c = s.load( Contract.class, contract.getId() );
Contract c = s.getReference( Contract.class, contract.getId() );
assertTrue( s.isReadOnly( c ) );
assertEquals( "gavin", c.getCustomerName() );
assertEquals( 2, c.getVariations().size() );

View File

@ -63,7 +63,7 @@ public class InsertOrderingWithCascadeOnPersist {
// This block resulted in a Foreign Key ConstraintViolation because the inserts were ordered incorrectly.
scope.inTransaction( session -> {
// Add marketResult to existing Bid
final MarketBid bid = session.load( MarketBid.class, bidId );
final MarketBid bid = session.getReference( MarketBid.class, bidId );
final MarketResult result = new MarketResult();
result.setMarketBid( bid );
session.persist( result );

View File

@ -279,7 +279,7 @@ public class InterceptorTest extends BaseCoreFunctionalTestCase {
merged.setInjectedString( null );
User loaded = s.load( User.class, merged.getName() );
User loaded = s.getReference( User.class, merged.getName() );
// the session-bound instance was not instantiated by the interceptor, load simply returns it
assertSame( merged, loaded );
assertNull( merged.getInjectedString() );
@ -288,7 +288,7 @@ public class InterceptorTest extends BaseCoreFunctionalTestCase {
s.flush();
s.evict( merged );
User reloaded = s.load( User.class, merged.getName() );
User reloaded = s.getReference( User.class, merged.getName() );
// Interceptor IS called for instantiating the persistent instance associated to the session when using load
assertEquals( injectedString, reloaded.getInjectedString() );
assertEquals( u.getName(), reloaded.getName() );

View File

@ -69,24 +69,24 @@ public class InterfaceProxyTest {
try (Session session = openSession( scope )) {
session.beginTransaction();
try {
Document d = (Document) session.load( ItemImpl.class, did );
Document d = (Document) session.getReference( ItemImpl.class, did );
assertEquals( did, d.getId() );
assertEquals( "Hibernate in Action", d.getName() );
assertNotNull( d.getContent() );
SecureDocument d2 = (SecureDocument) session.load( ItemImpl.class, d2id );
SecureDocument d2 = (SecureDocument) session.getReference( ItemImpl.class, d2id );
assertEquals( d2id, d2.getId() );
assertEquals( "Secret", d2.getName() );
assertNotNull( d2.getContent() );
session.clear();
d = session.load( DocumentImpl.class, did );
d = session.getReference( DocumentImpl.class, did );
assertEquals( did, d.getId() );
assertEquals( "Hibernate in Action", d.getName() );
assertNotNull( d.getContent() );
d2 = session.load( SecureDocumentImpl.class, d2id );
d2 = session.getReference( SecureDocumentImpl.class, d2id );
assertEquals( d2id, d2.getId() );
assertEquals( "Secret", d2.getName() );
assertNotNull( d2.getContent() );
@ -94,7 +94,7 @@ public class InterfaceProxyTest {
//s.clear();
d2 = session.load( SecureDocumentImpl.class, did );
d2 = session.getReference( SecureDocumentImpl.class, did );
assertEquals( did, d2.getId() );
assertEquals( "Hibernate in Action", d2.getName() );
assertNotNull( d2.getContent() );

View File

@ -50,7 +50,7 @@ public class GetLoadJpaComplianceTest {
assertNull( s.get( Workload.class, 999 ) );
Workload proxy = s.load( Workload.class, 999 );
Workload proxy = s.getReference( Workload.class, 999 );
assertFalse( Hibernate.isInitialized( proxy ) );
proxy.getId();
@ -103,7 +103,7 @@ public class GetLoadJpaComplianceTest {
assertNull( s.get( Employee.class, 999 ) );
Employee proxy = s.load( Employee.class, 999 );
Employee proxy = s.getReference( Employee.class, 999 );
assertFalse( Hibernate.isInitialized( proxy ) );
proxy.getId();

View File

@ -126,10 +126,10 @@ public class GetLoadTest {
scope.inTransaction(
entityManager -> {
Session s = ( Session ) entityManager.getDelegate();
Employer emp = s.load( Employer.class, empId );
Employer emp = s.getReference( Employer.class, empId );
emp.getId();
assertFalse( Hibernate.isInitialized( emp ) );
Node node = s.load( Node.class, nodeName );
Node node = s.getReference( Node.class, nodeName );
assertEquals( node.getName(), nodeName );
assertFalse( Hibernate.isInitialized( node ) );
}
@ -138,10 +138,10 @@ public class GetLoadTest {
scope.inTransaction(
entityManager -> {
Session s = ( Session ) entityManager.getDelegate();
Employer emp = ( Employer ) s.load( Employer.class.getName(), empId );
Employer emp = ( Employer ) s.getReference( Employer.class.getName(), empId );
emp.getId();
assertFalse( Hibernate.isInitialized( emp ) );
Node node = ( Node ) s.load( Node.class.getName(), nodeName );
Node node = ( Node ) s.getReference( Node.class.getName(), nodeName );
assertEquals( node.getName(), nodeName );
assertFalse( Hibernate.isInitialized( node ) );
}
@ -195,7 +195,7 @@ public class GetLoadTest {
entityManager -> {
Session s = ( Session ) entityManager.getDelegate();
Workload proxy = s.load(Workload.class, workload.id);
Workload proxy = s.getReference(Workload.class, workload.id);
proxy.getId();
assertFalse( Hibernate.isInitialized( proxy ) );
@ -218,7 +218,7 @@ public class GetLoadTest {
assertNull( s.get( Workload.class, 999 ) );
Workload proxy = s.load( Workload.class, 999 );
Workload proxy = s.getReference( Workload.class, 999 );
assertFalse( Hibernate.isInitialized( proxy ) );
proxy.getId();
@ -263,7 +263,7 @@ public class GetLoadTest {
assertNull( s.get( Employee.class, 999 ) );
Employee proxy = s.load( Employee.class, 999 );
Employee proxy = s.getReference( Employee.class, 999 );
assertFalse( Hibernate.isInitialized( proxy ) );
proxy.getId();

View File

@ -32,7 +32,7 @@ public class JPAProxyTest extends AbstractJPATest {
public void testEjb3ProxyUsage() {
inTransaction(
s -> {
Item item = s.load( Item.class, new Long( -1 ) );
Item item = s.getReference( Item.class, new Long( -1 ) );
assertFalse( Hibernate.isInitialized( item ) );
try {
Hibernate.initialize( item );
@ -47,7 +47,7 @@ public class JPAProxyTest extends AbstractJPATest {
s.clear();
Item item2 = s.load( Item.class, new Long( -1 ) );
Item item2 = s.getReference( Item.class, new Long( -1 ) );
assertFalse( Hibernate.isInitialized( item2 ) );
assertFalse( item == item2 );
try {
@ -80,7 +80,7 @@ public class JPAProxyTest extends AbstractJPATest {
inTransaction(
s -> {
// first load() it to generate a proxy...
Item item = s.load( Item.class, nonExistentId );
Item item = s.getReference( Item.class, nonExistentId );
assertFalse( Hibernate.isInitialized( item ) );
// then try to get() it to make sure we get an exception
try {

View File

@ -66,7 +66,7 @@ public class JpaSpecVersionValueUpdatingTest extends BaseCoreFunctionalTestCase
session = openSession();
session.beginTransaction();
customer = session.load( Customer.class, 1L );
customer = session.getReference( Customer.class, 1L );
assertEquals( initial, customer.version );
session.remove( customer );
session.getTransaction().commit();
@ -113,7 +113,7 @@ public class JpaSpecVersionValueUpdatingTest extends BaseCoreFunctionalTestCase
session = openSession();
session.beginTransaction();
customer = session.load( Customer.class, 1L );
customer = session.getReference( Customer.class, 1L );
assertEquals( initial, customer.version );
session.remove( customer );
session.getTransaction().commit();

View File

@ -65,7 +65,7 @@ public class LazyPersistWithDetachedAssociationTest {
Address loadedAddress = scope.fromTransaction(
session -> {
// first load the address
Address _loadedAddress = session.load(
Address _loadedAddress = session.getReference(
Address.class,
1L
);

View File

@ -79,7 +79,7 @@ public class AtomikosJtaLazyLoadingTest {
public void testLazyCollectionLoadingAfterEndTransaction(SessionFactoryScope scope) {
Parent loadedParent = scope.fromTransaction(
session ->
session.load( Parent.class, parentID )
session.getReference( Parent.class, parentID )
);
assertFalse( Hibernate.isInitialized( loadedParent.getChildren() ) );
@ -94,7 +94,7 @@ public class AtomikosJtaLazyLoadingTest {
Child loadedChild = scope.fromTransaction(
session ->
session.load( Child.class, lastChildID )
session.getReference( Child.class, lastChildID )
);
Parent p = loadedChild.getParent();

View File

@ -79,7 +79,7 @@ public class JtaLazyLoadingTest {
public void testLazyCollectionLoadingAfterEndTransaction(SessionFactoryScope scope) {
Parent loadedParent = scope.fromTransaction(
session ->
session.load( Parent.class, parentID )
session.getReference( Parent.class, parentID )
);
@ -95,7 +95,7 @@ public class JtaLazyLoadingTest {
Child loadedChild = scope.fromTransaction(
session ->
session.load( Child.class, lastChildID )
session.getReference( Child.class, lastChildID )
);
Parent p = loadedChild.getParent();

View File

@ -71,7 +71,7 @@ public class LazyLoadingLoggingTest {
public void testNoSession(SessionFactoryScope scope) {
Address address = scope.fromTransaction(
session ->
session.load( Address.class, 1L )
session.getReference( Address.class, 1L )
);
try {
@ -93,7 +93,7 @@ public class LazyLoadingLoggingTest {
public void testDisconnect(SessionFactoryScope scope) {
scope.inTransaction(
session -> {
Address address = session.load( Address.class, 1L );
Address address = session.getReference( Address.class, 1L );
AbstractSharedSessionContract sessionContract = (AbstractSharedSessionContract) session;
sessionContract.getJdbcCoordinator().close();

View File

@ -38,7 +38,7 @@ public class LazyLoadingNotFoundTest {
@TestForIssue(jiraKey = "HHH-11179")
public void testNonExistentLazyInitOutsideTransaction(SessionFactoryScope scope) {
Child loadedChild = scope.fromTransaction(
session -> session.load( Child.class, -1L )
session -> session.getReference( Child.class, -1L )
);
try {

View File

@ -84,7 +84,7 @@ public class LazyLoadingTest {
public void testLazyCollectionLoadingAfterEndTransaction(SessionFactoryScope scope) {
Parent loadedParent = scope.fromTransaction(
session ->
session.load( Parent.class, parentID )
session.getReference( Parent.class, parentID )
);
assertFalse( Hibernate.isInitialized( loadedParent.getChildren() ) );
@ -99,7 +99,7 @@ public class LazyLoadingTest {
Child loadedChild = scope.fromTransaction(
sesison ->
sesison.load( Child.class, lastChildID )
sesison.getReference( Child.class, lastChildID )
);
Parent p = loadedChild.getParent();
@ -167,7 +167,7 @@ public class LazyLoadingTest {
scope.inTransaction(
session -> {
Account account = session.load( Account.class, accountId );
Account account = session.getReference( Account.class, accountId );
Client client = account.getClient();
client.getId();
assertThat( Hibernate.isInitialized( client ), is( false ) );

View File

@ -140,7 +140,7 @@ public class ABCTest {
scope.inTransaction(
session -> {
C1 c1 = session.load( C1.class, c.getId() );
C1 c1 = session.getReference( C1.class, c.getId() );
assertTrue(
c1.getAddress().equals( "foo bar" ) &&
( c1.getCount() == 23432 ) &&

View File

@ -145,7 +145,7 @@ public class Qux implements Lifecycle {
public Qux getChild() throws HibernateException, SQLException {
store =true;
this.childKey = child==null ? null : child.getKey();
if (childKey!=null && child==null) child = (Qux) session.load(Qux.class, childKey);
if (childKey!=null && child==null) child = (Qux) session.getReference(Qux.class, childKey);
return child;
}

View File

@ -43,7 +43,7 @@ public class LoadContainedInDoubleContainingTest {
@Test
public void test(SessionFactoryScope scope) {
scope.inTransaction( session -> {
OtherContained otherContained = session.load( OtherContained.class, 2 );
OtherContained otherContained = session.getReference( OtherContained.class, 2 );
String text = otherContained.getText();
assertThat( text ).isEqualTo( "initial" );
} );

View File

@ -42,7 +42,7 @@ public class LoadParentChildEntityTest {
scope.inTransaction(
session -> {
ContainingEntity load = session.load( ContainingEntity.class, 1 );
ContainingEntity load = session.getReference( ContainingEntity.class, 1 );
assertThat( load.getChild() ).isNotNull();
assertThat( load.getParent() ).isNull();
}
@ -50,7 +50,7 @@ public class LoadParentChildEntityTest {
scope.inTransaction(
session -> {
ContainingEntity load = session.load( ContainingEntity.class, 2 );
ContainingEntity load = session.getReference( ContainingEntity.class, 2 );
assertThat( load.getParent() ).isNotNull();
assertThat( load.getChild() ).isNull();
}

View File

@ -121,13 +121,13 @@ public class MultiLoadTest {
scope.inTransaction(
session -> {
// delete one of them (but do not flush)...
SimpleEntity s4 = session.load(SimpleEntity.class, 5);
SimpleEntity s4 = session.getReference(SimpleEntity.class, 5);
session.remove( s4 );
assertFalse( Hibernate.isInitialized( s4 ) );
// as a baseline, assert based on how load() handles it
SimpleEntity s5 = session.load( SimpleEntity.class, 5 );
SimpleEntity s5 = session.getReference( SimpleEntity.class, 5 );
assertNotNull( s5 );
assertFalse( Hibernate.isInitialized( s5 ) );
}
@ -140,12 +140,12 @@ public class MultiLoadTest {
scope.inTransaction(
session -> {
// delete one of them (but do not flush)...
SimpleEntity s4 = session.load( SimpleEntity.class, 5 );
SimpleEntity s4 = session.getReference( SimpleEntity.class, 5 );
Hibernate.initialize( s4 );
session.remove( s4 );
// as a baseline, assert based on how load() handles it
SimpleEntity s5 = session.load( SimpleEntity.class, 5 );
SimpleEntity s5 = session.getReference( SimpleEntity.class, 5 );
assertNotNull( s5 );
}
);
@ -157,7 +157,7 @@ public class MultiLoadTest {
scope.inTransaction(
session -> {
// delete one of them (but do not flush)...
SimpleEntity s4 = session.load( SimpleEntity.class, 5 );
SimpleEntity s4 = session.getReference( SimpleEntity.class, 5 );
Hibernate.initialize( s4 );
session.remove( s4 );
@ -174,7 +174,7 @@ public class MultiLoadTest {
scope.inTransaction(
session -> {
// delete one of them (but do not flush)...
SimpleEntity s4 = session.load( SimpleEntity.class, 5 );
SimpleEntity s4 = session.getReference( SimpleEntity.class, 5 );
Hibernate.initialize( s4 );
session.remove( s4 );
@ -191,7 +191,7 @@ public class MultiLoadTest {
scope.inTransaction(
session -> {
// delete one of them (but do not flush)...
session.remove( session.load( SimpleEntity.class, 5 ) );
session.remove( session.getReference( SimpleEntity.class, 5 ) );
// and then, assert how get() handles it
SimpleEntity s5 = session.get( SimpleEntity.class, 5 );
@ -249,7 +249,7 @@ public class MultiLoadTest {
public void testBasicMultiLoadWithManagedAndNoChecking(SessionFactoryScope scope) {
scope.inTransaction(
session -> {
SimpleEntity first = session.byId( SimpleEntity.class ).load( 1 );
SimpleEntity first = session.byId( SimpleEntity.class ).getReference( 1 );
List<SimpleEntity> list = session.byMultipleIds( SimpleEntity.class ).multiLoad( ids( 56 ) );
assertEquals( 56, list.size() );
// this check is HIGHLY specific to implementation in the batch loader
@ -263,7 +263,7 @@ public class MultiLoadTest {
public void testBasicMultiLoadWithManagedAndChecking(SessionFactoryScope scope) {
scope.inTransaction(
session -> {
SimpleEntity first = session.byId( SimpleEntity.class ).load( 1 );
SimpleEntity first = session.byId( SimpleEntity.class ).getReference( 1 );
List<SimpleEntity> list = session.byMultipleIds( SimpleEntity.class )
.enableSessionCheck( true )
.multiLoad( ids( 56 ) );

View File

@ -75,7 +75,7 @@ public class MapOperationTests {
scope.inTransaction(
session -> {
final EntityOfMaps entity = session.load( EntityOfMaps.class, 1 );
final EntityOfMaps entity = session.getReference( EntityOfMaps.class, 1 );
session.remove( entity );
}
);

View File

@ -88,7 +88,7 @@ public class SetOperationTests {
public void testLoad(SessionFactoryScope scope) {
scope.inTransaction(
session -> {
final EntityOfSets entity = session.load( EntityOfSets.class, 1 );
final EntityOfSets entity = session.getReference( EntityOfSets.class, 1 );
assertThat( entity, notNullValue() );
assertThat( entity, isNotInitialized() );
}
@ -140,7 +140,7 @@ public class SetOperationTests {
public void testDeleteWithElementCollectionData(SessionFactoryScope scope) {
scope.inTransaction(
session -> {
final EntityOfSets entity = session.load( EntityOfSets.class, 1 );
final EntityOfSets entity = session.getReference( EntityOfSets.class, 1 );
session.remove( entity );
}
);

View File

@ -489,7 +489,7 @@ public class AttributeConverterTest extends BaseUnitTestCase {
s = sf.openSession();
s.beginTransaction();
entity = s.load( EntityWithConvertibleField.class, entityID );
entity = s.getReference( EntityWithConvertibleField.class, entityID );
assertEquals( ConvertibleEnum.VALUE, entity.getConvertibleEnum() );
s.getTransaction().commit();
s.close();

View File

@ -85,7 +85,7 @@ public class ElementCollectionTests {
sfScope.inTransaction(
(session) -> {
TheEntity retrieved = (TheEntity) session.load( TheEntity.class, 1 );
TheEntity retrieved = (TheEntity) session.getReference( TheEntity.class, 1 );
assertEquals( 1, retrieved.getSet().size() );
assertEquals( new ValueType( "set_value" ), retrieved.getSet().iterator().next() );
assertEquals( 1, retrieved.getMap().size() );

View File

@ -48,8 +48,8 @@ public class SimpleBatchFetchBaselineTests {
statementInspector.clear();
scope.inTransaction( (session) -> {
final EmployeeGroup group1 = session.load( EmployeeGroup.class, 1 );
final EmployeeGroup group2 = session.load( EmployeeGroup.class, 2 );
final EmployeeGroup group1 = session.getReference( EmployeeGroup.class, 1 );
final EmployeeGroup group2 = session.getReference( EmployeeGroup.class, 2 );
assertThat( Hibernate.isInitialized( group1 ) ).isFalse();
assertThat( Hibernate.isInitialized( group2 ) ).isFalse();

View File

@ -48,8 +48,8 @@ public class SimpleBatchFetchTests {
statementInspector.clear();
scope.inTransaction( (session) -> {
final EmployeeGroup group1 = session.load( EmployeeGroup.class, 1 );
final EmployeeGroup group2 = session.load( EmployeeGroup.class, 2 );
final EmployeeGroup group1 = session.getReference( EmployeeGroup.class, 1 );
final EmployeeGroup group2 = session.getReference( EmployeeGroup.class, 2 );
assertThat( Hibernate.isInitialized( group1 ) ).isFalse();
assertThat( Hibernate.isInitialized( group2 ) ).isFalse();

View File

@ -154,9 +154,9 @@ public class SimpleNestedSubSelectFetchTests {
@AfterEach
public void dropTestData(SessionFactoryScope scope) {
scope.inTransaction( (session) -> {
session.remove( session.load( Customer.class, 1 ) );
session.remove( session.load( Customer.class, 2 ) );
session.remove( session.load( Customer.class, 3 ) );
session.remove( session.getReference( Customer.class, 1 ) );
session.remove( session.getReference( Customer.class, 2 ) );
session.remove( session.getReference( Customer.class, 3 ) );
} );
}

View File

@ -99,8 +99,8 @@ public class SubselectFetchCollectionFromBatchTest {
scope.inTransaction( (s) -> {
EmployeeGroup[] loadedGroups = new EmployeeGroup[] {
s.load(EmployeeGroup.class, createdGroups[0].getId()),
s.load(EmployeeGroup.class, createdGroups[1].getId())
s.getReference(EmployeeGroup.class, createdGroups[0].getId()),
s.getReference(EmployeeGroup.class, createdGroups[1].getId())
};
// there should have been no SQL queries performed and loadedGroups should only contain proxies
@ -226,8 +226,8 @@ public class SubselectFetchCollectionFromBatchTest {
scope.inTransaction( (s) -> {
EmployeeGroup[] loadedGroups = new EmployeeGroup[] {
s.load(EmployeeGroup.class, createdIds[0]),
s.load(EmployeeGroup.class, createdIds[1])
s.getReference(EmployeeGroup.class, createdIds[0]),
s.getReference(EmployeeGroup.class, createdIds[1])
};
// loadedGroups should only contain proxies

View File

@ -66,8 +66,8 @@ public class SubselectFetchTest {
@AfterEach
public void dropTestData(SessionFactoryScope scope) {
scope.inTransaction( (session) -> {
session.remove( session.load( Parent.class, "foo" ) );
session.remove( session.load( Parent.class, "bar" ) );
session.remove( session.getReference( Parent.class, "foo" ) );
session.remove( session.getReference( Parent.class, "bar" ) );
} );
}
@ -277,7 +277,7 @@ public class SubselectFetchTest {
}
finally {
scope.inTransaction( (session) -> {
session.remove( session.load( Parent.class, "aaa" ) );
session.remove( session.getReference( Parent.class, "aaa" ) );
} );
}
}

View File

@ -48,7 +48,7 @@ public class BaseIdEntityByteCodeTest {
} );
scope.inTransaction( session -> {
ContainingEntity entity = session.load( ContainingEntity.class, 1 );
ContainingEntity entity = session.getReference( ContainingEntity.class, 1 );
ContainedEmbeddable containedEmbeddable = entity.getContainedEmbeddable();
assertThat( containedEmbeddable.getText() ).isEqualTo( "initialValue" );
} );

View File

@ -214,7 +214,7 @@ public class DiscriminatorTest {
scope.inTransaction(
s -> {
// load the superclass proxy.
Person pLoad = s.load( Person.class, e.getId() );
Person pLoad = s.getReference( Person.class, e.getId() );
assertTrue( pLoad instanceof HibernateProxy );
Person pGet = s.get( Person.class, e.getId() );
Person pQuery = (Person) s.createQuery( "from Person where id = :id" )
@ -241,7 +241,7 @@ public class DiscriminatorTest {
scope.inTransaction(
s -> {
// load the superclass proxy.
Person pLoad = s.load( Person.class, e.getId() );
Person pLoad = s.getReference( Person.class, e.getId() );
assertTrue( pLoad instanceof HibernateProxy );
Person pGet = s.get( Person.class, e.getId() );
Person pQuery = (Person) s.createQuery( "from Person where id = :id" )
@ -285,7 +285,7 @@ public class DiscriminatorTest {
scope.inTransaction(
s -> {
// load the superclass proxy.
Person pLoad = s.load( Person.class, e.getId() );
Person pLoad = s.getReference( Person.class, e.getId() );
assertTrue( pLoad instanceof HibernateProxy );
// evict the proxy
s.evict( pLoad );

View File

@ -220,7 +220,7 @@ public class SimpleInheritanceTest {
scope.inTransaction(
s -> {
// load the superclass proxy.
Person pLoad = s.load( Person.class, employee.getId() );
Person pLoad = s.getReference( Person.class, employee.getId() );
assertTrue( pLoad instanceof HibernateProxy );
Person pGet = s.get( Person.class, employee.getId() );
Person pQuery = (Person) s.createQuery(
@ -269,7 +269,7 @@ public class SimpleInheritanceTest {
scope.inTransaction(
s -> {
// load the superclass proxy.
Person pLoad = s.load( Person.class, employee.getId() );
Person pLoad = s.getReference( Person.class, employee.getId() );
assertTrue( pLoad instanceof HibernateProxy );
// evict the proxy
s.evict( pLoad );

View File

@ -77,26 +77,26 @@ public class MixedTest {
.openSession()) {
session.beginTransaction();
try {
Item id = session.load( Item.class, did );
Item id = session.getReference( Item.class, did );
assertEquals( did, id.getId() );
assertEquals( "Hibernate in Action", id.getName() );
assertEquals( "/", id.getParent().getName() );
Item id2 = session.load( Item.class, d2id );
Item id2 = session.getReference( Item.class, d2id );
assertEquals( d2id, id2.getId() );
assertEquals( "Secret", id2.getName() );
assertEquals( "/", id2.getParent().getName() );
id.setName( "HiA" );
SecureDocument d2 = session.load( SecureDocument.class, d2id );
SecureDocument d2 = session.getReference( SecureDocument.class, d2id );
d2.setOwner( "max" );
session.flush();
session.clear();
Document d = session.load( Document.class, did );
Document d = session.getReference( Document.class, did );
assertEquals( did, d.getId() );
assertEquals( "HiA", d.getName() );
assertNotNull( d.getContent() );
@ -104,7 +104,7 @@ public class MixedTest {
assertNotNull( d.getCreated() );
assertNotNull( d.getModified() );
d2 = session.load( SecureDocument.class, d2id );
d2 = session.getReference( SecureDocument.class, d2id );
assertEquals( d2id, d2.getId() );
assertEquals( "Secret", d2.getName() );
assertNotNull( d2.getContent() );

View File

@ -139,7 +139,7 @@ public class DiscriminatorMultiTenancyTest extends BaseUnitTestCase {
// make sure we get the steve back, from cache if same tenant (jboss)
doInHibernate( "jboss", session -> {
Customer customer = session.load( Customer.class, 1L );
Customer customer = session.getReference( Customer.class, 1L );
Assert.assertEquals( "steve", customer.getName() );
// also, make sure this came from second level
Assert.assertEquals( 1, sessionFactory.getStatistics().getSecondLevelCacheHitCount() );
@ -149,7 +149,7 @@ public class DiscriminatorMultiTenancyTest extends BaseUnitTestCase {
// then make sure we get the steve back, from db if other tenant (acme)
doInHibernate( "acme", session -> {
Customer customer = session.load( Customer.class, 1L );
Customer customer = session.getReference( Customer.class, 1L );
Assert.assertEquals( "steve", customer.getName() );
// also, make sure this doesn't came from second level
Assert.assertEquals( 0, sessionFactory.getStatistics().getSecondLevelCacheHitCount() );
@ -161,7 +161,7 @@ public class DiscriminatorMultiTenancyTest extends BaseUnitTestCase {
// first jboss
doInHibernate( "jboss", session -> {
Customer customer = session.load( Customer.class, 1L );
Customer customer = session.getReference( Customer.class, 1L );
Assert.assertEquals( "steve", customer.getName() );
// also, make sure this doesn't came from second level
Assert.assertEquals( 0, sessionFactory.getStatistics().getSecondLevelCacheHitCount() );
@ -170,14 +170,14 @@ public class DiscriminatorMultiTenancyTest extends BaseUnitTestCase {
sessionFactory.getStatistics().clear();
// then, acme
doInHibernate( "acme", session -> {
Customer customer = session.load( Customer.class, 1L );
Customer customer = session.getReference( Customer.class, 1L );
Assert.assertEquals( "steve", customer.getName() );
// also, make sure this doesn't came from second level
Assert.assertEquals( 0, sessionFactory.getStatistics().getSecondLevelCacheHitCount() );
} );
doInHibernate( "jboss", session -> {
Customer customer = session.load( Customer.class, 1L );
Customer customer = session.getReference( Customer.class, 1L );
session.remove( customer );
} );
}

View File

@ -196,7 +196,7 @@ public abstract class AbstractSchemaBasedMultiTenancyTest<T extends MultiTenantC
// make sure we get the correct people back, from cache
// first, jboss
doInHibernateSessionBuilder( this::jboss, session -> {
Customer customer = session.load( Customer.class, 1L );
Customer customer = session.getReference( Customer.class, 1L );
Assert.assertEquals( "steve", customer.getName() );
// also, make sure this came from second level
Assert.assertEquals( 1, sessionFactory.getStatistics().getSecondLevelCacheHitCount() );
@ -205,7 +205,7 @@ public abstract class AbstractSchemaBasedMultiTenancyTest<T extends MultiTenantC
sessionFactory.getStatistics().clear();
// then, acme
doInHibernateSessionBuilder( this::acme, session -> {
Customer customer = session.load( Customer.class, 1L );
Customer customer = session.getReference( Customer.class, 1L );
Assert.assertEquals( "john", customer.getName() );
// also, make sure this came from second level
Assert.assertEquals( 1, sessionFactory.getStatistics().getSecondLevelCacheHitCount() );
@ -216,7 +216,7 @@ public abstract class AbstractSchemaBasedMultiTenancyTest<T extends MultiTenantC
sessionFactory.getCache().evictEntityData();
// first jboss
doInHibernateSessionBuilder( this::jboss, session -> {
Customer customer = session.load( Customer.class, 1L );
Customer customer = session.getReference( Customer.class, 1L );
Assert.assertEquals( "steve", customer.getName() );
// also, make sure this came from second level
Assert.assertEquals( 0, sessionFactory.getStatistics().getSecondLevelCacheHitCount() );
@ -225,7 +225,7 @@ public abstract class AbstractSchemaBasedMultiTenancyTest<T extends MultiTenantC
sessionFactory.getStatistics().clear();
// then, acme
doInHibernateSessionBuilder( this::acme, session -> {
Customer customer = session.load( Customer.class, 1L );
Customer customer = session.getReference( Customer.class, 1L );
Assert.assertEquals( "john", customer.getName() );
// also, make sure this came from second level
Assert.assertEquals( 0, sessionFactory.getStatistics().getSecondLevelCacheHitCount() );

View File

@ -54,7 +54,7 @@ public class EagerProxyNotFoundTest {
session -> {
final Task task = new Task();
task.id = 1;
task.employeeEagerNotFoundIgnore = session.load( Employee.class, 2 );
task.employeeEagerNotFoundIgnore = session.getReference( Employee.class, 2 );
session.persist( task );
} );
@ -72,13 +72,13 @@ public class EagerProxyNotFoundTest {
session -> {
final Task task = new Task();
task.id = 1;
task.employeeEagerNotFoundIgnore = session.load( Employee.class, 2 );
task.employeeEagerNotFoundIgnore = session.getReference( Employee.class, 2 );
session.persist( task );
} );
scope.inTransaction(
session -> {
session.load( Employee.class, 2 );
session.getReference( Employee.class, 2 );
final Task task = session.createQuery( "from Task", Task.class ).getSingleResult();
assertNotNull( task );
assertNull( task.employeeEagerNotFoundIgnore );
@ -91,7 +91,7 @@ public class EagerProxyNotFoundTest {
session -> {
final Task task = new Task();
task.id = 1;
task.employeeLazy = session.load( Employee.class, 2 );
task.employeeLazy = session.getReference( Employee.class, 2 );
task.employeeEagerNotFoundIgnore = task.employeeLazy;
session.persist( task );
} );
@ -113,14 +113,14 @@ public class EagerProxyNotFoundTest {
session -> {
final Task task = new Task();
task.id = 1;
task.employeeLazy = session.load( Employee.class, 2 );
task.employeeLazy = session.getReference( Employee.class, 2 );
task.employeeEagerNotFoundIgnore = task.employeeLazy;
session.persist( task );
} );
scope.inTransaction(
session -> {
final Employee employeeProxy = session.load( Employee.class, 2 );
final Employee employeeProxy = session.getReference( Employee.class, 2 );
final Task task = session.createQuery( "from Task", Task.class ).getSingleResult();
assertNotNull( task );
assertNull( task.employeeEagerNotFoundIgnore );
@ -186,7 +186,7 @@ public class EagerProxyNotFoundTest {
try {
scope.inTransaction(
session -> {
session.load( Employee.class, 1 );
session.getReference( Employee.class, 1 );
session.createQuery( "from Task", Task.class ).getSingleResult();
} );
fail( "EntityNotFoundException should have been thrown because Task.employee.location is not found " +
@ -249,7 +249,7 @@ public class EagerProxyNotFoundTest {
try {
scope.inTransaction(
session -> {
session.load( Employee.class, 1 );
session.getReference( Employee.class, 1 );
Task task = session.createQuery( "from Task", Task.class ).getSingleResult();
assertNotNull( task );
Employee employeeEagerNotFoundIgnore = task.getEmployeeEagerNotFoundIgnore();

View File

@ -156,7 +156,7 @@ public class LazyLoadingTest {
Store s = scope.fromTransaction(
session -> {
// first load the store, making sure it is not initialized
Store store = session.load( Store.class, 1 );
Store store = session.getReference( Store.class, 1 );
assertNotNull( store );
assertFalse( Hibernate.isInitialized( store ) );

View File

@ -85,7 +85,7 @@ public abstract class AbstractRecursiveBidirectionalOneToManyTest extends BaseSe
inTransaction(
session -> {
session.setCacheMode( getSessionCacheMode() );
Node node3 = session.load( Node.class, new Integer( 3 ) );
Node node3 = session.getReference( Node.class, new Integer( 3 ) );
Node node2 = node3.getParentNode();
Node node1 = node2.getParentNode();
@ -99,7 +99,7 @@ public abstract class AbstractRecursiveBidirectionalOneToManyTest extends BaseSe
inTransaction(
session -> {
session.setCacheMode( getSessionCacheMode() );
Node node3 = session.load( Node.class, new Integer( 3 ) );
Node node3 = session.getReference( Node.class, new Integer( 3 ) );
Node node2 = node3.getParentNode();
Node node1 = node2.getParentNode();
@ -114,7 +114,7 @@ public abstract class AbstractRecursiveBidirectionalOneToManyTest extends BaseSe
inTransaction(
session -> {
session.setCacheMode( getSessionCacheMode() );
Node node3 = session.load( Node.class, new Integer( 3 ) );
Node node3 = session.getReference( Node.class, new Integer( 3 ) );
Node node2 = node3.getParentNode();
Node node1 = node2.getParentNode();

View File

@ -203,7 +203,7 @@ public class OneToOneFormulaTest extends BaseSessionFactoryFunctionalTest {
Address a = new Address();
a.setType( "HOME" );
a.setPerson( person );
a = session.load( Address.class, a );
a = session.getReference( Address.class, a );
assertFalse( Hibernate.isInitialized( a ) );
a.getPerson();
a.getType();

View File

@ -44,7 +44,7 @@ public class OptionalOneToOneTest {
scope.inTransaction(
session -> {
Person me = session.load( Person.class, name );
Person me = session.getReference( Person.class, name );
assertNull( me.address );
session.remove( me );
}

View File

@ -232,7 +232,7 @@ public class CreateTest extends AbstractOperationTestCase {
scope.inTransaction(
session -> {
Employer er1 = session.load( Employer.class, er.getId() );
Employer er1 = session.getReference( Employer.class, er.getId() );
assertNotNull( er1 );
assertNotNull( er1.getEmployees() );
assertThat( er1.getEmployees().size(), is( 1 ) );

View File

@ -75,10 +75,10 @@ public class GetLoadTest {
scope.inTransaction(
session -> {
Employer e = session.load( Employer.class, emp.getId() );
Employer e = session.getReference( Employer.class, emp.getId() );
e.getId();
assertFalse( Hibernate.isInitialized( e ) );
Node n = session.load( Node.class, node.getName() );
Node n = session.getReference( Node.class, node.getName() );
assertThat( n.getName(), is( "foo" ) );
assertFalse( Hibernate.isInitialized( n ) );
}
@ -95,10 +95,10 @@ public class GetLoadTest {
scope.inTransaction(
session -> {
Employer e = (Employer) session.load( "org.hibernate.orm.test.ops.Employer", emp.getId() );
Employer e = (Employer) session.getReference( "org.hibernate.orm.test.ops.Employer", emp.getId() );
e.getId();
assertFalse( Hibernate.isInitialized( e ) );
Node n = (Node) session.load( "org.hibernate.orm.test.ops.Node", node.getName() );
Node n = (Node) session.getReference( "org.hibernate.orm.test.ops.Node", node.getName() );
assertThat( n.getName(), is( "foo" ) );
assertFalse( Hibernate.isInitialized( n ) );
}

View File

@ -66,7 +66,7 @@ public class SimpleOpsTest extends AbstractOperationTestCase {
SimpleEntity simpleEntity = scope.fromTransaction(
session -> {
SimpleEntity entity = session.load( SimpleEntity.class, id );
SimpleEntity entity = session.getReference( SimpleEntity.class, id );
assertFalse( Hibernate.isInitialized( entity ) );
assertThat( entity.getId(), is( 1L ) );
assertThat( entity.getName(), is( "new name" ) );

View File

@ -87,17 +87,17 @@ public class BasicGetLoadAccessTest {
// test `load` access
scope.inTransaction(
session ->
session.load( User.class, 1 )
session.getReference( User.class, 1 )
);
scope.inTransaction(
session ->
session.load( User.class, 1, LockMode.PESSIMISTIC_WRITE )
session.get( User.class, 1, LockMode.PESSIMISTIC_WRITE )
);
scope.inTransaction(
session ->
session.load( User.class, 1, LockOptions.UPGRADE )
session.get( User.class, 1, LockOptions.UPGRADE )
);
scope.inTransaction(

View File

@ -115,7 +115,7 @@ public class OptimisticLockTest {
scope.inTransaction(
session -> {
Document document = (Document) session.load( entityName, doc.getId() );
Document document = (Document) session.getReference( entityName, doc.getId() );
session.remove( document );
}
);
@ -170,7 +170,7 @@ public class OptimisticLockTest {
scope.inTransaction(
session -> {
Document document = (Document) session.load( entityName, doc.getId() );
Document document = (Document) session.getReference( entityName, doc.getId() );
session.remove( document );
}
);

View File

@ -50,7 +50,7 @@ public class PropertyRefTest {
scope.inTransaction(
session -> {
User u = session.load( User.class, user.getId() );
User u = session.getReference( User.class, user.getId() );
session.remove( u );
}
);

View File

@ -59,7 +59,7 @@ public class PolymorphicAssociationTest {
@Test
public void testLoad(SessionFactoryScope scope) {
scope.inTransaction( session -> {
Level3 level3 = session.load( Level3.class, 3 );
Level3 level3 = session.getReference( Level3.class, 3 );
Level2 level2 = level3.getLevel2Parent();
assertThat( level2 ).isNotNull();
final Level3 level3Child = level2.getLevel3Child();
@ -67,7 +67,7 @@ public class PolymorphicAssociationTest {
} );
scope.inTransaction( session -> {
Level1 level1 = session.load( Level1.class, 1 );
Level1 level1 = session.getReference( Level1.class, 1 );
DerivedLevel2 level2 = level1.getLevel2Child();
assertThat( level2 ).isNotNull();
assertThat( level2.getLevel1Parent() ).extracting( "id" ).isEqualTo( 1 );

View File

@ -59,7 +59,7 @@ public class PolymorphicAssociationTest2 {
@Test
public void testLoad(SessionFactoryScope scope) {
scope.inTransaction( session -> {
Level3 level3 = session.load( Level3.class, 3 );
Level3 level3 = session.getReference( Level3.class, 3 );
Level2 level2 = level3.getLevel2Parent();
assertThat( level2 ).isNotNull();
final Level3 level3Child = level2.getLevel3Child();
@ -67,7 +67,7 @@ public class PolymorphicAssociationTest2 {
} );
scope.inTransaction( session -> {
Level1 level1 = session.load( Level1.class, 1 );
Level1 level1 = session.getReference( Level1.class, 1 );
Level2 level2 = level1.getLevel2Child();
assertThat( level2 ).isNotNull();
assertThat( level2.getLevel1Parent() ).extracting( "id" ).isEqualTo( 1 );

View File

@ -40,7 +40,7 @@ public class DirectPropertyAccessorTest {
s.flush();
s.clear();
o = ( Order ) s.load( Order.class, 1 );
o = ( Order ) s.getReference( Order.class, 1 );
assertFalse( Hibernate.isInitialized( o ) );
o.getOrderNumber();
// If you mapped with field access, any method, except id, call initializes the proxy

View File

@ -51,7 +51,7 @@ public class FinalGetterSetterTest {
try {
scope.inTransaction( session ->
session.load( EntityWithFinalClass.class, 999 )
session.getReference( EntityWithFinalClass.class, 999 )
);
fail( "Should have thrown ObjectNotFoundException" );
}
@ -66,7 +66,7 @@ public class FinalGetterSetterTest {
} );
scope.inTransaction( session -> {
final EntityWithFinalClass entity = session.load( EntityWithFinalClass.class, 1 );
final EntityWithFinalClass entity = session.getReference( EntityWithFinalClass.class, 1 );
assertNotNull( entity );
assertTrue( Hibernate.isInitialized( entity ) );
} );
@ -82,7 +82,7 @@ public class FinalGetterSetterTest {
try {
scope.inTransaction(
session ->
session.load( EntityWithFinalIdGetter.class, 999 )
session.getReference( EntityWithFinalIdGetter.class, 999 )
);
fail( "Should have thrown ObjectNotFoundException" );
}
@ -99,7 +99,7 @@ public class FinalGetterSetterTest {
scope.inTransaction(
session -> {
final EntityWithFinalIdGetter entity = session.load( EntityWithFinalIdGetter.class, 1 );
final EntityWithFinalIdGetter entity = session.getReference( EntityWithFinalIdGetter.class, 1 );
assertNotNull( entity );
assertTrue( Hibernate.isInitialized( entity ) );
} );
@ -115,7 +115,7 @@ public class FinalGetterSetterTest {
try {
scope.inTransaction(
session ->
session.load( EntityWithFinalIdSetter.class, 999 )
session.getReference( EntityWithFinalIdSetter.class, 999 )
);
fail( "Should have thrown ObjectNotFoundException" );
}
@ -132,7 +132,7 @@ public class FinalGetterSetterTest {
scope.inTransaction(
session -> {
final EntityWithFinalIdSetter entity = session.load( EntityWithFinalIdSetter.class, 1 );
final EntityWithFinalIdSetter entity = session.getReference( EntityWithFinalIdSetter.class, 1 );
assertNotNull( entity );
assertTrue( Hibernate.isInitialized( entity ) );
} );
@ -148,7 +148,7 @@ public class FinalGetterSetterTest {
try {
scope.inTransaction(
session ->
session.load( EntityWithFinalVersionGetter.class, 999 )
session.getReference( EntityWithFinalVersionGetter.class, 999 )
);
fail( "Should have thrown ObjectNotFoundException" );
}
@ -165,7 +165,7 @@ public class FinalGetterSetterTest {
scope.inTransaction(
session -> {
final EntityWithFinalVersionGetter entity = session.load( EntityWithFinalVersionGetter.class, 1 );
final EntityWithFinalVersionGetter entity = session.getReference( EntityWithFinalVersionGetter.class, 1 );
assertNotNull( entity );
assertTrue( Hibernate.isInitialized( entity ) );
} );
@ -181,7 +181,7 @@ public class FinalGetterSetterTest {
try {
scope.inTransaction(
session ->
session.load( EntityWithFinalVersionSetter.class, 999 )
session.getReference( EntityWithFinalVersionSetter.class, 999 )
);
fail( "Should have thrown ObjectNotFoundException" );
}
@ -198,7 +198,7 @@ public class FinalGetterSetterTest {
scope.inTransaction(
session -> {
final EntityWithFinalVersionSetter entity = session.load( EntityWithFinalVersionSetter.class, 1 );
final EntityWithFinalVersionSetter entity = session.getReference( EntityWithFinalVersionSetter.class, 1 );
assertNotNull( entity );
assertTrue( Hibernate.isInitialized( entity ) );
} );
@ -214,7 +214,7 @@ public class FinalGetterSetterTest {
try {
scope.inTransaction(
session ->
session.load( EntityWithFinalPropertyGetter.class, 999 )
session.getReference( EntityWithFinalPropertyGetter.class, 999 )
);
fail( "Should have thrown ObjectNotFoundException" );
}
@ -231,7 +231,7 @@ public class FinalGetterSetterTest {
scope.inTransaction(
session -> {
final EntityWithFinalPropertyGetter entity = session.load( EntityWithFinalPropertyGetter.class, 1 );
final EntityWithFinalPropertyGetter entity = session.getReference( EntityWithFinalPropertyGetter.class, 1 );
assertNotNull( entity );
assertTrue( Hibernate.isInitialized( entity ) );
} );
@ -247,7 +247,7 @@ public class FinalGetterSetterTest {
try {
scope.inTransaction(
session ->
session.load( EntityWithFinalPropertySetter.class, 999 )
session.getReference( EntityWithFinalPropertySetter.class, 999 )
);
fail( "Should have thrown ObjectNotFoundException" );
}
@ -264,7 +264,7 @@ public class FinalGetterSetterTest {
scope.inTransaction(
session -> {
final EntityWithFinalPropertySetter entity = session.load( EntityWithFinalPropertySetter.class, 1 );
final EntityWithFinalPropertySetter entity = session.getReference( EntityWithFinalPropertySetter.class, 1 );
assertNotNull( entity );
assertTrue( Hibernate.isInitialized( entity ) );
} );

View File

@ -65,7 +65,7 @@ public class MultipleSessionFactoriesProxyTest extends BaseCoreFunctionalTestCas
s.flush();
s.clear();
container = s.load( Container.class, container.getId() );
container = s.getReference( Container.class, container.getId() );
assertFalse( Hibernate.isInitialized( container ) );
container.getId();
assertFalse( Hibernate.isInitialized( container ) );

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