Skip to content

Commit 47b6429

Browse files
scottmarlowsebersole
authored andcommitted
HHH-19263 Do not bind to JNDI if hibernate.session_factory_name_is_jndi is set to false
Signed-off-by: Scott Marlow <[email protected]>
1 parent dda4e58 commit 47b6429

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

hibernate-core/src/main/java/org/hibernate/internal/SessionFactorySettings.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,18 @@ static String determineJndiName(
9595
if ( isNotEmpty( explicitJndiName ) ) {
9696
return explicitJndiName;
9797
}
98+
// do not use name for JNDI if explicitly asked not to
99+
else if ( options.isSessionFactoryNameAlsoJndiName() == Boolean.FALSE ) {
100+
return null;
101+
}
98102
else {
99103
final String expliciSessionFactoryname = configService.getSetting( SESSION_FACTORY_NAME, STRING );
100104
if ( isNotEmpty( expliciSessionFactoryname ) ) {
101105
return expliciSessionFactoryname;
102106
}
103107
final String unitName = configService.getSetting( PERSISTENCE_UNIT_NAME, STRING );
104-
// do not use name for JNDI if explicitly asked not to or if name comes from JPA persistence-unit name
105-
final boolean nameIsNotJndiName =
106-
options.isSessionFactoryNameAlsoJndiName() == Boolean.FALSE
107-
|| isNotEmpty( unitName );
108-
return !nameIsNotJndiName ? name : null;
108+
// if name comes from JPA persistence-unit name
109+
return ! isNotEmpty( unitName ) ? name : null;
109110
}
110111
}
111112

0 commit comments

Comments
 (0)