HHH-12484 - Improved error output for LazyInitializationException to include entity-related info

Use predefinied entity identifiers
This commit is contained in:
Vlad Mihalcea 2018-04-16 17:50:45 +03:00
parent d8d5bf99da
commit 6c0c44f7d0
1 changed files with 12 additions and 24 deletions

View File

@ -38,24 +38,27 @@ public class LazyLoadingLoggingTest
};
}
@Test
@TestForIssue(jiraKey = "HHH-12484")
public void testNoSession() {
Long addressId = doInHibernate( this::sessionFactory, session -> {
@Override
protected void afterSessionFactoryBuilt() {
doInHibernate( this::sessionFactory, session -> {
Address address = new Address();
address.setId( 1L );
address.setStreet( "Marea albastra" );
session.persist( address );
Client client = new Client();
client.setId( 1L );
client.setName( "Dorian" );
client.setAddress( address );
session.persist( client );
return address.getId();
} );
}
@Test
@TestForIssue(jiraKey = "HHH-12484")
public void testNoSession() {
Address address = doInHibernate( this::sessionFactory, s -> {
return s.load( Address.class, addressId );
return s.load( Address.class, 1L );
} );
try {
@ -75,21 +78,8 @@ public class LazyLoadingLoggingTest
@Test
@TestForIssue(jiraKey = "HHH-12484")
public void testDisconnect() {
Long addressId = doInHibernate( this::sessionFactory, s -> {
Address address = new Address();
address.setStreet( "Marea albastra" );
s.persist( address );
Client client = new Client();
client.setName( "Dorian" );
client.setAddress( address );
s.persist( client );
return address.getId();
} );
doInHibernate( this::sessionFactory, session -> {
Address address = session.load( Address.class, addressId );
Address address = session.load( Address.class, 1L );
AbstractSharedSessionContract sessionContract = (AbstractSharedSessionContract) session;
sessionContract.getJdbcCoordinator().close();
@ -116,7 +106,6 @@ public class LazyLoadingLoggingTest
@Entity(name = "Address")
public static class Address {
@Id
@GeneratedValue
private Long id;
@Column
@ -154,7 +143,6 @@ public class LazyLoadingLoggingTest
@Entity(name = "Client")
public static class Client {
@Id
@GeneratedValue
private Long id;
@Column
@ -195,4 +183,4 @@ public class LazyLoadingLoggingTest
this.address = address;
}
}
}
}