Skip to content

Commit ecd3ac7

Browse files
committed
[#2651] Add notNullableToOneAssociationMissingKey IllegalStateException to Log
1 parent b8e1b34 commit ecd3ac7

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
@@ -274,6 +274,9 @@ public interface Log extends BasicLogger {
274274
@Message(id = 86, value = "Error closing reactive connection")
275275
void errorClosingConnection(@Cause Throwable throwable);
276276

277+
@Message(id = 87, value = "Retrieved key was null, but to-one is not nullable : %s")
278+
IllegalStateException notNullableToOneAssociationMissingKey(String toOneNavigablePath);
279+
277280
// Same method that exists in CoreMessageLogger
278281
@LogMessage(level = WARN)
279282
@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)