HHH-18539 update tests after removal of load()
Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
parent
6fe0553fb9
commit
d38971f75b
|
@ -30,7 +30,7 @@ public class ProxyBreakingTest extends BaseCoreFunctionalTestCase {
|
||||||
s.flush();
|
s.flush();
|
||||||
s.clear();
|
s.clear();
|
||||||
assertNotNull( "The proxy creation failure is breaking things", h.getId() );
|
assertNotNull( "The proxy creation failure is breaking things", h.getId() );
|
||||||
h = (Hammer) s.load( Hammer.class, h.getId() );
|
h = (Hammer) s.getReference( Hammer.class, h.getId() );
|
||||||
assertFalse( Hibernate.isInitialized( h ) );
|
assertFalse( Hibernate.isInitialized( h ) );
|
||||||
tx.rollback();
|
tx.rollback();
|
||||||
s.close();
|
s.close();
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class EmbeddableWithMany2OneTest {
|
||||||
// same query!
|
// same query!
|
||||||
session.createQuery( "from Person p where p.address.country.id = 'US'" )
|
session.createQuery( "from Person p where p.address.country.id = 'US'" )
|
||||||
.list();
|
.list();
|
||||||
Person p = session.load( Person.class, person.getId() );
|
Person p = session.getReference( Person.class, person.getId() );
|
||||||
session.remove( p );
|
session.remove( p );
|
||||||
List countries = session.createQuery( "from Country" ).list();
|
List countries = session.createQuery( "from Country" ).list();
|
||||||
assertEquals( 1, countries.size() );
|
assertEquals( 1, countries.size() );
|
||||||
|
|
|
@ -295,10 +295,10 @@ public class BasicHibernateAnnotationsTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
s = openSession();
|
s = openSession();
|
||||||
tx = s.beginTransaction();
|
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");
|
s.enableFilter("byState").setParameter("state", "published");
|
||||||
topic = (Topic) s.load( Topic.class, topic.getId() );
|
topic = (Topic) s.getReference( Topic.class, topic.getId() );
|
||||||
assertNotNull(topic);
|
assertNotNull(topic);
|
||||||
assertTrue(topic.getNarratives().size() == 1);
|
assertTrue(topic.getNarratives().size() == 1);
|
||||||
assertEquals("published", topic.getNarratives().iterator().next().getState());
|
assertEquals("published", topic.getNarratives().iterator().next().getState());
|
||||||
|
@ -392,8 +392,8 @@ public class BasicHibernateAnnotationsTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
tx = s.beginTransaction();
|
tx = s.beginTransaction();
|
||||||
s.clear();
|
s.clear();
|
||||||
team2 = (SoccerTeam)s.load(team2.getClass(), team2.getId());
|
team2 = (SoccerTeam)s.getReference(team2.getClass(), team2.getId());
|
||||||
team = (SoccerTeam)s.load(team.getClass(), team.getId());
|
team = (SoccerTeam)s.getReference(team.getClass(), team.getId());
|
||||||
int count = ( (Long) s.createQuery( "select count(*) from Player" ).list().get( 0 ) ).intValue();
|
int count = ( (Long) s.createQuery( "select count(*) from Player" ).list().get( 0 ) ).intValue();
|
||||||
assertEquals("expected count of 2 but got = " + count, count, 2);
|
assertEquals("expected count of 2 but got = " + count, count, 2);
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class IdClassGeneratedValueTest {
|
||||||
session -> {
|
session -> {
|
||||||
List<Simple> simpleList = session.createQuery( "select s from Simple s" ).list();
|
List<Simple> simpleList = session.createQuery( "select s from Simple s" ).list();
|
||||||
assertEquals( 2, simpleList.size() );
|
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 );
|
assertEquals( s1.getQuantity(), 10 );
|
||||||
session.clear();
|
session.clear();
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ public class IdClassGeneratedValueTest {
|
||||||
session -> {
|
session -> {
|
||||||
List<Simple> simpleList = session.createQuery( "select s from Simple s" ).list();
|
List<Simple> simpleList = session.createQuery( "select s from Simple s" ).list();
|
||||||
assertEquals( 1, simpleList.size() );
|
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 );
|
assertEquals( s1.getQuantity(), 10 );
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -105,7 +105,7 @@ public class IdClassGeneratedValueTest {
|
||||||
session -> {
|
session -> {
|
||||||
List<Simple2> simpleList = session.createQuery( "select s from Simple2 s" ).list();
|
List<Simple2> simpleList = session.createQuery( "select s from Simple2 s" ).list();
|
||||||
assertEquals( simpleList.size(), 2 );
|
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 );
|
assertEquals( s1.getQuantity(), 10 );
|
||||||
session.clear();
|
session.clear();
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ public class IdClassGeneratedValueTest {
|
||||||
session -> {
|
session -> {
|
||||||
List<Multiple> simpleList = session.createQuery( "select m from Multiple m" ).list();
|
List<Multiple> simpleList = session.createQuery( "select m from Multiple m" ).list();
|
||||||
assertEquals( simpleList.size(), 2 );
|
assertEquals( simpleList.size(), 2 );
|
||||||
Multiple m1 = session.load(
|
Multiple m1 = session.getReference(
|
||||||
Multiple.class,
|
Multiple.class,
|
||||||
new MultiplePK( m1Ids.get( 0 ), m1Ids.get( 1 ), 1000L )
|
new MultiplePK( m1Ids.get( 0 ), m1Ids.get( 1 ), 1000L )
|
||||||
);
|
);
|
||||||
|
|
|
@ -167,13 +167,13 @@ public class JoinedSubclassTest {
|
||||||
session.flush();
|
session.flush();
|
||||||
session.clear();
|
session.clear();
|
||||||
|
|
||||||
c1 = session.load( Client.class, c1.getId() );
|
c1 = session.getReference( Client.class, c1.getId() );
|
||||||
assertEquals( 5000.0, c1.getAccount().getBalance(), 0.01 );
|
assertEquals( 5000.0, c1.getAccount().getBalance(), 0.01 );
|
||||||
|
|
||||||
session.flush();
|
session.flush();
|
||||||
session.clear();
|
session.clear();
|
||||||
|
|
||||||
a1 = session.load( Account.class, a1.getId() );
|
a1 = session.getReference( Account.class, a1.getId() );
|
||||||
Set<Client> clients = a1.getClients();
|
Set<Client> clients = a1.getClients();
|
||||||
assertEquals( 1, clients.size() );
|
assertEquals( 1, clients.size() );
|
||||||
Iterator<Client> it = clients.iterator();
|
Iterator<Client> it = clients.iterator();
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class LoaderTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
s = openSession();
|
s = openSession();
|
||||||
tx = s.beginTransaction();
|
tx = s.beginTransaction();
|
||||||
Team t2 = s.load( Team.class, t.getId() );
|
Team t2 = s.getReference( Team.class, t.getId() );
|
||||||
Set<Player> players = t2.getPlayers();
|
Set<Player> players = t2.getPlayers();
|
||||||
Iterator<Player> iterator = players.iterator();
|
Iterator<Player> iterator = players.iterator();
|
||||||
assertEquals( "me", iterator.next().getName() );
|
assertEquals( "me", iterator.next().getName() );
|
||||||
|
@ -75,7 +75,7 @@ public class LoaderTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
long notExistingId = 1l;
|
long notExistingId = 1l;
|
||||||
s.load( Team.class, notExistingId );
|
s.getReference( Team.class, notExistingId );
|
||||||
s.get( Team.class, notExistingId );
|
s.get( Team.class, notExistingId );
|
||||||
s.getTransaction().commit();
|
s.getTransaction().commit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -245,7 +245,7 @@ public class ManyToManyTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
s = openSession();
|
s = openSession();
|
||||||
tx = s.beginTransaction();
|
tx = s.beginTransaction();
|
||||||
er = s.load( Employer.class, er.getId() );
|
er = s.getReference( Employer.class, er.getId() );
|
||||||
assertNotNull( er );
|
assertNotNull( er );
|
||||||
assertNotNull( er.getEmployees() );
|
assertNotNull( er.getEmployees() );
|
||||||
assertEquals( 1, er.getEmployees().size() );
|
assertEquals( 1, er.getEmployees().size() );
|
||||||
|
@ -384,7 +384,7 @@ public class ManyToManyTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
s = openSession();
|
s = openSession();
|
||||||
tx = s.beginTransaction();
|
tx = s.beginTransaction();
|
||||||
er = s.load( Employer.class, er.getId() );
|
er = s.getReference( Employer.class, er.getId() );
|
||||||
assertNotNull( er );
|
assertNotNull( er );
|
||||||
assertNotNull( er.getEmployees() );
|
assertNotNull( er.getEmployees() );
|
||||||
assertEquals( 2, er.getEmployees().size() );
|
assertEquals( 2, er.getEmployees().size() );
|
||||||
|
@ -441,7 +441,7 @@ public class ManyToManyTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
s = openSession();
|
s = openSession();
|
||||||
tx = s.beginTransaction();
|
tx = s.beginTransaction();
|
||||||
f = s.load( Friend.class, f.getId() );
|
f = s.getReference( Friend.class, f.getId() );
|
||||||
assertNotNull( f );
|
assertNotNull( f );
|
||||||
assertNotNull( f.getFriends() );
|
assertNotNull( f.getFriends() );
|
||||||
assertEquals( 1, f.getFriends().size() );
|
assertEquals( 1, f.getFriends().size() );
|
||||||
|
@ -509,10 +509,10 @@ public class ManyToManyTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
s = openSession();
|
s = openSession();
|
||||||
tx = s.beginTransaction();
|
tx = s.beginTransaction();
|
||||||
m1 = s.load( Man.class, m1pk );
|
m1 = s.getReference( Man.class, m1pk );
|
||||||
assertFalse( m1.getWomens().isEmpty() );
|
assertFalse( m1.getWomens().isEmpty() );
|
||||||
assertEquals( 1, m1.getWomens().size() );
|
assertEquals( 1, m1.getWomens().size() );
|
||||||
w1 = s.load( Woman.class, w1pk );
|
w1 = s.getReference( Woman.class, w1pk );
|
||||||
assertFalse( w1.getMens().isEmpty() );
|
assertFalse( w1.getMens().isEmpty() );
|
||||||
assertEquals( 2, w1.getMens().size() );
|
assertEquals( 2, w1.getMens().size() );
|
||||||
|
|
||||||
|
|
|
@ -189,7 +189,7 @@ public class ManyToOneTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
s = openSession();
|
s = openSession();
|
||||||
tx = s.beginTransaction();
|
tx = s.beginTransaction();
|
||||||
discount = s.load( Discount.class, discount.getId() );
|
discount = s.getReference( Discount.class, discount.getId() );
|
||||||
assertNotNull( discount );
|
assertNotNull( discount );
|
||||||
assertFalse( Hibernate.isInitialized( discount.getOwner() ) );
|
assertFalse( Hibernate.isInitialized( discount.getOwner() ) );
|
||||||
tx.commit();
|
tx.commit();
|
||||||
|
|
|
@ -428,7 +428,7 @@ public class OneToManyTest extends BaseNonConfigCoreFunctionalTestCase {
|
||||||
|
|
||||||
s = openSession();
|
s = openSession();
|
||||||
tx = s.beginTransaction();
|
tx = s.beginTransaction();
|
||||||
c = ( Customer ) s.load( Customer.class, c.getId() );
|
c = ( Customer ) s.getReference( Customer.class, c.getId() );
|
||||||
assertNotNull( c );
|
assertNotNull( c );
|
||||||
assertTrue( Hibernate.isInitialized( c.getTickets() ) );
|
assertTrue( Hibernate.isInitialized( c.getTickets() ) );
|
||||||
assertNotNull( c.getTickets() );
|
assertNotNull( c.getTickets() );
|
||||||
|
@ -458,7 +458,7 @@ public class OneToManyTest extends BaseNonConfigCoreFunctionalTestCase {
|
||||||
|
|
||||||
s = openSession();
|
s = openSession();
|
||||||
tx = s.beginTransaction();
|
tx = s.beginTransaction();
|
||||||
c = ( Customer ) s.load( Customer.class, c.getId() );
|
c = ( Customer ) s.getReference( Customer.class, c.getId() );
|
||||||
assertNotNull( c );
|
assertNotNull( c );
|
||||||
assertFalse( Hibernate.isInitialized( c.getDiscountTickets() ) );
|
assertFalse( Hibernate.isInitialized( c.getDiscountTickets() ) );
|
||||||
assertNotNull( c.getDiscountTickets() );
|
assertNotNull( c.getDiscountTickets() );
|
||||||
|
|
|
@ -652,7 +652,7 @@ public class QueryAndSQLTest {
|
||||||
session.clear();
|
session.clear();
|
||||||
session.getSessionFactory().getCache().evictEntityData( Chaos.class );
|
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( upperName, resultChaos.getName() );
|
||||||
assertEquals( "nickname", resultChaos.getNickname() );
|
assertEquals( "nickname", resultChaos.getNickname() );
|
||||||
}
|
}
|
||||||
|
@ -686,14 +686,14 @@ public class QueryAndSQLTest {
|
||||||
session.clear();
|
session.clear();
|
||||||
session.getSessionFactory().getCache().evictEntityData( Chaos.class );
|
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() );
|
assertEquals( 2, resultChaos.getParticles().size() );
|
||||||
resultChaos.getParticles().remove( resultChaos.getParticles().iterator().next() );
|
resultChaos.getParticles().remove( resultChaos.getParticles().iterator().next() );
|
||||||
resultChaos.getParticles().remove( resultChaos.getParticles().iterator().next() );
|
resultChaos.getParticles().remove( resultChaos.getParticles().iterator().next() );
|
||||||
session.flush();
|
session.flush();
|
||||||
|
|
||||||
session.clear();
|
session.clear();
|
||||||
resultChaos = session.load( Chaos.class, chaos.getId() );
|
resultChaos = session.getReference( Chaos.class, chaos.getId() );
|
||||||
assertEquals( 0, resultChaos.getParticles().size() );
|
assertEquals( 0, resultChaos.getParticles().size() );
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -149,13 +149,13 @@ public class BatchFetchTest {
|
||||||
session -> {
|
session -> {
|
||||||
// load them all as proxies
|
// load them all as proxies
|
||||||
for ( int i = 0; i < size; i++ ) {
|
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 ) );
|
assertFalse( Hibernate.isInitialized( entity ) );
|
||||||
}
|
}
|
||||||
scope.getSessionFactory().getStatistics().clear();
|
scope.getSessionFactory().getStatistics().clear();
|
||||||
// now start initializing them...
|
// now start initializing them...
|
||||||
for ( int i = 0; i < size; i++ ) {
|
for ( int i = 0; i < size; i++ ) {
|
||||||
BatchLoadableEntity entity = session.load( BatchLoadableEntity.class, i );
|
BatchLoadableEntity entity = session.getReference( BatchLoadableEntity.class, i );
|
||||||
Hibernate.initialize( entity );
|
Hibernate.initialize( entity );
|
||||||
assertTrue( Hibernate.isInitialized( entity ) );
|
assertTrue( Hibernate.isInitialized( entity ) );
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class InvocationTargetExceptionTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
s = openSession();
|
s = openSession();
|
||||||
s.beginTransaction();
|
s.beginTransaction();
|
||||||
bean = ( Bean ) s.load( Bean.class, bean.getSomeString() );
|
bean = ( Bean ) s.getReference( Bean.class, bean.getSomeString() );
|
||||||
assertFalse( Hibernate.isInitialized( bean ) );
|
assertFalse( Hibernate.isInitialized( bean ) );
|
||||||
try {
|
try {
|
||||||
bean.throwException();
|
bean.throwException();
|
||||||
|
|
|
@ -91,7 +91,7 @@ public class LazyCollectionLoadingTest {
|
||||||
@Test
|
@Test
|
||||||
public void testTransaction(SessionFactoryScope scope) {
|
public void testTransaction(SessionFactoryScope scope) {
|
||||||
scope.inTransaction( s -> {
|
scope.inTransaction( s -> {
|
||||||
Parent parent = s.load( Parent.class, parentID );
|
Parent parent = s.getReference( Parent.class, parentID );
|
||||||
assertThat( parent, notNullValue() );
|
assertThat( parent, notNullValue() );
|
||||||
assertThat( parent, not( instanceOf( HibernateProxy.class ) ) );
|
assertThat( parent, not( instanceOf( HibernateProxy.class ) ) );
|
||||||
assertFalse( isPropertyInitialized( parent, "children" ) );
|
assertFalse( isPropertyInitialized( parent, "children" ) );
|
||||||
|
@ -141,7 +141,7 @@ public class LazyCollectionLoadingTest {
|
||||||
@Test
|
@Test
|
||||||
public void testNoTransaction(SessionFactoryScope scope) {
|
public void testNoTransaction(SessionFactoryScope scope) {
|
||||||
scope.inTransaction( s -> {
|
scope.inTransaction( s -> {
|
||||||
parent = s.load( Parent.class, parentID );
|
parent = s.getReference( Parent.class, parentID );
|
||||||
assertThat( parent, notNullValue() );
|
assertThat( parent, notNullValue() );
|
||||||
assertThat( parent, not( instanceOf( HibernateProxy.class ) ) );
|
assertThat( parent, not( instanceOf( HibernateProxy.class ) ) );
|
||||||
assertFalse( isPropertyInitialized( parent, "children" ) );
|
assertFalse( isPropertyInitialized( parent, "children" ) );
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class LazyLoadingAndInheritanceTest {
|
||||||
@Test
|
@Test
|
||||||
public void test(SessionFactoryScope scope) {
|
public void test(SessionFactoryScope scope) {
|
||||||
scope.inTransaction( s -> {
|
scope.inTransaction( s -> {
|
||||||
Containing containing = s.load( Containing.class, containingID );
|
Containing containing = s.getReference( Containing.class, containingID );
|
||||||
Contained contained = containing.contained;
|
Contained contained = containing.contained;
|
||||||
assertThat( contained ).isNotNull();
|
assertThat( contained ).isNotNull();
|
||||||
assertThat( Hibernate.isPropertyInitialized( contained, "name" ) ).isFalse();
|
assertThat( Hibernate.isPropertyInitialized( contained, "name" ) ).isFalse();
|
||||||
|
|
|
@ -73,7 +73,7 @@ public class LazyLoadingIntegrationTest {
|
||||||
@Test
|
@Test
|
||||||
public void test(SessionFactoryScope scope) {
|
public void test(SessionFactoryScope scope) {
|
||||||
scope.inTransaction( s -> {
|
scope.inTransaction( s -> {
|
||||||
Child loadedChild = s.load( Child.class, lastChildID );
|
Child loadedChild = s.getReference( Child.class, lastChildID );
|
||||||
checkDirtyTracking( loadedChild );
|
checkDirtyTracking( loadedChild );
|
||||||
|
|
||||||
loadedChild.name = "Barrabas";
|
loadedChild.name = "Barrabas";
|
||||||
|
|
|
@ -86,7 +86,7 @@ public class LazyLoadingTest {
|
||||||
@Test
|
@Test
|
||||||
public void test(SessionFactoryScope scope) {
|
public void test(SessionFactoryScope scope) {
|
||||||
scope.inTransaction( s -> {
|
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, not( instanceOf( HibernateProxy.class ) ) );
|
||||||
assertThat( loadedChild, instanceOf( PersistentAttributeInterceptable.class ) );
|
assertThat( loadedChild, instanceOf( PersistentAttributeInterceptable.class ) );
|
||||||
final PersistentAttributeInterceptable interceptable = (PersistentAttributeInterceptable) loadedChild;
|
final PersistentAttributeInterceptable interceptable = (PersistentAttributeInterceptable) loadedChild;
|
||||||
|
|
|
@ -90,7 +90,7 @@ public class MultiPathCascadeTest {
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
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 );
|
assertInstanceOf( HibernateProxy.class, aLoaded );
|
||||||
assertSame( aLoaded, session.merge( a ) );
|
assertSame( aLoaded, session.merge( a ) );
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class BasicAttributesLazyGroupTest {
|
||||||
@Test
|
@Test
|
||||||
public void testLoad(SessionFactoryScope scope) {
|
public void testLoad(SessionFactoryScope scope) {
|
||||||
scope.inTransaction( session -> {
|
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, "rating" ) );
|
||||||
assertFalse( Hibernate.isPropertyInitialized( review, "comment" ) );
|
assertFalse( Hibernate.isPropertyInitialized( review, "comment" ) );
|
||||||
|
@ -86,7 +86,7 @@ public class BasicAttributesLazyGroupTest {
|
||||||
@Test
|
@Test
|
||||||
public void testLoad2(SessionFactoryScope scope) {
|
public void testLoad2(SessionFactoryScope scope) {
|
||||||
scope.inTransaction( session -> {
|
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, "rating" ) );
|
||||||
assertFalse( Hibernate.isPropertyInitialized( review, "comment" ) );
|
assertFalse( Hibernate.isPropertyInitialized( review, "comment" ) );
|
||||||
|
@ -101,7 +101,7 @@ public class BasicAttributesLazyGroupTest {
|
||||||
@Test
|
@Test
|
||||||
public void testLoad3(SessionFactoryScope scope) {
|
public void testLoad3(SessionFactoryScope scope) {
|
||||||
scope.inTransaction( session -> {
|
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.getComment(), is( "My first review" ) );
|
||||||
assertThat( review.getRating(), is( Rating.ONE ) );
|
assertThat( review.getRating(), is( Rating.ONE ) );
|
||||||
|
@ -111,7 +111,7 @@ public class BasicAttributesLazyGroupTest {
|
||||||
@Test
|
@Test
|
||||||
public void testLoad4(SessionFactoryScope scope) {
|
public void testLoad4(SessionFactoryScope scope) {
|
||||||
scope.inTransaction( session -> {
|
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.getRating(), is( Rating.ONE ) );
|
||||||
assertThat( review.getComment(), is( "My first review" ) );
|
assertThat( review.getComment(), is( "My first review" ) );
|
||||||
} );
|
} );
|
||||||
|
|
|
@ -134,7 +134,7 @@ public class BatchFetchProxyTest {
|
||||||
|
|
||||||
List<Employer> employers = new ArrayList<>();
|
List<Employer> employers = new ArrayList<>();
|
||||||
for ( int i = 0 ; i < NUMBER_OF_ENTITIES ; i++ ) {
|
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() );
|
assertEquals( 0, statistics.getPrepareStatementCount() );
|
||||||
|
@ -167,7 +167,7 @@ public class BatchFetchProxyTest {
|
||||||
|
|
||||||
List<Employer> employers = new ArrayList<>();
|
List<Employer> employers = new ArrayList<>();
|
||||||
for ( int i = 0 ; i < NUMBER_OF_ENTITIES ; i++ ) {
|
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() );
|
assertEquals( 0, statistics.getPrepareStatementCount() );
|
||||||
|
|
|
@ -74,7 +74,7 @@ public class BytecodeEnhancedLazyLoadingOnDeletedEntityTest {
|
||||||
s.persist( owner );
|
s.persist( owner );
|
||||||
} );
|
} );
|
||||||
assertThatThrownBy( () -> scope.inTransaction( session -> {
|
assertThatThrownBy( () -> scope.inTransaction( session -> {
|
||||||
AssociationOwner owner = session.load( AssociationOwner.class, 1 );
|
AssociationOwner owner = session.getReference( AssociationOwner.class, 1 );
|
||||||
session.remove( owner );
|
session.remove( owner );
|
||||||
session.flush();
|
session.flush();
|
||||||
owner.getNonOwners().size();
|
owner.getNonOwners().size();
|
||||||
|
@ -92,7 +92,7 @@ public class BytecodeEnhancedLazyLoadingOnDeletedEntityTest {
|
||||||
s.persist( nonOwner );
|
s.persist( nonOwner );
|
||||||
} );
|
} );
|
||||||
assertThatThrownBy( () -> scope.inTransaction( session -> {
|
assertThatThrownBy( () -> scope.inTransaction( session -> {
|
||||||
AssociationNonOwner nonOwner = session.load( AssociationNonOwner.class, 1 );
|
AssociationNonOwner nonOwner = session.getReference( AssociationNonOwner.class, 1 );
|
||||||
session.remove( nonOwner );
|
session.remove( nonOwner );
|
||||||
session.flush();
|
session.flush();
|
||||||
nonOwner.getOwners().size();
|
nonOwner.getOwners().size();
|
||||||
|
|
|
@ -107,7 +107,7 @@ public class FetchGraphTest {
|
||||||
|
|
||||||
scope.inSession(
|
scope.inSession(
|
||||||
session -> {
|
session -> {
|
||||||
final DEntity entityD = session.load( DEntity.class, 1L );
|
final DEntity entityD = session.getReference( DEntity.class, 1L );
|
||||||
assertThat( stats.getPrepareStatementCount(), is( 0L ) );
|
assertThat( stats.getPrepareStatementCount(), is( 0L ) );
|
||||||
assert !Hibernate.isPropertyInitialized( entityD, "a" );
|
assert !Hibernate.isPropertyInitialized( entityD, "a" );
|
||||||
assert !Hibernate.isPropertyInitialized( entityD, "c" );
|
assert !Hibernate.isPropertyInitialized( entityD, "c" );
|
||||||
|
@ -141,7 +141,7 @@ public class FetchGraphTest {
|
||||||
|
|
||||||
scope.inSession(
|
scope.inSession(
|
||||||
session -> {
|
session -> {
|
||||||
final EEntity entityE = session.load( EEntity.class, 17L );
|
final EEntity entityE = session.getReference( EEntity.class, 17L );
|
||||||
assertThat( stats.getPrepareStatementCount(), is( 0L ) );
|
assertThat( stats.getPrepareStatementCount(), is( 0L ) );
|
||||||
assert !Hibernate.isPropertyInitialized( entityE, "d" );
|
assert !Hibernate.isPropertyInitialized( entityE, "d" );
|
||||||
|
|
||||||
|
@ -356,7 +356,7 @@ public class FetchGraphTest {
|
||||||
session -> {
|
session -> {
|
||||||
final AEntity entityA = session.get( AEntity.class, 1L );
|
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 );
|
assert !Hibernate.isInitialized( entityD );
|
||||||
Hibernate.initialize( entityD );
|
Hibernate.initialize( entityD );
|
||||||
assert Hibernate.isPropertyInitialized( entityD, "a" );
|
assert Hibernate.isPropertyInitialized( entityD, "a" );
|
||||||
|
@ -383,7 +383,7 @@ public class FetchGraphTest {
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
// Load a D
|
// 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 HibernateProxy, is( false ) );
|
||||||
assertThat( entityD instanceof PersistentAttributeInterceptable, is( true ) );
|
assertThat( entityD instanceof PersistentAttributeInterceptable, is( true ) );
|
||||||
|
@ -611,7 +611,7 @@ public class FetchGraphTest {
|
||||||
public void testLoadAndDeleteDEntity(SessionFactoryScope scope) {
|
public void testLoadAndDeleteDEntity(SessionFactoryScope scope) {
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
DEntity entity = session.load( DEntity.class, 1L );
|
DEntity entity = session.getReference( DEntity.class, 1L );
|
||||||
session.remove( entity );
|
session.remove( entity );
|
||||||
session.remove( entity.getE() );
|
session.remove( entity.getE() );
|
||||||
session.remove( entity.getA() );
|
session.remove( entity.getA() );
|
||||||
|
@ -654,7 +654,7 @@ public class FetchGraphTest {
|
||||||
public void testLoadAndDeleteEEntity(SessionFactoryScope scope) {
|
public void testLoadAndDeleteEEntity(SessionFactoryScope scope) {
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
EEntity entity = session.load( EEntity.class, 17L );
|
EEntity entity = session.getReference( EEntity.class, 17L );
|
||||||
session.remove( entity );
|
session.remove( entity );
|
||||||
session.remove( entity.getD() );
|
session.remove( entity.getD() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ public class LazyToOnesProxyWithSubclassesTest {
|
||||||
|
|
||||||
assertEquals( 1, stats.getPrepareStatementCount() );
|
assertEquals( 1, stats.getPrepareStatementCount() );
|
||||||
|
|
||||||
Animal animal = session.load( Animal.class, "A Human" );
|
Animal animal = session.getReference( Animal.class, "A Human" );
|
||||||
assertFalse( Hibernate.isInitialized( animal ) );
|
assertFalse( Hibernate.isInitialized( animal ) );
|
||||||
assertEquals( 1, stats.getPrepareStatementCount() );
|
assertEquals( 1, stats.getPrepareStatementCount() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class LoadANonExistingEntityTest {
|
||||||
statistics.clear();
|
statistics.clear();
|
||||||
|
|
||||||
scope.inTransaction( session -> {
|
scope.inTransaction( session -> {
|
||||||
Employer nonExisting = session.load( Employer.class, -1 );
|
Employer nonExisting = session.getReference( Employer.class, -1 );
|
||||||
assertEquals( 0, statistics.getPrepareStatementCount() );
|
assertEquals( 0, statistics.getPrepareStatementCount() );
|
||||||
assertFalse( Hibernate.isInitialized( nonExisting ) );
|
assertFalse( Hibernate.isInitialized( nonExisting ) );
|
||||||
try {
|
try {
|
||||||
|
@ -93,7 +93,7 @@ public class LoadANonExistingEntityTest {
|
||||||
final StatisticsImplementor statistics = scope.getSessionFactory().getStatistics();
|
final StatisticsImplementor statistics = scope.getSessionFactory().getStatistics();
|
||||||
statistics.clear();
|
statistics.clear();
|
||||||
scope.inTransaction( session -> {
|
scope.inTransaction( session -> {
|
||||||
Employer nonExisting = session.load( Employer.class, -1 );
|
Employer nonExisting = session.getReference( Employer.class, -1 );
|
||||||
assertEquals( 0, statistics.getPrepareStatementCount() );
|
assertEquals( 0, statistics.getPrepareStatementCount() );
|
||||||
assertFalse( Hibernate.isInitialized( nonExisting ) );
|
assertFalse( Hibernate.isInitialized( nonExisting ) );
|
||||||
try {
|
try {
|
||||||
|
@ -114,7 +114,7 @@ public class LoadANonExistingEntityTest {
|
||||||
final StatisticsImplementor statistics = scope.getSessionFactory().getStatistics();
|
final StatisticsImplementor statistics = scope.getSessionFactory().getStatistics();
|
||||||
statistics.clear();
|
statistics.clear();
|
||||||
scope.inTransaction( session -> {
|
scope.inTransaction( session -> {
|
||||||
Employer nonExisting = session.load( Employer.class, -1 );
|
Employer nonExisting = session.getReference( Employer.class, -1 );
|
||||||
assertEquals( 0, statistics.getPrepareStatementCount() );
|
assertEquals( 0, statistics.getPrepareStatementCount() );
|
||||||
assertFalse( Hibernate.isInitialized( nonExisting ) );
|
assertFalse( Hibernate.isInitialized( nonExisting ) );
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -82,7 +82,7 @@ public class LoadANonExistingNotFoundBatchEntityTest {
|
||||||
scope.inTransaction( (session) -> {
|
scope.inTransaction( (session) -> {
|
||||||
List<Employee> employees = new ArrayList<>( NUMBER_OF_ENTITIES );
|
List<Employee> employees = new ArrayList<>( NUMBER_OF_ENTITIES );
|
||||||
for ( int i = 0 ; i < NUMBER_OF_ENTITIES ; i++ ) {
|
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++ ) {
|
for ( int i = 0 ; i < NUMBER_OF_ENTITIES ; i++ ) {
|
||||||
Hibernate.initialize( employees.get( i ) );
|
Hibernate.initialize( employees.get( i ) );
|
||||||
|
|
|
@ -75,7 +75,7 @@ public class LoadANonExistingNotFoundEntityTest {
|
||||||
statistics.clear();
|
statistics.clear();
|
||||||
|
|
||||||
scope.inTransaction( session -> {
|
scope.inTransaction( session -> {
|
||||||
Employee employee = session.load( Employee.class, 1 );
|
Employee employee = session.getReference( Employee.class, 1 );
|
||||||
Hibernate.initialize( employee );
|
Hibernate.initialize( employee );
|
||||||
assertNull( employee.employer );
|
assertNull( employee.employer );
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,7 @@ public class LoadANonExistingNotFoundLazyBatchEntityTest {
|
||||||
scope.inTransaction( (session) -> {
|
scope.inTransaction( (session) -> {
|
||||||
List<Employee> employees = new ArrayList<>( NUMBER_OF_ENTITIES );
|
List<Employee> employees = new ArrayList<>( NUMBER_OF_ENTITIES );
|
||||||
for ( int i = 0 ; i < NUMBER_OF_ENTITIES ; i++ ) {
|
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++ ) {
|
for ( int i = 0 ; i < NUMBER_OF_ENTITIES ; i++ ) {
|
||||||
Hibernate.initialize( employees.get( i ) );
|
Hibernate.initialize( employees.get( i ) );
|
||||||
|
|
|
@ -95,7 +95,7 @@ public class MergeProxyTest {
|
||||||
public void testMergeDetachInitializedProxy(SessionFactoryScope scope) {
|
public void testMergeDetachInitializedProxy(SessionFactoryScope scope) {
|
||||||
final Activity activityProxy = scope.fromTransaction(
|
final Activity activityProxy = scope.fromTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
final Activity activity = session.load( Activity.class, 0 );
|
final Activity activity = session.getReference( Activity.class, 0 );
|
||||||
assertFalse( Hibernate.isInitialized( activity) );
|
assertFalse( Hibernate.isInitialized( activity) );
|
||||||
Hibernate.initialize( activity );
|
Hibernate.initialize( activity );
|
||||||
return activity;
|
return activity;
|
||||||
|
@ -140,7 +140,7 @@ public class MergeProxyTest {
|
||||||
public void testMergeDetachInitializedByAccessProxy(SessionFactoryScope scope) {
|
public void testMergeDetachInitializedByAccessProxy(SessionFactoryScope scope) {
|
||||||
final Activity activityProxy = scope.fromTransaction(
|
final Activity activityProxy = scope.fromTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
final Activity activity = session.load( Activity.class, 0 );
|
final Activity activity = session.getReference( Activity.class, 0 );
|
||||||
assertFalse( Hibernate.isInitialized( activity) );
|
assertFalse( Hibernate.isInitialized( activity) );
|
||||||
activity.getDescription();
|
activity.getDescription();
|
||||||
return activity;
|
return activity;
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class ProxyInitializeAndUpdateInlineDirtyTrackingDynamicUpdateTest {
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
Animal animal = session.load( Animal.class, "animal" );
|
Animal animal = session.getReference( Animal.class, "animal" );
|
||||||
assertFalse( Hibernate.isInitialized( animal ) );
|
assertFalse( Hibernate.isInitialized( animal ) );
|
||||||
assertEquals( LoadState.NOT_LOADED , PersistenceUtilHelper.isLoadedWithoutReference( animal, "sex", metadataCache ) );
|
assertEquals( LoadState.NOT_LOADED , PersistenceUtilHelper.isLoadedWithoutReference( animal, "sex", metadataCache ) );
|
||||||
assertEquals( "female", animal.getSex() );
|
assertEquals( "female", animal.getSex() );
|
||||||
|
@ -108,7 +108,7 @@ public class ProxyInitializeAndUpdateInlineDirtyTrackingDynamicUpdateTest {
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
Animal animal = session.load( Animal.class, "animal" );
|
Animal animal = session.getReference( Animal.class, "animal" );
|
||||||
assertFalse( Hibernate.isInitialized( animal ) );
|
assertFalse( Hibernate.isInitialized( animal ) );
|
||||||
assertEquals( LoadState.NOT_LOADED , PersistenceUtilHelper.isLoadedWithoutReference( animal, "sex", metadataCache ) );
|
assertEquals( LoadState.NOT_LOADED , PersistenceUtilHelper.isLoadedWithoutReference( animal, "sex", metadataCache ) );
|
||||||
animal.setSex( "other" );
|
animal.setSex( "other" );
|
||||||
|
@ -156,7 +156,7 @@ public class ProxyInitializeAndUpdateInlineDirtyTrackingDynamicUpdateTest {
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
final Animal animal = session.load( Animal.class, "animal" );
|
final Animal animal = session.getReference( Animal.class, "animal" );
|
||||||
assertFalse( Hibernate.isInitialized( animal ) );
|
assertFalse( Hibernate.isInitialized( animal ) );
|
||||||
assertEquals( LoadState.NOT_LOADED , PersistenceUtilHelper.isLoadedWithoutReference( animal, "age", metadataCache ) );
|
assertEquals( LoadState.NOT_LOADED , PersistenceUtilHelper.isLoadedWithoutReference( animal, "age", metadataCache ) );
|
||||||
session.merge( animalInitialized );
|
session.merge( animalInitialized );
|
||||||
|
@ -236,7 +236,7 @@ public class ProxyInitializeAndUpdateInlineDirtyTrackingDynamicUpdateTest {
|
||||||
);
|
);
|
||||||
|
|
||||||
final Animal animalUninitialized = scope.fromTransaction( session -> {
|
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 ) );
|
assertFalse( Hibernate.isInitialized( animal ) );
|
||||||
assertEquals( LoadState.NOT_LOADED , PersistenceUtilHelper.isLoadedWithoutReference( animal, "age", metadataCache ) );
|
assertEquals( LoadState.NOT_LOADED , PersistenceUtilHelper.isLoadedWithoutReference( animal, "age", metadataCache ) );
|
||||||
assertFalse( Hibernate.isInitialized( animal ) ); //checking again against side effects of using PersistenceUtilHelper
|
assertFalse( Hibernate.isInitialized( animal ) ); //checking again against side effects of using PersistenceUtilHelper
|
||||||
|
@ -246,7 +246,7 @@ public class ProxyInitializeAndUpdateInlineDirtyTrackingDynamicUpdateTest {
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
final Animal animal = session.load( Animal.class, "animal" );
|
final Animal animal = session.getReference( Animal.class, "animal" );
|
||||||
assertFalse( Hibernate.isInitialized( animal ) );
|
assertFalse( Hibernate.isInitialized( animal ) );
|
||||||
assertEquals( LoadState.NOT_LOADED , PersistenceUtilHelper.isLoadedWithoutReference( animal, "age", metadataCache ) );
|
assertEquals( LoadState.NOT_LOADED , PersistenceUtilHelper.isLoadedWithoutReference( animal, "age", metadataCache ) );
|
||||||
session.merge( animalUninitialized );
|
session.merge( animalUninitialized );
|
||||||
|
@ -279,7 +279,7 @@ public class ProxyInitializeAndUpdateInlineDirtyTrackingDynamicUpdateTest {
|
||||||
);
|
);
|
||||||
|
|
||||||
final Animal animalUninitialized = scope.fromTransaction( session -> {
|
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 ) );
|
assertFalse( Hibernate.isInitialized( animal ) );
|
||||||
assertEquals( LoadState.NOT_LOADED , PersistenceUtilHelper.isLoadedWithoutReference( animal, "age", metadataCache ) );
|
assertEquals( LoadState.NOT_LOADED , PersistenceUtilHelper.isLoadedWithoutReference( animal, "age", metadataCache ) );
|
||||||
assertFalse( Hibernate.isInitialized( animal ) );
|
assertFalse( Hibernate.isInitialized( animal ) );
|
||||||
|
|
|
@ -65,7 +65,7 @@ public class ProxyInitializeAndUpdateInlineDirtyTrackingTest {
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
Animal animal = session.load( Animal.class, "animal" );
|
Animal animal = session.getReference( Animal.class, "animal" );
|
||||||
assertFalse( Hibernate.isInitialized( animal ) );
|
assertFalse( Hibernate.isInitialized( animal ) );
|
||||||
assertEquals( "female", animal.getSex() );
|
assertEquals( "female", animal.getSex() );
|
||||||
assertTrue( Hibernate.isInitialized( animal ) );
|
assertTrue( Hibernate.isInitialized( animal ) );
|
||||||
|
@ -100,7 +100,7 @@ public class ProxyInitializeAndUpdateInlineDirtyTrackingTest {
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
Animal animal = session.load( Animal.class, "animal" );
|
Animal animal = session.getReference( Animal.class, "animal" );
|
||||||
assertFalse( Hibernate.isInitialized( animal ) );
|
assertFalse( Hibernate.isInitialized( animal ) );
|
||||||
animal.setSex( "other" );
|
animal.setSex( "other" );
|
||||||
// Setting the attribute value should have initialized animal.
|
// Setting the attribute value should have initialized animal.
|
||||||
|
@ -145,7 +145,7 @@ public class ProxyInitializeAndUpdateInlineDirtyTrackingTest {
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
final Animal animal = session.load( Animal.class, "animal" );
|
final Animal animal = session.getReference( Animal.class, "animal" );
|
||||||
assertFalse( Hibernate.isInitialized( animal ) );
|
assertFalse( Hibernate.isInitialized( animal ) );
|
||||||
session.merge( animalInitialized );
|
session.merge( animalInitialized );
|
||||||
assertTrue( Hibernate.isInitialized( animal ) );
|
assertTrue( Hibernate.isInitialized( animal ) );
|
||||||
|
@ -223,7 +223,7 @@ public class ProxyInitializeAndUpdateInlineDirtyTrackingTest {
|
||||||
);
|
);
|
||||||
|
|
||||||
final Animal animalUninitialized = scope.fromTransaction( session -> {
|
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 ) );
|
assertFalse( Hibernate.isInitialized( animal ) );
|
||||||
return animal;
|
return animal;
|
||||||
}
|
}
|
||||||
|
@ -231,7 +231,7 @@ public class ProxyInitializeAndUpdateInlineDirtyTrackingTest {
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
final Animal animal = session.load( Animal.class, "animal" );
|
final Animal animal = session.getReference( Animal.class, "animal" );
|
||||||
assertFalse( Hibernate.isInitialized( animal ) );
|
assertFalse( Hibernate.isInitialized( animal ) );
|
||||||
session.merge( animalUninitialized );
|
session.merge( animalUninitialized );
|
||||||
assertFalse( Hibernate.isInitialized( animal ) );
|
assertFalse( Hibernate.isInitialized( animal ) );
|
||||||
|
@ -261,7 +261,7 @@ public class ProxyInitializeAndUpdateInlineDirtyTrackingTest {
|
||||||
);
|
);
|
||||||
|
|
||||||
final Animal animalUninitialized = scope.fromTransaction( session -> {
|
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 ) );
|
assertFalse( Hibernate.isInitialized( animal ) );
|
||||||
return animal;
|
return animal;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class ProxyInitializeAndUpdateTest {
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
Animal animal = session.load( Animal.class, "animal" );
|
Animal animal = session.getReference( Animal.class, "animal" );
|
||||||
assertFalse( Hibernate.isInitialized( animal ) );
|
assertFalse( Hibernate.isInitialized( animal ) );
|
||||||
assertEquals( "female", animal.getSex() );
|
assertEquals( "female", animal.getSex() );
|
||||||
assertTrue( Hibernate.isInitialized( animal ) );
|
assertTrue( Hibernate.isInitialized( animal ) );
|
||||||
|
@ -101,7 +101,7 @@ public class ProxyInitializeAndUpdateTest {
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
Animal animal = session.load( Animal.class, "animal" );
|
Animal animal = session.getReference( Animal.class, "animal" );
|
||||||
assertFalse( Hibernate.isInitialized( animal ) );
|
assertFalse( Hibernate.isInitialized( animal ) );
|
||||||
animal.setSex( "other" );
|
animal.setSex( "other" );
|
||||||
// Setting the attribute value should have initialized animal.
|
// Setting the attribute value should have initialized animal.
|
||||||
|
@ -146,7 +146,7 @@ public class ProxyInitializeAndUpdateTest {
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
final Animal animal = session.load( Animal.class, "animal" );
|
final Animal animal = session.getReference( Animal.class, "animal" );
|
||||||
assertFalse( Hibernate.isInitialized( animal ) );
|
assertFalse( Hibernate.isInitialized( animal ) );
|
||||||
final Animal animalMerged = (Animal) session.merge( animalInitialized );
|
final Animal animalMerged = (Animal) session.merge( animalInitialized );
|
||||||
assertSame( animal, animalMerged );
|
assertSame( animal, animalMerged );
|
||||||
|
@ -226,7 +226,7 @@ public class ProxyInitializeAndUpdateTest {
|
||||||
);
|
);
|
||||||
|
|
||||||
final Animal animalUninitialized = scope.fromTransaction( session -> {
|
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 ) );
|
assertFalse( Hibernate.isInitialized( animal ) );
|
||||||
return animal;
|
return animal;
|
||||||
}
|
}
|
||||||
|
@ -234,7 +234,7 @@ public class ProxyInitializeAndUpdateTest {
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
final Animal animal = session.load( Animal.class, "animal" );
|
final Animal animal = session.getReference( Animal.class, "animal" );
|
||||||
assertFalse( Hibernate.isInitialized( animal ) );
|
assertFalse( Hibernate.isInitialized( animal ) );
|
||||||
final Animal animalMerged = (Animal) session.merge( animalUninitialized );
|
final Animal animalMerged = (Animal) session.merge( animalUninitialized );
|
||||||
assertSame( animal, animalMerged );
|
assertSame( animal, animalMerged );
|
||||||
|
@ -265,7 +265,7 @@ public class ProxyInitializeAndUpdateTest {
|
||||||
);
|
);
|
||||||
|
|
||||||
final Animal animalUninitialized = scope.fromTransaction( session -> {
|
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 ) );
|
assertFalse( Hibernate.isInitialized( animal ) );
|
||||||
return animal;
|
return animal;
|
||||||
}
|
}
|
||||||
|
@ -273,7 +273,7 @@ public class ProxyInitializeAndUpdateTest {
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
final Animal animal = session.load( Animal.class, "animal" );
|
final Animal animal = session.getReference( Animal.class, "animal" );
|
||||||
assertFalse( Hibernate.isInitialized( animal ) );
|
assertFalse( Hibernate.isInitialized( animal ) );
|
||||||
animal.setSex( "other" );
|
animal.setSex( "other" );
|
||||||
assertTrue( Hibernate.isInitialized( animal ) );
|
assertTrue( Hibernate.isInitialized( animal ) );
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class SetIdentifierOnAEnhancedProxyTest {
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
stats.clear();
|
stats.clear();
|
||||||
Child loadedChild = session.load( Child.class, lastChildID );
|
Child loadedChild = session.getReference( Child.class, lastChildID );
|
||||||
|
|
||||||
final PersistentAttributeInterceptable interceptable = (PersistentAttributeInterceptable) loadedChild;
|
final PersistentAttributeInterceptable interceptable = (PersistentAttributeInterceptable) loadedChild;
|
||||||
final PersistentAttributeInterceptor interceptor = interceptable.$$_hibernate_getInterceptor();
|
final PersistentAttributeInterceptor interceptor = interceptable.$$_hibernate_getInterceptor();
|
||||||
|
@ -102,7 +102,7 @@ public class SetIdentifierOnAEnhancedProxyTest {
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
Child loadedChild = session.load( Child.class, lastChildID );
|
Child loadedChild = session.getReference( Child.class, lastChildID );
|
||||||
assertThat( loadedChild ).isNotNull();
|
assertThat( loadedChild ).isNotNull();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -120,7 +120,7 @@ public class SetIdentifierOnAEnhancedProxyTest {
|
||||||
ModelId id = new ModelId();
|
ModelId id = new ModelId();
|
||||||
id.setId1( 1L );
|
id.setId1( 1L );
|
||||||
id.setId2( 2L );
|
id.setId2( 2L );
|
||||||
Parent parent = session.load( Parent.class, id );
|
Parent parent = session.getReference( Parent.class, id );
|
||||||
|
|
||||||
final PersistentAttributeInterceptable interceptable = (PersistentAttributeInterceptable) parent;
|
final PersistentAttributeInterceptable interceptable = (PersistentAttributeInterceptable) parent;
|
||||||
final PersistentAttributeInterceptor interceptor = interceptable.$$_hibernate_getInterceptor();
|
final PersistentAttributeInterceptor interceptor = interceptable.$$_hibernate_getInterceptor();
|
||||||
|
@ -142,7 +142,7 @@ public class SetIdentifierOnAEnhancedProxyTest {
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
Child loadedChild = session.load( Child.class, lastChildID );
|
Child loadedChild = session.getReference( Child.class, lastChildID );
|
||||||
assertThat( loadedChild ).isNotNull();
|
assertThat( loadedChild ).isNotNull();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -160,7 +160,7 @@ public class SetIdentifierOnAEnhancedProxyTest {
|
||||||
ModelId id = new ModelId();
|
ModelId id = new ModelId();
|
||||||
id.setId1( 1L );
|
id.setId1( 1L );
|
||||||
id.setId2( 2L );
|
id.setId2( 2L );
|
||||||
Parent parent = session.load( Parent.class, id );
|
Parent parent = session.getReference( Parent.class, id );
|
||||||
|
|
||||||
final PersistentAttributeInterceptable interceptable = (PersistentAttributeInterceptable) parent;
|
final PersistentAttributeInterceptable interceptable = (PersistentAttributeInterceptable) parent;
|
||||||
final PersistentAttributeInterceptor interceptor = interceptable.$$_hibernate_getInterceptor();
|
final PersistentAttributeInterceptor interceptor = interceptable.$$_hibernate_getInterceptor();
|
||||||
|
@ -189,7 +189,7 @@ public class SetIdentifierOnAEnhancedProxyTest {
|
||||||
() -> scope.inTransaction(
|
() -> scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
stats.clear();
|
stats.clear();
|
||||||
Child loadedChild = session.load( Child.class, lastChildID );
|
Child loadedChild = session.getReference( Child.class, lastChildID );
|
||||||
|
|
||||||
final PersistentAttributeInterceptable interceptable = (PersistentAttributeInterceptable) loadedChild;
|
final PersistentAttributeInterceptable interceptable = (PersistentAttributeInterceptable) loadedChild;
|
||||||
final PersistentAttributeInterceptor interceptor = interceptable.$$_hibernate_getInterceptor();
|
final PersistentAttributeInterceptor interceptor = interceptable.$$_hibernate_getInterceptor();
|
||||||
|
|
|
@ -120,7 +120,7 @@ public class SimpleUpdateTestWithLazyLoading {
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
stats.clear();
|
stats.clear();
|
||||||
Child loadedChild = session.load( Child.class, lastChildID );
|
Child loadedChild = session.getReference( Child.class, lastChildID );
|
||||||
|
|
||||||
final PersistentAttributeInterceptable interceptable = (PersistentAttributeInterceptable) loadedChild;
|
final PersistentAttributeInterceptable interceptable = (PersistentAttributeInterceptable) loadedChild;
|
||||||
final PersistentAttributeInterceptor interceptor = interceptable.$$_hibernate_getInterceptor();
|
final PersistentAttributeInterceptor interceptor = interceptable.$$_hibernate_getInterceptor();
|
||||||
|
@ -152,7 +152,7 @@ public class SimpleUpdateTestWithLazyLoading {
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
Child loadedChild = session.load( Child.class, lastChildID );
|
Child loadedChild = session.getReference( Child.class, lastChildID );
|
||||||
assertThat( loadedChild.getName(), is( updatedName ) );
|
assertThat( loadedChild.getName(), is( updatedName ) );
|
||||||
|
|
||||||
assertFalse( Hibernate.isInitialized( loadedChild.getRelatives() ) );
|
assertFalse( Hibernate.isInitialized( loadedChild.getRelatives() ) );
|
||||||
|
@ -168,7 +168,7 @@ public class SimpleUpdateTestWithLazyLoading {
|
||||||
scope.inTransaction( s -> {
|
scope.inTransaction( s -> {
|
||||||
final Statistics stats = scope.getSessionFactory().getStatistics();
|
final Statistics stats = scope.getSessionFactory().getStatistics();
|
||||||
stats.clear();
|
stats.clear();
|
||||||
Child loadedChild = s.load( Child.class, lastChildID );
|
Child loadedChild = s.getReference( Child.class, lastChildID );
|
||||||
|
|
||||||
loadedChild.setName( updatedName );
|
loadedChild.setName( updatedName );
|
||||||
|
|
||||||
|
@ -184,7 +184,7 @@ public class SimpleUpdateTestWithLazyLoading {
|
||||||
} );
|
} );
|
||||||
|
|
||||||
scope.inTransaction( s -> {
|
scope.inTransaction( s -> {
|
||||||
Child loadedChild = s.load( Child.class, lastChildID );
|
Child loadedChild = s.getReference( Child.class, lastChildID );
|
||||||
assertThat( Hibernate.isInitialized( loadedChild ), is( false ) );
|
assertThat( Hibernate.isInitialized( loadedChild ), is( false ) );
|
||||||
assertThat( loadedChild.getName(), is( updatedName ) );
|
assertThat( loadedChild.getName(), is( updatedName ) );
|
||||||
assertThat( Hibernate.isInitialized( loadedChild ), is( true ) );
|
assertThat( Hibernate.isInitialized( loadedChild ), is( true ) );
|
||||||
|
@ -199,7 +199,7 @@ public class SimpleUpdateTestWithLazyLoading {
|
||||||
scope.inTransaction( s -> {
|
scope.inTransaction( s -> {
|
||||||
final Statistics stats = scope.getSessionFactory().getStatistics();
|
final Statistics stats = scope.getSessionFactory().getStatistics();
|
||||||
stats.clear();
|
stats.clear();
|
||||||
Child loadedChild = s.load( Child.class, lastChildID );
|
Child loadedChild = s.getReference( Child.class, lastChildID );
|
||||||
|
|
||||||
|
|
||||||
assertEquals( 0, stats.getPrepareStatementCount() );
|
assertEquals( 0, stats.getPrepareStatementCount() );
|
||||||
|
@ -213,7 +213,7 @@ public class SimpleUpdateTestWithLazyLoading {
|
||||||
} );
|
} );
|
||||||
|
|
||||||
scope.inTransaction( s -> {
|
scope.inTransaction( s -> {
|
||||||
Child loadedChild = s.load( Child.class, lastChildID );
|
Child loadedChild = s.getReference( Child.class, lastChildID );
|
||||||
assertThat( loadedChild.getRelatives().size(), is( 2 ) );
|
assertThat( loadedChild.getRelatives().size(), is( 2 ) );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,7 +108,7 @@ public class SimpleUpdateTestWithLazyLoadingAndInlineDirtyTracking {
|
||||||
String updatedName = "Barrabas_";
|
String updatedName = "Barrabas_";
|
||||||
scope.inTransaction( s -> {
|
scope.inTransaction( s -> {
|
||||||
stats.clear();
|
stats.clear();
|
||||||
Child loadedChild = s.load( Child.class, lastChildID );
|
Child loadedChild = s.getReference( Child.class, lastChildID );
|
||||||
|
|
||||||
final PersistentAttributeInterceptable interceptable = (PersistentAttributeInterceptable) loadedChild;
|
final PersistentAttributeInterceptable interceptable = (PersistentAttributeInterceptable) loadedChild;
|
||||||
final PersistentAttributeInterceptor interceptor = interceptable.$$_hibernate_getInterceptor();
|
final PersistentAttributeInterceptor interceptor = interceptable.$$_hibernate_getInterceptor();
|
||||||
|
@ -124,7 +124,7 @@ public class SimpleUpdateTestWithLazyLoadingAndInlineDirtyTracking {
|
||||||
assertEquals( 2, stats.getPrepareStatementCount() );
|
assertEquals( 2, stats.getPrepareStatementCount() );
|
||||||
|
|
||||||
scope.inTransaction( s -> {
|
scope.inTransaction( s -> {
|
||||||
Child loadedChild = s.load( Child.class, lastChildID );
|
Child loadedChild = s.getReference( Child.class, lastChildID );
|
||||||
assertThat( loadedChild.getName(), is( updatedName ) );
|
assertThat( loadedChild.getName(), is( updatedName ) );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ public class SimpleUpdateTestWithLazyLoadingAndInlineDirtyTracking {
|
||||||
scope.inTransaction( s -> {
|
scope.inTransaction( s -> {
|
||||||
final Statistics stats = scope.getSessionFactory().getStatistics();
|
final Statistics stats = scope.getSessionFactory().getStatistics();
|
||||||
stats.clear();
|
stats.clear();
|
||||||
Child loadedChild = s.load( Child.class, lastChildID );
|
Child loadedChild = s.getReference( Child.class, lastChildID );
|
||||||
|
|
||||||
loadedChild.setName( updatedName );
|
loadedChild.setName( updatedName );
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ public class SimpleUpdateTestWithLazyLoadingAndInlineDirtyTracking {
|
||||||
} );
|
} );
|
||||||
|
|
||||||
scope.inTransaction( s -> {
|
scope.inTransaction( s -> {
|
||||||
Child loadedChild = s.load( Child.class, lastChildID );
|
Child loadedChild = s.getReference( Child.class, lastChildID );
|
||||||
assertThat( loadedChild.getName(), is( updatedName ) );
|
assertThat( loadedChild.getName(), is( updatedName ) );
|
||||||
assertThat( loadedChild.getParent().getName(), is( parentName ) );
|
assertThat( loadedChild.getParent().getName(), is( parentName ) );
|
||||||
} );
|
} );
|
||||||
|
@ -163,7 +163,7 @@ public class SimpleUpdateTestWithLazyLoadingAndInlineDirtyTracking {
|
||||||
scope.inTransaction( s -> {
|
scope.inTransaction( s -> {
|
||||||
final Statistics stats = scope.getSessionFactory().getStatistics();
|
final Statistics stats = scope.getSessionFactory().getStatistics();
|
||||||
stats.clear();
|
stats.clear();
|
||||||
Child loadedChild = s.load( Child.class, lastChildID );
|
Child loadedChild = s.getReference( Child.class, lastChildID );
|
||||||
|
|
||||||
assertEquals( 0, stats.getPrepareStatementCount() );
|
assertEquals( 0, stats.getPrepareStatementCount() );
|
||||||
Person relative = new Person();
|
Person relative = new Person();
|
||||||
|
@ -177,7 +177,7 @@ public class SimpleUpdateTestWithLazyLoadingAndInlineDirtyTracking {
|
||||||
} );
|
} );
|
||||||
|
|
||||||
scope.inTransaction( s -> {
|
scope.inTransaction( s -> {
|
||||||
Child loadedChild = s.load( Child.class, lastChildID );
|
Child loadedChild = s.getReference( Child.class, lastChildID );
|
||||||
assertThat( loadedChild.getRelatives().size(), is( 2 ) );
|
assertThat( loadedChild.getRelatives().size(), is( 2 ) );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,7 @@ public class SimpleUpdateWithLazyLoadingWithCollectionInDefaultFetchGroupFalseTe
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
stats.clear();
|
stats.clear();
|
||||||
Child loadedChild = session.load( Child.class, lastChildID );
|
Child loadedChild = session.getReference( Child.class, lastChildID );
|
||||||
|
|
||||||
final PersistentAttributeInterceptable interceptable = (PersistentAttributeInterceptable) loadedChild;
|
final PersistentAttributeInterceptable interceptable = (PersistentAttributeInterceptable) loadedChild;
|
||||||
final PersistentAttributeInterceptor interceptor = interceptable.$$_hibernate_getInterceptor();
|
final PersistentAttributeInterceptor interceptor = interceptable.$$_hibernate_getInterceptor();
|
||||||
|
@ -167,7 +167,7 @@ public class SimpleUpdateWithLazyLoadingWithCollectionInDefaultFetchGroupFalseTe
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
Child loadedChild = session.load( Child.class, lastChildID );
|
Child loadedChild = session.getReference( Child.class, lastChildID );
|
||||||
assertThat( loadedChild.getName(), is( updatedName ) );
|
assertThat( loadedChild.getName(), is( updatedName ) );
|
||||||
|
|
||||||
final EntityEntry entry = session.getPersistenceContext().getEntry( loadedChild );
|
final EntityEntry entry = session.getPersistenceContext().getEntry( loadedChild );
|
||||||
|
@ -187,7 +187,7 @@ public class SimpleUpdateWithLazyLoadingWithCollectionInDefaultFetchGroupFalseTe
|
||||||
scope.inTransaction( s -> {
|
scope.inTransaction( s -> {
|
||||||
final Statistics stats = scope.getSessionFactory().getStatistics();
|
final Statistics stats = scope.getSessionFactory().getStatistics();
|
||||||
stats.clear();
|
stats.clear();
|
||||||
Child loadedChild = s.load( Child.class, lastChildID );
|
Child loadedChild = s.getReference( Child.class, lastChildID );
|
||||||
|
|
||||||
loadedChild.setName( updatedName );
|
loadedChild.setName( updatedName );
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ public class SimpleUpdateWithLazyLoadingWithCollectionInDefaultFetchGroupFalseTe
|
||||||
} );
|
} );
|
||||||
|
|
||||||
scope.inTransaction( s -> {
|
scope.inTransaction( s -> {
|
||||||
Child loadedChild = s.load( Child.class, lastChildID );
|
Child loadedChild = s.getReference( Child.class, lastChildID );
|
||||||
assertThat( Hibernate.isInitialized( loadedChild ), is( false ) );
|
assertThat( Hibernate.isInitialized( loadedChild ), is( false ) );
|
||||||
assertThat( loadedChild.getName(), is( updatedName ) );
|
assertThat( loadedChild.getName(), is( updatedName ) );
|
||||||
assertThat( Hibernate.isInitialized( loadedChild ), is( true ) );
|
assertThat( Hibernate.isInitialized( loadedChild ), is( true ) );
|
||||||
|
@ -218,7 +218,7 @@ public class SimpleUpdateWithLazyLoadingWithCollectionInDefaultFetchGroupFalseTe
|
||||||
scope.inTransaction( s -> {
|
scope.inTransaction( s -> {
|
||||||
final Statistics stats = scope.getSessionFactory().getStatistics();
|
final Statistics stats = scope.getSessionFactory().getStatistics();
|
||||||
stats.clear();
|
stats.clear();
|
||||||
Child loadedChild = s.load( Child.class, lastChildID );
|
Child loadedChild = s.getReference( Child.class, lastChildID );
|
||||||
|
|
||||||
|
|
||||||
assertEquals( 0, stats.getPrepareStatementCount() );
|
assertEquals( 0, stats.getPrepareStatementCount() );
|
||||||
|
@ -232,7 +232,7 @@ public class SimpleUpdateWithLazyLoadingWithCollectionInDefaultFetchGroupFalseTe
|
||||||
} );
|
} );
|
||||||
|
|
||||||
scope.inTransaction( s -> {
|
scope.inTransaction( s -> {
|
||||||
Child loadedChild = s.load( Child.class, lastChildID );
|
Child loadedChild = s.getReference( Child.class, lastChildID );
|
||||||
assertThat( loadedChild.getRelatives().size(), is( 2 ) );
|
assertThat( loadedChild.getRelatives().size(), is( 2 ) );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ public class EntityWithMutableAttributesTest {
|
||||||
public void testLoad(SessionFactoryScope scope) {
|
public void testLoad(SessionFactoryScope scope) {
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
User user = session.load( User.class, 1 );
|
User user = session.getReference( User.class, 1 );
|
||||||
assertThat(
|
assertThat(
|
||||||
user, instanceOf( PersistentAttributeInterceptable.class )
|
user, instanceOf( PersistentAttributeInterceptable.class )
|
||||||
);
|
);
|
||||||
|
@ -117,7 +117,7 @@ public class EntityWithMutableAttributesTest {
|
||||||
public void testMutableAttributeIsUpdated(SessionFactoryScope scope) {
|
public void testMutableAttributeIsUpdated(SessionFactoryScope scope) {
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
User user = session.load( User.class, 1 );
|
User user = session.getReference( User.class, 1 );
|
||||||
user.getDate().setTime( 0 );
|
user.getDate().setTime( 0 );
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -83,7 +83,7 @@ public class OnDemandLoadTest {
|
||||||
|
|
||||||
scope.inTransaction( s -> {
|
scope.inTransaction( s -> {
|
||||||
// first load the store, making sure it is not initialized
|
// 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] );
|
assertNotNull( store[0] );
|
||||||
assertFalse( isPropertyInitialized( store[0], "inventories" ) );
|
assertFalse( isPropertyInitialized( store[0], "inventories" ) );
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,7 @@ public class OnDemandLoadWithCollectionInDefaultFetchGroupFalseTest {
|
||||||
|
|
||||||
scope.inTransaction( s -> {
|
scope.inTransaction( s -> {
|
||||||
// first load the store, making sure it is not initialized
|
// 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] );
|
assertNotNull( store[0] );
|
||||||
assertFalse( isPropertyInitialized( store[0], "inventories" ) );
|
assertFalse( isPropertyInitialized( store[0], "inventories" ) );
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class ByteCodeEnhancedImmutableReferenceCacheTest extends BaseCoreFunctio
|
||||||
s = openSession();
|
s = openSession();
|
||||||
s.beginTransaction();
|
s.beginTransaction();
|
||||||
// MyEnhancedReferenceData loaded = (MyEnhancedReferenceData) s.get( MyEnhancedReferenceData.class, 1 );
|
// 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.getTransaction().commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class CacheAnnotationTests extends BaseCoreFunctionalTestCase {
|
||||||
} );
|
} );
|
||||||
|
|
||||||
doInHibernate( this::sessionFactory, session -> {
|
doInHibernate( this::sessionFactory, session -> {
|
||||||
NoCacheConcurrencyStrategyEntity entity = session.load( NoCacheConcurrencyStrategyEntity.class, this.entityId );
|
NoCacheConcurrencyStrategyEntity entity = session.getReference( NoCacheConcurrencyStrategyEntity.class, this.entityId );
|
||||||
assertEquals( "name", entity.getName() );
|
assertEquals( "name", entity.getName() );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class ReferenceCacheTest extends BaseCoreFunctionalTestCase {
|
||||||
s = openSession();
|
s = openSession();
|
||||||
s.beginTransaction();
|
s.beginTransaction();
|
||||||
// MyReferenceData loaded = (MyReferenceData) s.get( MyReferenceData.class, 1 );
|
// 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.getTransaction().commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ public class MultiPathCascadeTest {
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
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 );
|
assertTrue( aLoaded instanceof HibernateProxy );
|
||||||
assertSame( aLoaded, session.merge( a ) );
|
assertSame( aLoaded, session.merge( a ) );
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class TempTest {
|
||||||
@AfterEach
|
@AfterEach
|
||||||
public void dropTestData(SessionFactoryScope scope) {
|
public void dropTestData(SessionFactoryScope scope) {
|
||||||
scope.inTransaction( (session) -> {
|
scope.inTransaction( (session) -> {
|
||||||
session.remove( session.load( Client.class, 1 ) );
|
session.remove( session.getReference( Client.class, 1 ) );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -113,8 +113,8 @@ public class EmbeddedCompositeIdTest {
|
||||||
session -> {
|
session -> {
|
||||||
Course ucid = new Course( "mat2000", "Monash", null );
|
Course ucid = new Course( "mat2000", "Monash", null );
|
||||||
Course cid = new Course( "eng5000", "BHS", null );
|
Course cid = new Course( "eng5000", "BHS", null );
|
||||||
Course luc = session.load( Course.class, ucid );
|
Course luc = session.getReference( Course.class, ucid );
|
||||||
Course lc = session.load( Course.class, cid );
|
Course lc = session.getReference( Course.class, cid );
|
||||||
assertFalse( Hibernate.isInitialized( luc ) );
|
assertFalse( Hibernate.isInitialized( luc ) );
|
||||||
assertFalse( Hibernate.isInitialized( lc ) );
|
assertFalse( Hibernate.isInitialized( lc ) );
|
||||||
assertEquals( UniversityCourse.class, Hibernate.getClass( luc ) );
|
assertEquals( UniversityCourse.class, Hibernate.getClass( luc ) );
|
||||||
|
|
|
@ -51,8 +51,8 @@ public class MappedByEmbeddableTest extends BaseCoreFunctionalTestCase {
|
||||||
} );
|
} );
|
||||||
|
|
||||||
inTransaction( session -> {
|
inTransaction( session -> {
|
||||||
Containing containing1 = session.load( Containing.class, 1 );
|
Containing containing1 = session.getReference( Containing.class, 1 );
|
||||||
Containing containing2 = session.load( Containing.class, 2 );
|
Containing containing2 = session.getReference( Containing.class, 2 );
|
||||||
|
|
||||||
Embed embed1 = containing1.getEmbed();
|
Embed embed1 = containing1.getEmbed();
|
||||||
Embed embed2 = containing2.getEmbed();
|
Embed embed2 = containing2.getEmbed();
|
||||||
|
@ -117,7 +117,7 @@ public class MappedByEmbeddableTest extends BaseCoreFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadContaining(Session session, Integer containingId, Integer containedId) {
|
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();
|
Containing containing = contained.getContaining();
|
||||||
|
|
||||||
assertThat( containing.getId() ).isEqualTo( containingId );
|
assertThat( containing.getId() ).isEqualTo( containingId );
|
||||||
|
|
|
@ -114,7 +114,7 @@ public class DynamicFilterTest extends BaseNonConfigCoreFunctionalTestCase {
|
||||||
CollectionCacheEntry cachedData = fromSession(
|
CollectionCacheEntry cachedData = fromSession(
|
||||||
session -> {
|
session -> {
|
||||||
// Force a collection into the second level cache, with its non-filtered elements
|
// 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() );
|
Hibernate.initialize( sp.getOrders() );
|
||||||
assertTrue( "No cache for collection", persister.hasCache() );
|
assertTrue( "No cache for collection", persister.hasCache() );
|
||||||
Object cacheKey = cache.generateCacheKey(
|
Object cacheKey = cache.generateCacheKey(
|
||||||
|
@ -156,7 +156,7 @@ public class DynamicFilterTest extends BaseNonConfigCoreFunctionalTestCase {
|
||||||
inSession(
|
inSession(
|
||||||
session -> {
|
session -> {
|
||||||
session.enableFilter( "fulfilledOrders" ).setParameter( "asOfDate", testData.lastMonth.getTime() );
|
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() );
|
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
|
// Finally, make sure that the original cached version did not get over-written
|
||||||
inSession(
|
inSession(
|
||||||
session -> {
|
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() );
|
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() );
|
.setParameter( "asOfDate", testData.lastMonth.getTime() );
|
||||||
|
|
||||||
log.info( "Performing load of Department..." );
|
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();
|
Set salespersons = department.getSalespersons();
|
||||||
assertEquals( "Incorrect salesperson count", 1, salespersons.size() );
|
assertEquals( "Incorrect salesperson count", 1, salespersons.size() );
|
||||||
|
|
||||||
|
|
|
@ -58,9 +58,9 @@ public class TestClearBatchFetchQueueAfterFlush extends BaseCoreFunctionalTestCa
|
||||||
s.getTransaction().commit();
|
s.getTransaction().commit();
|
||||||
s.clear();
|
s.clear();
|
||||||
|
|
||||||
bookStore1 = s.load( BookStore.class, bookStore1.getId() );
|
bookStore1 = s.getReference( BookStore.class, bookStore1.getId() );
|
||||||
bookStore2 = s.load( BookStore.class, bookStore2.getId() );
|
bookStore2 = s.getReference( BookStore.class, bookStore2.getId() );
|
||||||
bookStore3 = s.load( BookStore.class, bookStore3.getId() );
|
bookStore3 = s.getReference( BookStore.class, bookStore3.getId() );
|
||||||
|
|
||||||
s.beginTransaction();
|
s.beginTransaction();
|
||||||
s.remove( bookStore2 );
|
s.remove( bookStore2 );
|
||||||
|
|
|
@ -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.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.getTransaction().commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
@ -2127,7 +2127,7 @@ public class ASTParserLoadingTest extends BaseCoreFunctionalTestCase {
|
||||||
s.persist( plat );
|
s.persist( plat );
|
||||||
s.flush();
|
s.flush();
|
||||||
s.clear();
|
s.clear();
|
||||||
plat = (Mammal) s.load(Mammal.class, plat.getId() );
|
plat = (Mammal) s.getReference(Mammal.class, plat.getId() );
|
||||||
assertFalse( Hibernate.isInitialized(plat) );
|
assertFalse( Hibernate.isInitialized(plat) );
|
||||||
Object plat2 = s.createQuery("from Animal a").uniqueResult();
|
Object plat2 = s.createQuery("from Animal a").uniqueResult();
|
||||||
assertSame( plat, plat2 );
|
assertSame( plat, plat2 );
|
||||||
|
@ -2941,7 +2941,7 @@ public class ASTParserLoadingTest extends BaseCoreFunctionalTestCase {
|
||||||
Transaction txn = session.beginTransaction();
|
Transaction txn = session.beginTransaction();
|
||||||
|
|
||||||
for ( Long createdAnimalId : createdAnimalIds ) {
|
for ( Long createdAnimalId : createdAnimalIds ) {
|
||||||
Animal animal = session.load( Animal.class, createdAnimalId );
|
Animal animal = session.getReference( Animal.class, createdAnimalId );
|
||||||
session.remove( animal );
|
session.remove( animal );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -859,7 +859,7 @@ public class BulkManipulationTest extends BaseCoreFunctionalTestCase {
|
||||||
t.commit();
|
t.commit();
|
||||||
|
|
||||||
t = s.beginTransaction();
|
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() );
|
assertEquals( "version not incremented", initialVersion + 1, entity.getVersion() );
|
||||||
|
|
||||||
s.remove( entity );
|
s.remove( entity );
|
||||||
|
@ -894,7 +894,7 @@ public class BulkManipulationTest extends BaseCoreFunctionalTestCase {
|
||||||
t.commit();
|
t.commit();
|
||||||
|
|
||||||
t = s.beginTransaction();
|
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 ) );
|
assertTrue( "version not incremented", entity.getVersion().after( initialVersion ) );
|
||||||
|
|
||||||
s.remove( entity );
|
s.remove( entity );
|
||||||
|
@ -1035,7 +1035,7 @@ public class BulkManipulationTest extends BaseCoreFunctionalTestCase {
|
||||||
.executeUpdate();
|
.executeUpdate();
|
||||||
assertEquals( "Incorrect entity-updated count", 1, count );
|
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() );
|
assertEquals( "Update did not take effect", "Tadpole", tadpole.getDescription() );
|
||||||
|
|
||||||
count = s.createQuery( "update Animal set bodyWeight = bodyWeight + :w1 + :w2" )
|
count = s.createQuery( "update Animal set bodyWeight = bodyWeight + :w1 + :w2" )
|
||||||
|
|
|
@ -115,7 +115,7 @@ public class WithClauseTest {
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
(session) -> {
|
(session) -> {
|
||||||
List list = session.createQuery( "from Human h inner join h.offspring o with o.mother.father = :cousin" )
|
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();
|
.list();
|
||||||
assertTrue( list.isEmpty(), "ad-hoc did take effect" );
|
assertTrue( list.isEmpty(), "ad-hoc did take effect" );
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,16 +56,16 @@ public class IdBagTest {
|
||||||
criteria.from( User.class );
|
criteria.from( User.class );
|
||||||
User gavin = s.createQuery( criteria ).uniqueResult();
|
User gavin = s.createQuery( criteria ).uniqueResult();
|
||||||
// User gavin = (User) s.createCriteria( User.class ).uniqueResult();
|
// User gavin = (User) s.createCriteria( User.class ).uniqueResult();
|
||||||
Group admins = s.load( Group.class, "admins" );
|
Group admins = s.getReference( Group.class, "admins" );
|
||||||
Group plebs = s.load( Group.class, "plebs" );
|
Group plebs = s.getReference( Group.class, "plebs" );
|
||||||
Group banned = s.load( Group.class, "banned" );
|
Group banned = s.getReference( Group.class, "banned" );
|
||||||
gavin.getGroups().add( admins );
|
gavin.getGroups().add( admins );
|
||||||
gavin.getGroups().remove( plebs );
|
gavin.getGroups().remove( plebs );
|
||||||
//gavin.getGroups().add(banned);
|
//gavin.getGroups().add(banned);
|
||||||
|
|
||||||
s.remove( plebs );
|
s.remove( plebs );
|
||||||
s.remove( banned );
|
s.remove( banned );
|
||||||
s.remove( s.load( Group.class, "moderators" ) );
|
s.remove( s.getReference( Group.class, "moderators" ) );
|
||||||
s.remove( admins );
|
s.remove( admins );
|
||||||
s.remove( gavin );
|
s.remove( gavin );
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,7 @@ public class ImmutableTest extends BaseSessionFactoryFunctionalTest {
|
||||||
s -> {
|
s -> {
|
||||||
s.beginTransaction();
|
s.beginTransaction();
|
||||||
try {
|
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();
|
// Contract c = (Contract) s.createCriteria(Contract.class).uniqueResult();
|
||||||
assertTrue( s.isReadOnly( c ) );
|
assertTrue( s.isReadOnly( c ) );
|
||||||
assertEquals( "gavin", c.getCustomerName() );
|
assertEquals( "gavin", c.getCustomerName() );
|
||||||
|
@ -161,7 +161,7 @@ public class ImmutableTest extends BaseSessionFactoryFunctionalTest {
|
||||||
|
|
||||||
inSession(
|
inSession(
|
||||||
s -> {
|
s -> {
|
||||||
Contract c = s.load( Contract.class, contract.getId() );
|
Contract c = s.getReference( Contract.class, contract.getId() );
|
||||||
assertTrue( s.isReadOnly( c ) );
|
assertTrue( s.isReadOnly( c ) );
|
||||||
assertEquals( "gavin", c.getCustomerName() );
|
assertEquals( "gavin", c.getCustomerName() );
|
||||||
assertEquals( 2, c.getVariations().size() );
|
assertEquals( 2, c.getVariations().size() );
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class InsertOrderingWithCascadeOnPersist {
|
||||||
// This block resulted in a Foreign Key ConstraintViolation because the inserts were ordered incorrectly.
|
// This block resulted in a Foreign Key ConstraintViolation because the inserts were ordered incorrectly.
|
||||||
scope.inTransaction( session -> {
|
scope.inTransaction( session -> {
|
||||||
// Add marketResult to existing Bid
|
// 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();
|
final MarketResult result = new MarketResult();
|
||||||
result.setMarketBid( bid );
|
result.setMarketBid( bid );
|
||||||
session.persist( result );
|
session.persist( result );
|
||||||
|
|
|
@ -279,7 +279,7 @@ public class InterceptorTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
merged.setInjectedString( null );
|
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
|
// the session-bound instance was not instantiated by the interceptor, load simply returns it
|
||||||
assertSame( merged, loaded );
|
assertSame( merged, loaded );
|
||||||
assertNull( merged.getInjectedString() );
|
assertNull( merged.getInjectedString() );
|
||||||
|
@ -288,7 +288,7 @@ public class InterceptorTest extends BaseCoreFunctionalTestCase {
|
||||||
s.flush();
|
s.flush();
|
||||||
s.evict( merged );
|
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
|
// Interceptor IS called for instantiating the persistent instance associated to the session when using load
|
||||||
assertEquals( injectedString, reloaded.getInjectedString() );
|
assertEquals( injectedString, reloaded.getInjectedString() );
|
||||||
assertEquals( u.getName(), reloaded.getName() );
|
assertEquals( u.getName(), reloaded.getName() );
|
||||||
|
|
|
@ -69,24 +69,24 @@ public class InterfaceProxyTest {
|
||||||
try (Session session = openSession( scope )) {
|
try (Session session = openSession( scope )) {
|
||||||
session.beginTransaction();
|
session.beginTransaction();
|
||||||
try {
|
try {
|
||||||
Document d = (Document) session.load( ItemImpl.class, did );
|
Document d = (Document) session.getReference( ItemImpl.class, did );
|
||||||
assertEquals( did, d.getId() );
|
assertEquals( did, d.getId() );
|
||||||
assertEquals( "Hibernate in Action", d.getName() );
|
assertEquals( "Hibernate in Action", d.getName() );
|
||||||
assertNotNull( d.getContent() );
|
assertNotNull( d.getContent() );
|
||||||
|
|
||||||
SecureDocument d2 = (SecureDocument) session.load( ItemImpl.class, d2id );
|
SecureDocument d2 = (SecureDocument) session.getReference( ItemImpl.class, d2id );
|
||||||
assertEquals( d2id, d2.getId() );
|
assertEquals( d2id, d2.getId() );
|
||||||
assertEquals( "Secret", d2.getName() );
|
assertEquals( "Secret", d2.getName() );
|
||||||
assertNotNull( d2.getContent() );
|
assertNotNull( d2.getContent() );
|
||||||
|
|
||||||
session.clear();
|
session.clear();
|
||||||
|
|
||||||
d = session.load( DocumentImpl.class, did );
|
d = session.getReference( DocumentImpl.class, did );
|
||||||
assertEquals( did, d.getId() );
|
assertEquals( did, d.getId() );
|
||||||
assertEquals( "Hibernate in Action", d.getName() );
|
assertEquals( "Hibernate in Action", d.getName() );
|
||||||
assertNotNull( d.getContent() );
|
assertNotNull( d.getContent() );
|
||||||
|
|
||||||
d2 = session.load( SecureDocumentImpl.class, d2id );
|
d2 = session.getReference( SecureDocumentImpl.class, d2id );
|
||||||
assertEquals( d2id, d2.getId() );
|
assertEquals( d2id, d2.getId() );
|
||||||
assertEquals( "Secret", d2.getName() );
|
assertEquals( "Secret", d2.getName() );
|
||||||
assertNotNull( d2.getContent() );
|
assertNotNull( d2.getContent() );
|
||||||
|
@ -94,7 +94,7 @@ public class InterfaceProxyTest {
|
||||||
|
|
||||||
//s.clear();
|
//s.clear();
|
||||||
|
|
||||||
d2 = session.load( SecureDocumentImpl.class, did );
|
d2 = session.getReference( SecureDocumentImpl.class, did );
|
||||||
assertEquals( did, d2.getId() );
|
assertEquals( did, d2.getId() );
|
||||||
assertEquals( "Hibernate in Action", d2.getName() );
|
assertEquals( "Hibernate in Action", d2.getName() );
|
||||||
assertNotNull( d2.getContent() );
|
assertNotNull( d2.getContent() );
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class GetLoadJpaComplianceTest {
|
||||||
|
|
||||||
assertNull( s.get( Workload.class, 999 ) );
|
assertNull( s.get( Workload.class, 999 ) );
|
||||||
|
|
||||||
Workload proxy = s.load( Workload.class, 999 );
|
Workload proxy = s.getReference( Workload.class, 999 );
|
||||||
assertFalse( Hibernate.isInitialized( proxy ) );
|
assertFalse( Hibernate.isInitialized( proxy ) );
|
||||||
|
|
||||||
proxy.getId();
|
proxy.getId();
|
||||||
|
@ -103,7 +103,7 @@ public class GetLoadJpaComplianceTest {
|
||||||
|
|
||||||
assertNull( s.get( Employee.class, 999 ) );
|
assertNull( s.get( Employee.class, 999 ) );
|
||||||
|
|
||||||
Employee proxy = s.load( Employee.class, 999 );
|
Employee proxy = s.getReference( Employee.class, 999 );
|
||||||
assertFalse( Hibernate.isInitialized( proxy ) );
|
assertFalse( Hibernate.isInitialized( proxy ) );
|
||||||
|
|
||||||
proxy.getId();
|
proxy.getId();
|
||||||
|
|
|
@ -126,10 +126,10 @@ public class GetLoadTest {
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
entityManager -> {
|
entityManager -> {
|
||||||
Session s = ( Session ) entityManager.getDelegate();
|
Session s = ( Session ) entityManager.getDelegate();
|
||||||
Employer emp = s.load( Employer.class, empId );
|
Employer emp = s.getReference( Employer.class, empId );
|
||||||
emp.getId();
|
emp.getId();
|
||||||
assertFalse( Hibernate.isInitialized( emp ) );
|
assertFalse( Hibernate.isInitialized( emp ) );
|
||||||
Node node = s.load( Node.class, nodeName );
|
Node node = s.getReference( Node.class, nodeName );
|
||||||
assertEquals( node.getName(), nodeName );
|
assertEquals( node.getName(), nodeName );
|
||||||
assertFalse( Hibernate.isInitialized( node ) );
|
assertFalse( Hibernate.isInitialized( node ) );
|
||||||
}
|
}
|
||||||
|
@ -138,10 +138,10 @@ public class GetLoadTest {
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
entityManager -> {
|
entityManager -> {
|
||||||
Session s = ( Session ) entityManager.getDelegate();
|
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();
|
emp.getId();
|
||||||
assertFalse( Hibernate.isInitialized( emp ) );
|
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 );
|
assertEquals( node.getName(), nodeName );
|
||||||
assertFalse( Hibernate.isInitialized( node ) );
|
assertFalse( Hibernate.isInitialized( node ) );
|
||||||
}
|
}
|
||||||
|
@ -195,7 +195,7 @@ public class GetLoadTest {
|
||||||
entityManager -> {
|
entityManager -> {
|
||||||
Session s = ( Session ) entityManager.getDelegate();
|
Session s = ( Session ) entityManager.getDelegate();
|
||||||
|
|
||||||
Workload proxy = s.load(Workload.class, workload.id);
|
Workload proxy = s.getReference(Workload.class, workload.id);
|
||||||
proxy.getId();
|
proxy.getId();
|
||||||
|
|
||||||
assertFalse( Hibernate.isInitialized( proxy ) );
|
assertFalse( Hibernate.isInitialized( proxy ) );
|
||||||
|
@ -218,7 +218,7 @@ public class GetLoadTest {
|
||||||
|
|
||||||
assertNull( s.get( Workload.class, 999 ) );
|
assertNull( s.get( Workload.class, 999 ) );
|
||||||
|
|
||||||
Workload proxy = s.load( Workload.class, 999 );
|
Workload proxy = s.getReference( Workload.class, 999 );
|
||||||
assertFalse( Hibernate.isInitialized( proxy ) );
|
assertFalse( Hibernate.isInitialized( proxy ) );
|
||||||
|
|
||||||
proxy.getId();
|
proxy.getId();
|
||||||
|
@ -263,7 +263,7 @@ public class GetLoadTest {
|
||||||
|
|
||||||
assertNull( s.get( Employee.class, 999 ) );
|
assertNull( s.get( Employee.class, 999 ) );
|
||||||
|
|
||||||
Employee proxy = s.load( Employee.class, 999 );
|
Employee proxy = s.getReference( Employee.class, 999 );
|
||||||
assertFalse( Hibernate.isInitialized( proxy ) );
|
assertFalse( Hibernate.isInitialized( proxy ) );
|
||||||
|
|
||||||
proxy.getId();
|
proxy.getId();
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class JPAProxyTest extends AbstractJPATest {
|
||||||
public void testEjb3ProxyUsage() {
|
public void testEjb3ProxyUsage() {
|
||||||
inTransaction(
|
inTransaction(
|
||||||
s -> {
|
s -> {
|
||||||
Item item = s.load( Item.class, new Long( -1 ) );
|
Item item = s.getReference( Item.class, new Long( -1 ) );
|
||||||
assertFalse( Hibernate.isInitialized( item ) );
|
assertFalse( Hibernate.isInitialized( item ) );
|
||||||
try {
|
try {
|
||||||
Hibernate.initialize( item );
|
Hibernate.initialize( item );
|
||||||
|
@ -47,7 +47,7 @@ public class JPAProxyTest extends AbstractJPATest {
|
||||||
|
|
||||||
s.clear();
|
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( Hibernate.isInitialized( item2 ) );
|
||||||
assertFalse( item == item2 );
|
assertFalse( item == item2 );
|
||||||
try {
|
try {
|
||||||
|
@ -80,7 +80,7 @@ public class JPAProxyTest extends AbstractJPATest {
|
||||||
inTransaction(
|
inTransaction(
|
||||||
s -> {
|
s -> {
|
||||||
// first load() it to generate a proxy...
|
// 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 ) );
|
assertFalse( Hibernate.isInitialized( item ) );
|
||||||
// then try to get() it to make sure we get an exception
|
// then try to get() it to make sure we get an exception
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class JpaSpecVersionValueUpdatingTest extends BaseCoreFunctionalTestCase
|
||||||
|
|
||||||
session = openSession();
|
session = openSession();
|
||||||
session.beginTransaction();
|
session.beginTransaction();
|
||||||
customer = session.load( Customer.class, 1L );
|
customer = session.getReference( Customer.class, 1L );
|
||||||
assertEquals( initial, customer.version );
|
assertEquals( initial, customer.version );
|
||||||
session.remove( customer );
|
session.remove( customer );
|
||||||
session.getTransaction().commit();
|
session.getTransaction().commit();
|
||||||
|
@ -113,7 +113,7 @@ public class JpaSpecVersionValueUpdatingTest extends BaseCoreFunctionalTestCase
|
||||||
|
|
||||||
session = openSession();
|
session = openSession();
|
||||||
session.beginTransaction();
|
session.beginTransaction();
|
||||||
customer = session.load( Customer.class, 1L );
|
customer = session.getReference( Customer.class, 1L );
|
||||||
assertEquals( initial, customer.version );
|
assertEquals( initial, customer.version );
|
||||||
session.remove( customer );
|
session.remove( customer );
|
||||||
session.getTransaction().commit();
|
session.getTransaction().commit();
|
||||||
|
|
|
@ -65,7 +65,7 @@ public class LazyPersistWithDetachedAssociationTest {
|
||||||
Address loadedAddress = scope.fromTransaction(
|
Address loadedAddress = scope.fromTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
// first load the address
|
// first load the address
|
||||||
Address _loadedAddress = session.load(
|
Address _loadedAddress = session.getReference(
|
||||||
Address.class,
|
Address.class,
|
||||||
1L
|
1L
|
||||||
);
|
);
|
||||||
|
|
|
@ -79,7 +79,7 @@ public class AtomikosJtaLazyLoadingTest {
|
||||||
public void testLazyCollectionLoadingAfterEndTransaction(SessionFactoryScope scope) {
|
public void testLazyCollectionLoadingAfterEndTransaction(SessionFactoryScope scope) {
|
||||||
Parent loadedParent = scope.fromTransaction(
|
Parent loadedParent = scope.fromTransaction(
|
||||||
session ->
|
session ->
|
||||||
session.load( Parent.class, parentID )
|
session.getReference( Parent.class, parentID )
|
||||||
);
|
);
|
||||||
|
|
||||||
assertFalse( Hibernate.isInitialized( loadedParent.getChildren() ) );
|
assertFalse( Hibernate.isInitialized( loadedParent.getChildren() ) );
|
||||||
|
@ -94,7 +94,7 @@ public class AtomikosJtaLazyLoadingTest {
|
||||||
|
|
||||||
Child loadedChild = scope.fromTransaction(
|
Child loadedChild = scope.fromTransaction(
|
||||||
session ->
|
session ->
|
||||||
session.load( Child.class, lastChildID )
|
session.getReference( Child.class, lastChildID )
|
||||||
);
|
);
|
||||||
|
|
||||||
Parent p = loadedChild.getParent();
|
Parent p = loadedChild.getParent();
|
||||||
|
|
|
@ -79,7 +79,7 @@ public class JtaLazyLoadingTest {
|
||||||
public void testLazyCollectionLoadingAfterEndTransaction(SessionFactoryScope scope) {
|
public void testLazyCollectionLoadingAfterEndTransaction(SessionFactoryScope scope) {
|
||||||
Parent loadedParent = scope.fromTransaction(
|
Parent loadedParent = scope.fromTransaction(
|
||||||
session ->
|
session ->
|
||||||
session.load( Parent.class, parentID )
|
session.getReference( Parent.class, parentID )
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ public class JtaLazyLoadingTest {
|
||||||
|
|
||||||
Child loadedChild = scope.fromTransaction(
|
Child loadedChild = scope.fromTransaction(
|
||||||
session ->
|
session ->
|
||||||
session.load( Child.class, lastChildID )
|
session.getReference( Child.class, lastChildID )
|
||||||
);
|
);
|
||||||
|
|
||||||
Parent p = loadedChild.getParent();
|
Parent p = loadedChild.getParent();
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class LazyLoadingLoggingTest {
|
||||||
public void testNoSession(SessionFactoryScope scope) {
|
public void testNoSession(SessionFactoryScope scope) {
|
||||||
Address address = scope.fromTransaction(
|
Address address = scope.fromTransaction(
|
||||||
session ->
|
session ->
|
||||||
session.load( Address.class, 1L )
|
session.getReference( Address.class, 1L )
|
||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -93,7 +93,7 @@ public class LazyLoadingLoggingTest {
|
||||||
public void testDisconnect(SessionFactoryScope scope) {
|
public void testDisconnect(SessionFactoryScope scope) {
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
Address address = session.load( Address.class, 1L );
|
Address address = session.getReference( Address.class, 1L );
|
||||||
AbstractSharedSessionContract sessionContract = (AbstractSharedSessionContract) session;
|
AbstractSharedSessionContract sessionContract = (AbstractSharedSessionContract) session;
|
||||||
sessionContract.getJdbcCoordinator().close();
|
sessionContract.getJdbcCoordinator().close();
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class LazyLoadingNotFoundTest {
|
||||||
@TestForIssue(jiraKey = "HHH-11179")
|
@TestForIssue(jiraKey = "HHH-11179")
|
||||||
public void testNonExistentLazyInitOutsideTransaction(SessionFactoryScope scope) {
|
public void testNonExistentLazyInitOutsideTransaction(SessionFactoryScope scope) {
|
||||||
Child loadedChild = scope.fromTransaction(
|
Child loadedChild = scope.fromTransaction(
|
||||||
session -> session.load( Child.class, -1L )
|
session -> session.getReference( Child.class, -1L )
|
||||||
);
|
);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -84,7 +84,7 @@ public class LazyLoadingTest {
|
||||||
public void testLazyCollectionLoadingAfterEndTransaction(SessionFactoryScope scope) {
|
public void testLazyCollectionLoadingAfterEndTransaction(SessionFactoryScope scope) {
|
||||||
Parent loadedParent = scope.fromTransaction(
|
Parent loadedParent = scope.fromTransaction(
|
||||||
session ->
|
session ->
|
||||||
session.load( Parent.class, parentID )
|
session.getReference( Parent.class, parentID )
|
||||||
);
|
);
|
||||||
|
|
||||||
assertFalse( Hibernate.isInitialized( loadedParent.getChildren() ) );
|
assertFalse( Hibernate.isInitialized( loadedParent.getChildren() ) );
|
||||||
|
@ -99,7 +99,7 @@ public class LazyLoadingTest {
|
||||||
|
|
||||||
Child loadedChild = scope.fromTransaction(
|
Child loadedChild = scope.fromTransaction(
|
||||||
sesison ->
|
sesison ->
|
||||||
sesison.load( Child.class, lastChildID )
|
sesison.getReference( Child.class, lastChildID )
|
||||||
);
|
);
|
||||||
|
|
||||||
Parent p = loadedChild.getParent();
|
Parent p = loadedChild.getParent();
|
||||||
|
@ -167,7 +167,7 @@ public class LazyLoadingTest {
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
Account account = session.load( Account.class, accountId );
|
Account account = session.getReference( Account.class, accountId );
|
||||||
Client client = account.getClient();
|
Client client = account.getClient();
|
||||||
client.getId();
|
client.getId();
|
||||||
assertThat( Hibernate.isInitialized( client ), is( false ) );
|
assertThat( Hibernate.isInitialized( client ), is( false ) );
|
||||||
|
|
|
@ -140,7 +140,7 @@ public class ABCTest {
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
C1 c1 = session.load( C1.class, c.getId() );
|
C1 c1 = session.getReference( C1.class, c.getId() );
|
||||||
assertTrue(
|
assertTrue(
|
||||||
c1.getAddress().equals( "foo bar" ) &&
|
c1.getAddress().equals( "foo bar" ) &&
|
||||||
( c1.getCount() == 23432 ) &&
|
( c1.getCount() == 23432 ) &&
|
||||||
|
|
|
@ -145,7 +145,7 @@ public class Qux implements Lifecycle {
|
||||||
public Qux getChild() throws HibernateException, SQLException {
|
public Qux getChild() throws HibernateException, SQLException {
|
||||||
store =true;
|
store =true;
|
||||||
this.childKey = child==null ? null : child.getKey();
|
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;
|
return child;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class LoadContainedInDoubleContainingTest {
|
||||||
@Test
|
@Test
|
||||||
public void test(SessionFactoryScope scope) {
|
public void test(SessionFactoryScope scope) {
|
||||||
scope.inTransaction( session -> {
|
scope.inTransaction( session -> {
|
||||||
OtherContained otherContained = session.load( OtherContained.class, 2 );
|
OtherContained otherContained = session.getReference( OtherContained.class, 2 );
|
||||||
String text = otherContained.getText();
|
String text = otherContained.getText();
|
||||||
assertThat( text ).isEqualTo( "initial" );
|
assertThat( text ).isEqualTo( "initial" );
|
||||||
} );
|
} );
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class LoadParentChildEntityTest {
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
ContainingEntity load = session.load( ContainingEntity.class, 1 );
|
ContainingEntity load = session.getReference( ContainingEntity.class, 1 );
|
||||||
assertThat( load.getChild() ).isNotNull();
|
assertThat( load.getChild() ).isNotNull();
|
||||||
assertThat( load.getParent() ).isNull();
|
assertThat( load.getParent() ).isNull();
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ public class LoadParentChildEntityTest {
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
ContainingEntity load = session.load( ContainingEntity.class, 2 );
|
ContainingEntity load = session.getReference( ContainingEntity.class, 2 );
|
||||||
assertThat( load.getParent() ).isNotNull();
|
assertThat( load.getParent() ).isNotNull();
|
||||||
assertThat( load.getChild() ).isNull();
|
assertThat( load.getChild() ).isNull();
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,13 +121,13 @@ public class MultiLoadTest {
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
// delete one of them (but do not flush)...
|
// 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 );
|
session.remove( s4 );
|
||||||
|
|
||||||
assertFalse( Hibernate.isInitialized( s4 ) );
|
assertFalse( Hibernate.isInitialized( s4 ) );
|
||||||
|
|
||||||
// as a baseline, assert based on how load() handles it
|
// 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 );
|
assertNotNull( s5 );
|
||||||
assertFalse( Hibernate.isInitialized( s5 ) );
|
assertFalse( Hibernate.isInitialized( s5 ) );
|
||||||
}
|
}
|
||||||
|
@ -140,12 +140,12 @@ public class MultiLoadTest {
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
// delete one of them (but do not flush)...
|
// 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 );
|
Hibernate.initialize( s4 );
|
||||||
session.remove( s4 );
|
session.remove( s4 );
|
||||||
|
|
||||||
// as a baseline, assert based on how load() handles it
|
// 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 );
|
assertNotNull( s5 );
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -157,7 +157,7 @@ public class MultiLoadTest {
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
// delete one of them (but do not flush)...
|
// 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 );
|
Hibernate.initialize( s4 );
|
||||||
session.remove( s4 );
|
session.remove( s4 );
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ public class MultiLoadTest {
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
// delete one of them (but do not flush)...
|
// 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 );
|
Hibernate.initialize( s4 );
|
||||||
session.remove( s4 );
|
session.remove( s4 );
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ public class MultiLoadTest {
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
// delete one of them (but do not flush)...
|
// 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
|
// and then, assert how get() handles it
|
||||||
SimpleEntity s5 = session.get( SimpleEntity.class, 5 );
|
SimpleEntity s5 = session.get( SimpleEntity.class, 5 );
|
||||||
|
@ -249,7 +249,7 @@ public class MultiLoadTest {
|
||||||
public void testBasicMultiLoadWithManagedAndNoChecking(SessionFactoryScope scope) {
|
public void testBasicMultiLoadWithManagedAndNoChecking(SessionFactoryScope scope) {
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
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 ) );
|
List<SimpleEntity> list = session.byMultipleIds( SimpleEntity.class ).multiLoad( ids( 56 ) );
|
||||||
assertEquals( 56, list.size() );
|
assertEquals( 56, list.size() );
|
||||||
// this check is HIGHLY specific to implementation in the batch loader
|
// this check is HIGHLY specific to implementation in the batch loader
|
||||||
|
@ -263,7 +263,7 @@ public class MultiLoadTest {
|
||||||
public void testBasicMultiLoadWithManagedAndChecking(SessionFactoryScope scope) {
|
public void testBasicMultiLoadWithManagedAndChecking(SessionFactoryScope scope) {
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
SimpleEntity first = session.byId( SimpleEntity.class ).load( 1 );
|
SimpleEntity first = session.byId( SimpleEntity.class ).getReference( 1 );
|
||||||
List<SimpleEntity> list = session.byMultipleIds( SimpleEntity.class )
|
List<SimpleEntity> list = session.byMultipleIds( SimpleEntity.class )
|
||||||
.enableSessionCheck( true )
|
.enableSessionCheck( true )
|
||||||
.multiLoad( ids( 56 ) );
|
.multiLoad( ids( 56 ) );
|
||||||
|
|
|
@ -75,7 +75,7 @@ public class MapOperationTests {
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
final EntityOfMaps entity = session.load( EntityOfMaps.class, 1 );
|
final EntityOfMaps entity = session.getReference( EntityOfMaps.class, 1 );
|
||||||
session.remove( entity );
|
session.remove( entity );
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -88,7 +88,7 @@ public class SetOperationTests {
|
||||||
public void testLoad(SessionFactoryScope scope) {
|
public void testLoad(SessionFactoryScope scope) {
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
final EntityOfSets entity = session.load( EntityOfSets.class, 1 );
|
final EntityOfSets entity = session.getReference( EntityOfSets.class, 1 );
|
||||||
assertThat( entity, notNullValue() );
|
assertThat( entity, notNullValue() );
|
||||||
assertThat( entity, isNotInitialized() );
|
assertThat( entity, isNotInitialized() );
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ public class SetOperationTests {
|
||||||
public void testDeleteWithElementCollectionData(SessionFactoryScope scope) {
|
public void testDeleteWithElementCollectionData(SessionFactoryScope scope) {
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
final EntityOfSets entity = session.load( EntityOfSets.class, 1 );
|
final EntityOfSets entity = session.getReference( EntityOfSets.class, 1 );
|
||||||
session.remove( entity );
|
session.remove( entity );
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -489,7 +489,7 @@ public class AttributeConverterTest extends BaseUnitTestCase {
|
||||||
|
|
||||||
s = sf.openSession();
|
s = sf.openSession();
|
||||||
s.beginTransaction();
|
s.beginTransaction();
|
||||||
entity = s.load( EntityWithConvertibleField.class, entityID );
|
entity = s.getReference( EntityWithConvertibleField.class, entityID );
|
||||||
assertEquals( ConvertibleEnum.VALUE, entity.getConvertibleEnum() );
|
assertEquals( ConvertibleEnum.VALUE, entity.getConvertibleEnum() );
|
||||||
s.getTransaction().commit();
|
s.getTransaction().commit();
|
||||||
s.close();
|
s.close();
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class ElementCollectionTests {
|
||||||
|
|
||||||
sfScope.inTransaction(
|
sfScope.inTransaction(
|
||||||
(session) -> {
|
(session) -> {
|
||||||
TheEntity retrieved = (TheEntity) session.load( TheEntity.class, 1 );
|
TheEntity retrieved = (TheEntity) session.getReference( TheEntity.class, 1 );
|
||||||
assertEquals( 1, retrieved.getSet().size() );
|
assertEquals( 1, retrieved.getSet().size() );
|
||||||
assertEquals( new ValueType( "set_value" ), retrieved.getSet().iterator().next() );
|
assertEquals( new ValueType( "set_value" ), retrieved.getSet().iterator().next() );
|
||||||
assertEquals( 1, retrieved.getMap().size() );
|
assertEquals( 1, retrieved.getMap().size() );
|
||||||
|
|
|
@ -48,8 +48,8 @@ public class SimpleBatchFetchBaselineTests {
|
||||||
statementInspector.clear();
|
statementInspector.clear();
|
||||||
|
|
||||||
scope.inTransaction( (session) -> {
|
scope.inTransaction( (session) -> {
|
||||||
final EmployeeGroup group1 = session.load( EmployeeGroup.class, 1 );
|
final EmployeeGroup group1 = session.getReference( EmployeeGroup.class, 1 );
|
||||||
final EmployeeGroup group2 = session.load( EmployeeGroup.class, 2 );
|
final EmployeeGroup group2 = session.getReference( EmployeeGroup.class, 2 );
|
||||||
|
|
||||||
assertThat( Hibernate.isInitialized( group1 ) ).isFalse();
|
assertThat( Hibernate.isInitialized( group1 ) ).isFalse();
|
||||||
assertThat( Hibernate.isInitialized( group2 ) ).isFalse();
|
assertThat( Hibernate.isInitialized( group2 ) ).isFalse();
|
||||||
|
|
|
@ -48,8 +48,8 @@ public class SimpleBatchFetchTests {
|
||||||
statementInspector.clear();
|
statementInspector.clear();
|
||||||
|
|
||||||
scope.inTransaction( (session) -> {
|
scope.inTransaction( (session) -> {
|
||||||
final EmployeeGroup group1 = session.load( EmployeeGroup.class, 1 );
|
final EmployeeGroup group1 = session.getReference( EmployeeGroup.class, 1 );
|
||||||
final EmployeeGroup group2 = session.load( EmployeeGroup.class, 2 );
|
final EmployeeGroup group2 = session.getReference( EmployeeGroup.class, 2 );
|
||||||
|
|
||||||
assertThat( Hibernate.isInitialized( group1 ) ).isFalse();
|
assertThat( Hibernate.isInitialized( group1 ) ).isFalse();
|
||||||
assertThat( Hibernate.isInitialized( group2 ) ).isFalse();
|
assertThat( Hibernate.isInitialized( group2 ) ).isFalse();
|
||||||
|
|
|
@ -154,9 +154,9 @@ public class SimpleNestedSubSelectFetchTests {
|
||||||
@AfterEach
|
@AfterEach
|
||||||
public void dropTestData(SessionFactoryScope scope) {
|
public void dropTestData(SessionFactoryScope scope) {
|
||||||
scope.inTransaction( (session) -> {
|
scope.inTransaction( (session) -> {
|
||||||
session.remove( session.load( Customer.class, 1 ) );
|
session.remove( session.getReference( Customer.class, 1 ) );
|
||||||
session.remove( session.load( Customer.class, 2 ) );
|
session.remove( session.getReference( Customer.class, 2 ) );
|
||||||
session.remove( session.load( Customer.class, 3 ) );
|
session.remove( session.getReference( Customer.class, 3 ) );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -99,8 +99,8 @@ public class SubselectFetchCollectionFromBatchTest {
|
||||||
|
|
||||||
scope.inTransaction( (s) -> {
|
scope.inTransaction( (s) -> {
|
||||||
EmployeeGroup[] loadedGroups = new EmployeeGroup[] {
|
EmployeeGroup[] loadedGroups = new EmployeeGroup[] {
|
||||||
s.load(EmployeeGroup.class, createdGroups[0].getId()),
|
s.getReference(EmployeeGroup.class, createdGroups[0].getId()),
|
||||||
s.load(EmployeeGroup.class, createdGroups[1].getId())
|
s.getReference(EmployeeGroup.class, createdGroups[1].getId())
|
||||||
};
|
};
|
||||||
|
|
||||||
// there should have been no SQL queries performed and loadedGroups should only contain proxies
|
// there should have been no SQL queries performed and loadedGroups should only contain proxies
|
||||||
|
@ -226,8 +226,8 @@ public class SubselectFetchCollectionFromBatchTest {
|
||||||
|
|
||||||
scope.inTransaction( (s) -> {
|
scope.inTransaction( (s) -> {
|
||||||
EmployeeGroup[] loadedGroups = new EmployeeGroup[] {
|
EmployeeGroup[] loadedGroups = new EmployeeGroup[] {
|
||||||
s.load(EmployeeGroup.class, createdIds[0]),
|
s.getReference(EmployeeGroup.class, createdIds[0]),
|
||||||
s.load(EmployeeGroup.class, createdIds[1])
|
s.getReference(EmployeeGroup.class, createdIds[1])
|
||||||
};
|
};
|
||||||
|
|
||||||
// loadedGroups should only contain proxies
|
// loadedGroups should only contain proxies
|
||||||
|
|
|
@ -66,8 +66,8 @@ public class SubselectFetchTest {
|
||||||
@AfterEach
|
@AfterEach
|
||||||
public void dropTestData(SessionFactoryScope scope) {
|
public void dropTestData(SessionFactoryScope scope) {
|
||||||
scope.inTransaction( (session) -> {
|
scope.inTransaction( (session) -> {
|
||||||
session.remove( session.load( Parent.class, "foo" ) );
|
session.remove( session.getReference( Parent.class, "foo" ) );
|
||||||
session.remove( session.load( Parent.class, "bar" ) );
|
session.remove( session.getReference( Parent.class, "bar" ) );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,7 +277,7 @@ public class SubselectFetchTest {
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
scope.inTransaction( (session) -> {
|
scope.inTransaction( (session) -> {
|
||||||
session.remove( session.load( Parent.class, "aaa" ) );
|
session.remove( session.getReference( Parent.class, "aaa" ) );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class BaseIdEntityByteCodeTest {
|
||||||
} );
|
} );
|
||||||
|
|
||||||
scope.inTransaction( session -> {
|
scope.inTransaction( session -> {
|
||||||
ContainingEntity entity = session.load( ContainingEntity.class, 1 );
|
ContainingEntity entity = session.getReference( ContainingEntity.class, 1 );
|
||||||
ContainedEmbeddable containedEmbeddable = entity.getContainedEmbeddable();
|
ContainedEmbeddable containedEmbeddable = entity.getContainedEmbeddable();
|
||||||
assertThat( containedEmbeddable.getText() ).isEqualTo( "initialValue" );
|
assertThat( containedEmbeddable.getText() ).isEqualTo( "initialValue" );
|
||||||
} );
|
} );
|
||||||
|
|
|
@ -214,7 +214,7 @@ public class DiscriminatorTest {
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
s -> {
|
s -> {
|
||||||
// load the superclass proxy.
|
// load the superclass proxy.
|
||||||
Person pLoad = s.load( Person.class, e.getId() );
|
Person pLoad = s.getReference( Person.class, e.getId() );
|
||||||
assertTrue( pLoad instanceof HibernateProxy );
|
assertTrue( pLoad instanceof HibernateProxy );
|
||||||
Person pGet = s.get( Person.class, e.getId() );
|
Person pGet = s.get( Person.class, e.getId() );
|
||||||
Person pQuery = (Person) s.createQuery( "from Person where id = :id" )
|
Person pQuery = (Person) s.createQuery( "from Person where id = :id" )
|
||||||
|
@ -241,7 +241,7 @@ public class DiscriminatorTest {
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
s -> {
|
s -> {
|
||||||
// load the superclass proxy.
|
// load the superclass proxy.
|
||||||
Person pLoad = s.load( Person.class, e.getId() );
|
Person pLoad = s.getReference( Person.class, e.getId() );
|
||||||
assertTrue( pLoad instanceof HibernateProxy );
|
assertTrue( pLoad instanceof HibernateProxy );
|
||||||
Person pGet = s.get( Person.class, e.getId() );
|
Person pGet = s.get( Person.class, e.getId() );
|
||||||
Person pQuery = (Person) s.createQuery( "from Person where id = :id" )
|
Person pQuery = (Person) s.createQuery( "from Person where id = :id" )
|
||||||
|
@ -285,7 +285,7 @@ public class DiscriminatorTest {
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
s -> {
|
s -> {
|
||||||
// load the superclass proxy.
|
// load the superclass proxy.
|
||||||
Person pLoad = s.load( Person.class, e.getId() );
|
Person pLoad = s.getReference( Person.class, e.getId() );
|
||||||
assertTrue( pLoad instanceof HibernateProxy );
|
assertTrue( pLoad instanceof HibernateProxy );
|
||||||
// evict the proxy
|
// evict the proxy
|
||||||
s.evict( pLoad );
|
s.evict( pLoad );
|
||||||
|
|
|
@ -220,7 +220,7 @@ public class SimpleInheritanceTest {
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
s -> {
|
s -> {
|
||||||
// load the superclass proxy.
|
// load the superclass proxy.
|
||||||
Person pLoad = s.load( Person.class, employee.getId() );
|
Person pLoad = s.getReference( Person.class, employee.getId() );
|
||||||
assertTrue( pLoad instanceof HibernateProxy );
|
assertTrue( pLoad instanceof HibernateProxy );
|
||||||
Person pGet = s.get( Person.class, employee.getId() );
|
Person pGet = s.get( Person.class, employee.getId() );
|
||||||
Person pQuery = (Person) s.createQuery(
|
Person pQuery = (Person) s.createQuery(
|
||||||
|
@ -269,7 +269,7 @@ public class SimpleInheritanceTest {
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
s -> {
|
s -> {
|
||||||
// load the superclass proxy.
|
// load the superclass proxy.
|
||||||
Person pLoad = s.load( Person.class, employee.getId() );
|
Person pLoad = s.getReference( Person.class, employee.getId() );
|
||||||
assertTrue( pLoad instanceof HibernateProxy );
|
assertTrue( pLoad instanceof HibernateProxy );
|
||||||
// evict the proxy
|
// evict the proxy
|
||||||
s.evict( pLoad );
|
s.evict( pLoad );
|
||||||
|
|
|
@ -77,26 +77,26 @@ public class MixedTest {
|
||||||
.openSession()) {
|
.openSession()) {
|
||||||
session.beginTransaction();
|
session.beginTransaction();
|
||||||
try {
|
try {
|
||||||
Item id = session.load( Item.class, did );
|
Item id = session.getReference( Item.class, did );
|
||||||
assertEquals( did, id.getId() );
|
assertEquals( did, id.getId() );
|
||||||
assertEquals( "Hibernate in Action", id.getName() );
|
assertEquals( "Hibernate in Action", id.getName() );
|
||||||
assertEquals( "/", id.getParent().getName() );
|
assertEquals( "/", id.getParent().getName() );
|
||||||
|
|
||||||
Item id2 = session.load( Item.class, d2id );
|
Item id2 = session.getReference( Item.class, d2id );
|
||||||
assertEquals( d2id, id2.getId() );
|
assertEquals( d2id, id2.getId() );
|
||||||
assertEquals( "Secret", id2.getName() );
|
assertEquals( "Secret", id2.getName() );
|
||||||
assertEquals( "/", id2.getParent().getName() );
|
assertEquals( "/", id2.getParent().getName() );
|
||||||
|
|
||||||
id.setName( "HiA" );
|
id.setName( "HiA" );
|
||||||
|
|
||||||
SecureDocument d2 = session.load( SecureDocument.class, d2id );
|
SecureDocument d2 = session.getReference( SecureDocument.class, d2id );
|
||||||
d2.setOwner( "max" );
|
d2.setOwner( "max" );
|
||||||
|
|
||||||
session.flush();
|
session.flush();
|
||||||
|
|
||||||
session.clear();
|
session.clear();
|
||||||
|
|
||||||
Document d = session.load( Document.class, did );
|
Document d = session.getReference( Document.class, did );
|
||||||
assertEquals( did, d.getId() );
|
assertEquals( did, d.getId() );
|
||||||
assertEquals( "HiA", d.getName() );
|
assertEquals( "HiA", d.getName() );
|
||||||
assertNotNull( d.getContent() );
|
assertNotNull( d.getContent() );
|
||||||
|
@ -104,7 +104,7 @@ public class MixedTest {
|
||||||
assertNotNull( d.getCreated() );
|
assertNotNull( d.getCreated() );
|
||||||
assertNotNull( d.getModified() );
|
assertNotNull( d.getModified() );
|
||||||
|
|
||||||
d2 = session.load( SecureDocument.class, d2id );
|
d2 = session.getReference( SecureDocument.class, d2id );
|
||||||
assertEquals( d2id, d2.getId() );
|
assertEquals( d2id, d2.getId() );
|
||||||
assertEquals( "Secret", d2.getName() );
|
assertEquals( "Secret", d2.getName() );
|
||||||
assertNotNull( d2.getContent() );
|
assertNotNull( d2.getContent() );
|
||||||
|
|
|
@ -139,7 +139,7 @@ public class DiscriminatorMultiTenancyTest extends BaseUnitTestCase {
|
||||||
|
|
||||||
// make sure we get the steve back, from cache if same tenant (jboss)
|
// make sure we get the steve back, from cache if same tenant (jboss)
|
||||||
doInHibernate( "jboss", session -> {
|
doInHibernate( "jboss", session -> {
|
||||||
Customer customer = session.load( Customer.class, 1L );
|
Customer customer = session.getReference( Customer.class, 1L );
|
||||||
Assert.assertEquals( "steve", customer.getName() );
|
Assert.assertEquals( "steve", customer.getName() );
|
||||||
// also, make sure this came from second level
|
// also, make sure this came from second level
|
||||||
Assert.assertEquals( 1, sessionFactory.getStatistics().getSecondLevelCacheHitCount() );
|
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)
|
// then make sure we get the steve back, from db if other tenant (acme)
|
||||||
doInHibernate( "acme", session -> {
|
doInHibernate( "acme", session -> {
|
||||||
Customer customer = session.load( Customer.class, 1L );
|
Customer customer = session.getReference( Customer.class, 1L );
|
||||||
Assert.assertEquals( "steve", customer.getName() );
|
Assert.assertEquals( "steve", customer.getName() );
|
||||||
// also, make sure this doesn't came from second level
|
// also, make sure this doesn't came from second level
|
||||||
Assert.assertEquals( 0, sessionFactory.getStatistics().getSecondLevelCacheHitCount() );
|
Assert.assertEquals( 0, sessionFactory.getStatistics().getSecondLevelCacheHitCount() );
|
||||||
|
@ -161,7 +161,7 @@ public class DiscriminatorMultiTenancyTest extends BaseUnitTestCase {
|
||||||
|
|
||||||
// first jboss
|
// first jboss
|
||||||
doInHibernate( "jboss", session -> {
|
doInHibernate( "jboss", session -> {
|
||||||
Customer customer = session.load( Customer.class, 1L );
|
Customer customer = session.getReference( Customer.class, 1L );
|
||||||
Assert.assertEquals( "steve", customer.getName() );
|
Assert.assertEquals( "steve", customer.getName() );
|
||||||
// also, make sure this doesn't came from second level
|
// also, make sure this doesn't came from second level
|
||||||
Assert.assertEquals( 0, sessionFactory.getStatistics().getSecondLevelCacheHitCount() );
|
Assert.assertEquals( 0, sessionFactory.getStatistics().getSecondLevelCacheHitCount() );
|
||||||
|
@ -170,14 +170,14 @@ public class DiscriminatorMultiTenancyTest extends BaseUnitTestCase {
|
||||||
sessionFactory.getStatistics().clear();
|
sessionFactory.getStatistics().clear();
|
||||||
// then, acme
|
// then, acme
|
||||||
doInHibernate( "acme", session -> {
|
doInHibernate( "acme", session -> {
|
||||||
Customer customer = session.load( Customer.class, 1L );
|
Customer customer = session.getReference( Customer.class, 1L );
|
||||||
Assert.assertEquals( "steve", customer.getName() );
|
Assert.assertEquals( "steve", customer.getName() );
|
||||||
// also, make sure this doesn't came from second level
|
// also, make sure this doesn't came from second level
|
||||||
Assert.assertEquals( 0, sessionFactory.getStatistics().getSecondLevelCacheHitCount() );
|
Assert.assertEquals( 0, sessionFactory.getStatistics().getSecondLevelCacheHitCount() );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
doInHibernate( "jboss", session -> {
|
doInHibernate( "jboss", session -> {
|
||||||
Customer customer = session.load( Customer.class, 1L );
|
Customer customer = session.getReference( Customer.class, 1L );
|
||||||
session.remove( customer );
|
session.remove( customer );
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,7 +196,7 @@ public abstract class AbstractSchemaBasedMultiTenancyTest<T extends MultiTenantC
|
||||||
// make sure we get the correct people back, from cache
|
// make sure we get the correct people back, from cache
|
||||||
// first, jboss
|
// first, jboss
|
||||||
doInHibernateSessionBuilder( this::jboss, session -> {
|
doInHibernateSessionBuilder( this::jboss, session -> {
|
||||||
Customer customer = session.load( Customer.class, 1L );
|
Customer customer = session.getReference( Customer.class, 1L );
|
||||||
Assert.assertEquals( "steve", customer.getName() );
|
Assert.assertEquals( "steve", customer.getName() );
|
||||||
// also, make sure this came from second level
|
// also, make sure this came from second level
|
||||||
Assert.assertEquals( 1, sessionFactory.getStatistics().getSecondLevelCacheHitCount() );
|
Assert.assertEquals( 1, sessionFactory.getStatistics().getSecondLevelCacheHitCount() );
|
||||||
|
@ -205,7 +205,7 @@ public abstract class AbstractSchemaBasedMultiTenancyTest<T extends MultiTenantC
|
||||||
sessionFactory.getStatistics().clear();
|
sessionFactory.getStatistics().clear();
|
||||||
// then, acme
|
// then, acme
|
||||||
doInHibernateSessionBuilder( this::acme, session -> {
|
doInHibernateSessionBuilder( this::acme, session -> {
|
||||||
Customer customer = session.load( Customer.class, 1L );
|
Customer customer = session.getReference( Customer.class, 1L );
|
||||||
Assert.assertEquals( "john", customer.getName() );
|
Assert.assertEquals( "john", customer.getName() );
|
||||||
// also, make sure this came from second level
|
// also, make sure this came from second level
|
||||||
Assert.assertEquals( 1, sessionFactory.getStatistics().getSecondLevelCacheHitCount() );
|
Assert.assertEquals( 1, sessionFactory.getStatistics().getSecondLevelCacheHitCount() );
|
||||||
|
@ -216,7 +216,7 @@ public abstract class AbstractSchemaBasedMultiTenancyTest<T extends MultiTenantC
|
||||||
sessionFactory.getCache().evictEntityData();
|
sessionFactory.getCache().evictEntityData();
|
||||||
// first jboss
|
// first jboss
|
||||||
doInHibernateSessionBuilder( this::jboss, session -> {
|
doInHibernateSessionBuilder( this::jboss, session -> {
|
||||||
Customer customer = session.load( Customer.class, 1L );
|
Customer customer = session.getReference( Customer.class, 1L );
|
||||||
Assert.assertEquals( "steve", customer.getName() );
|
Assert.assertEquals( "steve", customer.getName() );
|
||||||
// also, make sure this came from second level
|
// also, make sure this came from second level
|
||||||
Assert.assertEquals( 0, sessionFactory.getStatistics().getSecondLevelCacheHitCount() );
|
Assert.assertEquals( 0, sessionFactory.getStatistics().getSecondLevelCacheHitCount() );
|
||||||
|
@ -225,7 +225,7 @@ public abstract class AbstractSchemaBasedMultiTenancyTest<T extends MultiTenantC
|
||||||
sessionFactory.getStatistics().clear();
|
sessionFactory.getStatistics().clear();
|
||||||
// then, acme
|
// then, acme
|
||||||
doInHibernateSessionBuilder( this::acme, session -> {
|
doInHibernateSessionBuilder( this::acme, session -> {
|
||||||
Customer customer = session.load( Customer.class, 1L );
|
Customer customer = session.getReference( Customer.class, 1L );
|
||||||
Assert.assertEquals( "john", customer.getName() );
|
Assert.assertEquals( "john", customer.getName() );
|
||||||
// also, make sure this came from second level
|
// also, make sure this came from second level
|
||||||
Assert.assertEquals( 0, sessionFactory.getStatistics().getSecondLevelCacheHitCount() );
|
Assert.assertEquals( 0, sessionFactory.getStatistics().getSecondLevelCacheHitCount() );
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class EagerProxyNotFoundTest {
|
||||||
session -> {
|
session -> {
|
||||||
final Task task = new Task();
|
final Task task = new Task();
|
||||||
task.id = 1;
|
task.id = 1;
|
||||||
task.employeeEagerNotFoundIgnore = session.load( Employee.class, 2 );
|
task.employeeEagerNotFoundIgnore = session.getReference( Employee.class, 2 );
|
||||||
session.persist( task );
|
session.persist( task );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
@ -72,13 +72,13 @@ public class EagerProxyNotFoundTest {
|
||||||
session -> {
|
session -> {
|
||||||
final Task task = new Task();
|
final Task task = new Task();
|
||||||
task.id = 1;
|
task.id = 1;
|
||||||
task.employeeEagerNotFoundIgnore = session.load( Employee.class, 2 );
|
task.employeeEagerNotFoundIgnore = session.getReference( Employee.class, 2 );
|
||||||
session.persist( task );
|
session.persist( task );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
session.load( Employee.class, 2 );
|
session.getReference( Employee.class, 2 );
|
||||||
final Task task = session.createQuery( "from Task", Task.class ).getSingleResult();
|
final Task task = session.createQuery( "from Task", Task.class ).getSingleResult();
|
||||||
assertNotNull( task );
|
assertNotNull( task );
|
||||||
assertNull( task.employeeEagerNotFoundIgnore );
|
assertNull( task.employeeEagerNotFoundIgnore );
|
||||||
|
@ -91,7 +91,7 @@ public class EagerProxyNotFoundTest {
|
||||||
session -> {
|
session -> {
|
||||||
final Task task = new Task();
|
final Task task = new Task();
|
||||||
task.id = 1;
|
task.id = 1;
|
||||||
task.employeeLazy = session.load( Employee.class, 2 );
|
task.employeeLazy = session.getReference( Employee.class, 2 );
|
||||||
task.employeeEagerNotFoundIgnore = task.employeeLazy;
|
task.employeeEagerNotFoundIgnore = task.employeeLazy;
|
||||||
session.persist( task );
|
session.persist( task );
|
||||||
} );
|
} );
|
||||||
|
@ -113,14 +113,14 @@ public class EagerProxyNotFoundTest {
|
||||||
session -> {
|
session -> {
|
||||||
final Task task = new Task();
|
final Task task = new Task();
|
||||||
task.id = 1;
|
task.id = 1;
|
||||||
task.employeeLazy = session.load( Employee.class, 2 );
|
task.employeeLazy = session.getReference( Employee.class, 2 );
|
||||||
task.employeeEagerNotFoundIgnore = task.employeeLazy;
|
task.employeeEagerNotFoundIgnore = task.employeeLazy;
|
||||||
session.persist( task );
|
session.persist( task );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
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();
|
final Task task = session.createQuery( "from Task", Task.class ).getSingleResult();
|
||||||
assertNotNull( task );
|
assertNotNull( task );
|
||||||
assertNull( task.employeeEagerNotFoundIgnore );
|
assertNull( task.employeeEagerNotFoundIgnore );
|
||||||
|
@ -186,7 +186,7 @@ public class EagerProxyNotFoundTest {
|
||||||
try {
|
try {
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
session.load( Employee.class, 1 );
|
session.getReference( Employee.class, 1 );
|
||||||
session.createQuery( "from Task", Task.class ).getSingleResult();
|
session.createQuery( "from Task", Task.class ).getSingleResult();
|
||||||
} );
|
} );
|
||||||
fail( "EntityNotFoundException should have been thrown because Task.employee.location is not found " +
|
fail( "EntityNotFoundException should have been thrown because Task.employee.location is not found " +
|
||||||
|
@ -249,7 +249,7 @@ public class EagerProxyNotFoundTest {
|
||||||
try {
|
try {
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
session.load( Employee.class, 1 );
|
session.getReference( Employee.class, 1 );
|
||||||
Task task = session.createQuery( "from Task", Task.class ).getSingleResult();
|
Task task = session.createQuery( "from Task", Task.class ).getSingleResult();
|
||||||
assertNotNull( task );
|
assertNotNull( task );
|
||||||
Employee employeeEagerNotFoundIgnore = task.getEmployeeEagerNotFoundIgnore();
|
Employee employeeEagerNotFoundIgnore = task.getEmployeeEagerNotFoundIgnore();
|
||||||
|
|
|
@ -156,7 +156,7 @@ public class LazyLoadingTest {
|
||||||
Store s = scope.fromTransaction(
|
Store s = scope.fromTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
// first load the store, making sure it is not initialized
|
// 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 );
|
assertNotNull( store );
|
||||||
assertFalse( Hibernate.isInitialized( store ) );
|
assertFalse( Hibernate.isInitialized( store ) );
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ public abstract class AbstractRecursiveBidirectionalOneToManyTest extends BaseSe
|
||||||
inTransaction(
|
inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
session.setCacheMode( getSessionCacheMode() );
|
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 node2 = node3.getParentNode();
|
||||||
Node node1 = node2.getParentNode();
|
Node node1 = node2.getParentNode();
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ public abstract class AbstractRecursiveBidirectionalOneToManyTest extends BaseSe
|
||||||
inTransaction(
|
inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
session.setCacheMode( getSessionCacheMode() );
|
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 node2 = node3.getParentNode();
|
||||||
Node node1 = node2.getParentNode();
|
Node node1 = node2.getParentNode();
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ public abstract class AbstractRecursiveBidirectionalOneToManyTest extends BaseSe
|
||||||
inTransaction(
|
inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
session.setCacheMode( getSessionCacheMode() );
|
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 node2 = node3.getParentNode();
|
||||||
Node node1 = node2.getParentNode();
|
Node node1 = node2.getParentNode();
|
||||||
|
|
||||||
|
|
|
@ -203,7 +203,7 @@ public class OneToOneFormulaTest extends BaseSessionFactoryFunctionalTest {
|
||||||
Address a = new Address();
|
Address a = new Address();
|
||||||
a.setType( "HOME" );
|
a.setType( "HOME" );
|
||||||
a.setPerson( person );
|
a.setPerson( person );
|
||||||
a = session.load( Address.class, a );
|
a = session.getReference( Address.class, a );
|
||||||
assertFalse( Hibernate.isInitialized( a ) );
|
assertFalse( Hibernate.isInitialized( a ) );
|
||||||
a.getPerson();
|
a.getPerson();
|
||||||
a.getType();
|
a.getType();
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class OptionalOneToOneTest {
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
Person me = session.load( Person.class, name );
|
Person me = session.getReference( Person.class, name );
|
||||||
assertNull( me.address );
|
assertNull( me.address );
|
||||||
session.remove( me );
|
session.remove( me );
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,7 +232,7 @@ public class CreateTest extends AbstractOperationTestCase {
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
Employer er1 = session.load( Employer.class, er.getId() );
|
Employer er1 = session.getReference( Employer.class, er.getId() );
|
||||||
assertNotNull( er1 );
|
assertNotNull( er1 );
|
||||||
assertNotNull( er1.getEmployees() );
|
assertNotNull( er1.getEmployees() );
|
||||||
assertThat( er1.getEmployees().size(), is( 1 ) );
|
assertThat( er1.getEmployees().size(), is( 1 ) );
|
||||||
|
|
|
@ -75,10 +75,10 @@ public class GetLoadTest {
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
Employer e = session.load( Employer.class, emp.getId() );
|
Employer e = session.getReference( Employer.class, emp.getId() );
|
||||||
e.getId();
|
e.getId();
|
||||||
assertFalse( Hibernate.isInitialized( e ) );
|
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" ) );
|
assertThat( n.getName(), is( "foo" ) );
|
||||||
assertFalse( Hibernate.isInitialized( n ) );
|
assertFalse( Hibernate.isInitialized( n ) );
|
||||||
}
|
}
|
||||||
|
@ -95,10 +95,10 @@ public class GetLoadTest {
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
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();
|
e.getId();
|
||||||
assertFalse( Hibernate.isInitialized( e ) );
|
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" ) );
|
assertThat( n.getName(), is( "foo" ) );
|
||||||
assertFalse( Hibernate.isInitialized( n ) );
|
assertFalse( Hibernate.isInitialized( n ) );
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class SimpleOpsTest extends AbstractOperationTestCase {
|
||||||
|
|
||||||
SimpleEntity simpleEntity = scope.fromTransaction(
|
SimpleEntity simpleEntity = scope.fromTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
SimpleEntity entity = session.load( SimpleEntity.class, id );
|
SimpleEntity entity = session.getReference( SimpleEntity.class, id );
|
||||||
assertFalse( Hibernate.isInitialized( entity ) );
|
assertFalse( Hibernate.isInitialized( entity ) );
|
||||||
assertThat( entity.getId(), is( 1L ) );
|
assertThat( entity.getId(), is( 1L ) );
|
||||||
assertThat( entity.getName(), is( "new name" ) );
|
assertThat( entity.getName(), is( "new name" ) );
|
||||||
|
|
|
@ -87,17 +87,17 @@ public class BasicGetLoadAccessTest {
|
||||||
// test `load` access
|
// test `load` access
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session ->
|
session ->
|
||||||
session.load( User.class, 1 )
|
session.getReference( User.class, 1 )
|
||||||
);
|
);
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session ->
|
session ->
|
||||||
session.load( User.class, 1, LockMode.PESSIMISTIC_WRITE )
|
session.get( User.class, 1, LockMode.PESSIMISTIC_WRITE )
|
||||||
);
|
);
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session ->
|
session ->
|
||||||
session.load( User.class, 1, LockOptions.UPGRADE )
|
session.get( User.class, 1, LockOptions.UPGRADE )
|
||||||
);
|
);
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
|
|
|
@ -115,7 +115,7 @@ public class OptimisticLockTest {
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
Document document = (Document) session.load( entityName, doc.getId() );
|
Document document = (Document) session.getReference( entityName, doc.getId() );
|
||||||
session.remove( document );
|
session.remove( document );
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -170,7 +170,7 @@ public class OptimisticLockTest {
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
Document document = (Document) session.load( entityName, doc.getId() );
|
Document document = (Document) session.getReference( entityName, doc.getId() );
|
||||||
session.remove( document );
|
session.remove( document );
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class PropertyRefTest {
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
User u = session.load( User.class, user.getId() );
|
User u = session.getReference( User.class, user.getId() );
|
||||||
session.remove( u );
|
session.remove( u );
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class PolymorphicAssociationTest {
|
||||||
@Test
|
@Test
|
||||||
public void testLoad(SessionFactoryScope scope) {
|
public void testLoad(SessionFactoryScope scope) {
|
||||||
scope.inTransaction( session -> {
|
scope.inTransaction( session -> {
|
||||||
Level3 level3 = session.load( Level3.class, 3 );
|
Level3 level3 = session.getReference( Level3.class, 3 );
|
||||||
Level2 level2 = level3.getLevel2Parent();
|
Level2 level2 = level3.getLevel2Parent();
|
||||||
assertThat( level2 ).isNotNull();
|
assertThat( level2 ).isNotNull();
|
||||||
final Level3 level3Child = level2.getLevel3Child();
|
final Level3 level3Child = level2.getLevel3Child();
|
||||||
|
@ -67,7 +67,7 @@ public class PolymorphicAssociationTest {
|
||||||
} );
|
} );
|
||||||
|
|
||||||
scope.inTransaction( session -> {
|
scope.inTransaction( session -> {
|
||||||
Level1 level1 = session.load( Level1.class, 1 );
|
Level1 level1 = session.getReference( Level1.class, 1 );
|
||||||
DerivedLevel2 level2 = level1.getLevel2Child();
|
DerivedLevel2 level2 = level1.getLevel2Child();
|
||||||
assertThat( level2 ).isNotNull();
|
assertThat( level2 ).isNotNull();
|
||||||
assertThat( level2.getLevel1Parent() ).extracting( "id" ).isEqualTo( 1 );
|
assertThat( level2.getLevel1Parent() ).extracting( "id" ).isEqualTo( 1 );
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class PolymorphicAssociationTest2 {
|
||||||
@Test
|
@Test
|
||||||
public void testLoad(SessionFactoryScope scope) {
|
public void testLoad(SessionFactoryScope scope) {
|
||||||
scope.inTransaction( session -> {
|
scope.inTransaction( session -> {
|
||||||
Level3 level3 = session.load( Level3.class, 3 );
|
Level3 level3 = session.getReference( Level3.class, 3 );
|
||||||
Level2 level2 = level3.getLevel2Parent();
|
Level2 level2 = level3.getLevel2Parent();
|
||||||
assertThat( level2 ).isNotNull();
|
assertThat( level2 ).isNotNull();
|
||||||
final Level3 level3Child = level2.getLevel3Child();
|
final Level3 level3Child = level2.getLevel3Child();
|
||||||
|
@ -67,7 +67,7 @@ public class PolymorphicAssociationTest2 {
|
||||||
} );
|
} );
|
||||||
|
|
||||||
scope.inTransaction( session -> {
|
scope.inTransaction( session -> {
|
||||||
Level1 level1 = session.load( Level1.class, 1 );
|
Level1 level1 = session.getReference( Level1.class, 1 );
|
||||||
Level2 level2 = level1.getLevel2Child();
|
Level2 level2 = level1.getLevel2Child();
|
||||||
assertThat( level2 ).isNotNull();
|
assertThat( level2 ).isNotNull();
|
||||||
assertThat( level2.getLevel1Parent() ).extracting( "id" ).isEqualTo( 1 );
|
assertThat( level2.getLevel1Parent() ).extracting( "id" ).isEqualTo( 1 );
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class DirectPropertyAccessorTest {
|
||||||
s.flush();
|
s.flush();
|
||||||
s.clear();
|
s.clear();
|
||||||
|
|
||||||
o = ( Order ) s.load( Order.class, 1 );
|
o = ( Order ) s.getReference( Order.class, 1 );
|
||||||
assertFalse( Hibernate.isInitialized( o ) );
|
assertFalse( Hibernate.isInitialized( o ) );
|
||||||
o.getOrderNumber();
|
o.getOrderNumber();
|
||||||
// If you mapped with field access, any method, except id, call initializes the proxy
|
// If you mapped with field access, any method, except id, call initializes the proxy
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class FinalGetterSetterTest {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
scope.inTransaction( session ->
|
scope.inTransaction( session ->
|
||||||
session.load( EntityWithFinalClass.class, 999 )
|
session.getReference( EntityWithFinalClass.class, 999 )
|
||||||
);
|
);
|
||||||
fail( "Should have thrown ObjectNotFoundException" );
|
fail( "Should have thrown ObjectNotFoundException" );
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ public class FinalGetterSetterTest {
|
||||||
} );
|
} );
|
||||||
|
|
||||||
scope.inTransaction( session -> {
|
scope.inTransaction( session -> {
|
||||||
final EntityWithFinalClass entity = session.load( EntityWithFinalClass.class, 1 );
|
final EntityWithFinalClass entity = session.getReference( EntityWithFinalClass.class, 1 );
|
||||||
assertNotNull( entity );
|
assertNotNull( entity );
|
||||||
assertTrue( Hibernate.isInitialized( entity ) );
|
assertTrue( Hibernate.isInitialized( entity ) );
|
||||||
} );
|
} );
|
||||||
|
@ -82,7 +82,7 @@ public class FinalGetterSetterTest {
|
||||||
try {
|
try {
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session ->
|
session ->
|
||||||
session.load( EntityWithFinalIdGetter.class, 999 )
|
session.getReference( EntityWithFinalIdGetter.class, 999 )
|
||||||
);
|
);
|
||||||
fail( "Should have thrown ObjectNotFoundException" );
|
fail( "Should have thrown ObjectNotFoundException" );
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ public class FinalGetterSetterTest {
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
final EntityWithFinalIdGetter entity = session.load( EntityWithFinalIdGetter.class, 1 );
|
final EntityWithFinalIdGetter entity = session.getReference( EntityWithFinalIdGetter.class, 1 );
|
||||||
assertNotNull( entity );
|
assertNotNull( entity );
|
||||||
assertTrue( Hibernate.isInitialized( entity ) );
|
assertTrue( Hibernate.isInitialized( entity ) );
|
||||||
} );
|
} );
|
||||||
|
@ -115,7 +115,7 @@ public class FinalGetterSetterTest {
|
||||||
try {
|
try {
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session ->
|
session ->
|
||||||
session.load( EntityWithFinalIdSetter.class, 999 )
|
session.getReference( EntityWithFinalIdSetter.class, 999 )
|
||||||
);
|
);
|
||||||
fail( "Should have thrown ObjectNotFoundException" );
|
fail( "Should have thrown ObjectNotFoundException" );
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ public class FinalGetterSetterTest {
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
final EntityWithFinalIdSetter entity = session.load( EntityWithFinalIdSetter.class, 1 );
|
final EntityWithFinalIdSetter entity = session.getReference( EntityWithFinalIdSetter.class, 1 );
|
||||||
assertNotNull( entity );
|
assertNotNull( entity );
|
||||||
assertTrue( Hibernate.isInitialized( entity ) );
|
assertTrue( Hibernate.isInitialized( entity ) );
|
||||||
} );
|
} );
|
||||||
|
@ -148,7 +148,7 @@ public class FinalGetterSetterTest {
|
||||||
try {
|
try {
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session ->
|
session ->
|
||||||
session.load( EntityWithFinalVersionGetter.class, 999 )
|
session.getReference( EntityWithFinalVersionGetter.class, 999 )
|
||||||
);
|
);
|
||||||
fail( "Should have thrown ObjectNotFoundException" );
|
fail( "Should have thrown ObjectNotFoundException" );
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,7 @@ public class FinalGetterSetterTest {
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
final EntityWithFinalVersionGetter entity = session.load( EntityWithFinalVersionGetter.class, 1 );
|
final EntityWithFinalVersionGetter entity = session.getReference( EntityWithFinalVersionGetter.class, 1 );
|
||||||
assertNotNull( entity );
|
assertNotNull( entity );
|
||||||
assertTrue( Hibernate.isInitialized( entity ) );
|
assertTrue( Hibernate.isInitialized( entity ) );
|
||||||
} );
|
} );
|
||||||
|
@ -181,7 +181,7 @@ public class FinalGetterSetterTest {
|
||||||
try {
|
try {
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session ->
|
session ->
|
||||||
session.load( EntityWithFinalVersionSetter.class, 999 )
|
session.getReference( EntityWithFinalVersionSetter.class, 999 )
|
||||||
);
|
);
|
||||||
fail( "Should have thrown ObjectNotFoundException" );
|
fail( "Should have thrown ObjectNotFoundException" );
|
||||||
}
|
}
|
||||||
|
@ -198,7 +198,7 @@ public class FinalGetterSetterTest {
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
final EntityWithFinalVersionSetter entity = session.load( EntityWithFinalVersionSetter.class, 1 );
|
final EntityWithFinalVersionSetter entity = session.getReference( EntityWithFinalVersionSetter.class, 1 );
|
||||||
assertNotNull( entity );
|
assertNotNull( entity );
|
||||||
assertTrue( Hibernate.isInitialized( entity ) );
|
assertTrue( Hibernate.isInitialized( entity ) );
|
||||||
} );
|
} );
|
||||||
|
@ -214,7 +214,7 @@ public class FinalGetterSetterTest {
|
||||||
try {
|
try {
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session ->
|
session ->
|
||||||
session.load( EntityWithFinalPropertyGetter.class, 999 )
|
session.getReference( EntityWithFinalPropertyGetter.class, 999 )
|
||||||
);
|
);
|
||||||
fail( "Should have thrown ObjectNotFoundException" );
|
fail( "Should have thrown ObjectNotFoundException" );
|
||||||
}
|
}
|
||||||
|
@ -231,7 +231,7 @@ public class FinalGetterSetterTest {
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
final EntityWithFinalPropertyGetter entity = session.load( EntityWithFinalPropertyGetter.class, 1 );
|
final EntityWithFinalPropertyGetter entity = session.getReference( EntityWithFinalPropertyGetter.class, 1 );
|
||||||
assertNotNull( entity );
|
assertNotNull( entity );
|
||||||
assertTrue( Hibernate.isInitialized( entity ) );
|
assertTrue( Hibernate.isInitialized( entity ) );
|
||||||
} );
|
} );
|
||||||
|
@ -247,7 +247,7 @@ public class FinalGetterSetterTest {
|
||||||
try {
|
try {
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session ->
|
session ->
|
||||||
session.load( EntityWithFinalPropertySetter.class, 999 )
|
session.getReference( EntityWithFinalPropertySetter.class, 999 )
|
||||||
);
|
);
|
||||||
fail( "Should have thrown ObjectNotFoundException" );
|
fail( "Should have thrown ObjectNotFoundException" );
|
||||||
}
|
}
|
||||||
|
@ -264,7 +264,7 @@ public class FinalGetterSetterTest {
|
||||||
|
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
session -> {
|
session -> {
|
||||||
final EntityWithFinalPropertySetter entity = session.load( EntityWithFinalPropertySetter.class, 1 );
|
final EntityWithFinalPropertySetter entity = session.getReference( EntityWithFinalPropertySetter.class, 1 );
|
||||||
assertNotNull( entity );
|
assertNotNull( entity );
|
||||||
assertTrue( Hibernate.isInitialized( entity ) );
|
assertTrue( Hibernate.isInitialized( entity ) );
|
||||||
} );
|
} );
|
||||||
|
|
|
@ -65,7 +65,7 @@ public class MultipleSessionFactoriesProxyTest extends BaseCoreFunctionalTestCas
|
||||||
s.flush();
|
s.flush();
|
||||||
s.clear();
|
s.clear();
|
||||||
|
|
||||||
container = s.load( Container.class, container.getId() );
|
container = s.getReference( Container.class, container.getId() );
|
||||||
assertFalse( Hibernate.isInitialized( container ) );
|
assertFalse( Hibernate.isInitialized( container ) );
|
||||||
container.getId();
|
container.getId();
|
||||||
assertFalse( Hibernate.isInitialized( container ) );
|
assertFalse( Hibernate.isInitialized( container ) );
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue