HHH-10905 - Fix NPE when calling StatelessSession methods with null LockMode.
This commit is contained in:
parent
457715692c
commit
acd2f238ee
|
@ -178,8 +178,9 @@ public class StatelessSessionImpl extends AbstractSharedSessionContract implemen
|
||||||
@Override
|
@Override
|
||||||
public Object get(String entityName, Serializable id, LockMode lockMode) {
|
public Object get(String entityName, Serializable id, LockMode lockMode) {
|
||||||
checkOpen();
|
checkOpen();
|
||||||
|
|
||||||
Object result = getFactory().getMetamodel().entityPersister( entityName )
|
Object result = getFactory().getMetamodel().entityPersister( entityName )
|
||||||
.load( id, null, lockMode, this );
|
.load( id, null, getNullSafeLockMode( lockMode ), this );
|
||||||
if ( temporaryPersistenceContext.isLoadFinished() ) {
|
if ( temporaryPersistenceContext.isLoadFinished() ) {
|
||||||
temporaryPersistenceContext.clear();
|
temporaryPersistenceContext.clear();
|
||||||
}
|
}
|
||||||
|
@ -227,7 +228,7 @@ public class StatelessSessionImpl extends AbstractSharedSessionContract implemen
|
||||||
Object result = null;
|
Object result = null;
|
||||||
try {
|
try {
|
||||||
this.getLoadQueryInfluencers().setInternalFetchProfile( "refresh" );
|
this.getLoadQueryInfluencers().setInternalFetchProfile( "refresh" );
|
||||||
result = persister.load( id, entity, lockMode, this );
|
result = persister.load( id, entity, getNullSafeLockMode( lockMode ), this );
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
this.getLoadQueryInfluencers().setInternalFetchProfile( previousFetchProfile );
|
this.getLoadQueryInfluencers().setInternalFetchProfile( previousFetchProfile );
|
||||||
|
@ -669,4 +670,8 @@ public class StatelessSessionImpl extends AbstractSharedSessionContract implemen
|
||||||
private JtaPlatform getJtaPlatform() {
|
private JtaPlatform getJtaPlatform() {
|
||||||
return getFactory().getServiceRegistry().getService( JtaPlatform.class );
|
return getFactory().getServiceRegistry().getService( JtaPlatform.class );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private LockMode getNullSafeLockMode(LockMode lockMode) {
|
||||||
|
return lockMode == null ? LockMode.NONE : lockMode;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue