File tree Expand file tree Collapse file tree 1 file changed +11
-9
lines changed
hibernate-core/src/main/java/org/hibernate/collection/spi Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -657,19 +657,21 @@ private void throwLazyInitializationExceptionIfNotConnected() {
657
657
}
658
658
659
659
private void throwLazyInitializationException (String message ) {
660
- throwLazyInitializationException ( role , message );
661
- }
662
-
663
- private static void throwLazyInitializationException (String role , String message ) {
664
- throw new LazyInitializationException (
665
- String .format ( "Cannot lazily initialize collection%s (%s)" ,
666
- role == null ? "" : " of role '" + role + "'" , message )
667
- );
660
+ final var error = new StringBuilder ( "Cannot lazily initialize collection" );
661
+ if ( role != null ) {
662
+ error .append ( " of role '" ).append ( role ).append ( "'" );
663
+ }
664
+ if ( key != null ) {
665
+ error .append ( " with key '" ).append ( key ).append ( "'" );
666
+ }
667
+ error .append ( " (" ).append ( message ).append ( ")" );
668
+ throw new LazyInitializationException ( error .toString () );
668
669
}
669
670
670
671
public static void checkPersister (PersistentCollection <?> collection , CollectionPersister persister ) {
671
672
if ( !collection .wasInitialized () && persister == null ) {
672
- throwLazyInitializationException ( null , "collection is being removed" );
673
+ throw new LazyInitializationException ( "Cannot lazily initialize collection"
674
+ + " (collection is being removed)" );
673
675
}
674
676
}
675
677
You can’t perform that action at this time.
0 commit comments