Skip to content

Commit d9d7b0a

Browse files
dreab8DavideD
authored andcommitted
[#2651] Add notNullableToOneAssociationMissingKey IllegalStateException to Log
1 parent c13f723 commit d9d7b0a

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

hibernate-reactive-core/src/main/java/org/hibernate/reactive/logging/impl/Log.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,9 @@ public interface Log extends BasicLogger {
277277
@Message(id = 86, value = "Error closing reactive connection")
278278
void errorClosingConnection(@Cause Throwable throwable);
279279

280+
@Message(id = 87, value = "Retrieved key was null, but to-one is not nullable : %s")
281+
IllegalStateException notNullableToOneAssociationMissingKey(String toOneNavigablePath);
282+
280283
// Same method that exists in CoreMessageLogger
281284
@LogMessage(level = WARN)
282285
@Message(id = 104, value = "firstResult/maxResults specified with collection fetch; applying in memory!" )

hibernate-reactive-core/src/main/java/org/hibernate/reactive/sql/exec/internal/lock/ReactiveTableLock.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ public CompletionStage<Void> reactiveApplyResult(
154154
}
155155

156156
protected static class ReactiveToOneResultHandler extends ToOneResultHandler implements ReactiveResulHandler {
157+
public static final Log LOG = LoggerFactory.make( Log.class, MethodHandles.lookup() );
157158

158159
public ReactiveToOneResultHandler(Integer statePosition, ToOneAttributeMapping toOne) {
159160
super( statePosition, toOne );
@@ -166,8 +167,7 @@ public CompletionStage<Void> reactiveApplyResult(
166167
ReactiveSessionImpl session) {
167168
if ( stateValue == null ) {
168169
if ( !toOne.isNullable() ) {
169-
throw new IllegalStateException( "Retrieved key was null, but to-one is not nullable : " + toOne.getNavigableRole()
170-
.getFullPath() );
170+
throw LOG.notNullableToOneAssociationMissingKey( toOne.getNavigableRole().getFullPath() );
171171
}
172172
applyLoadedState( entityDetails, statePosition, null );
173173
applyModelState( entityDetails, statePosition, null );

0 commit comments

Comments
 (0)