Skip to content

Commit d5102ff

Browse files
committed
fix a bug in generation of @find method for @naturalid fields
StatelessSession does not have a byNaturalId() method
1 parent fa4c43f commit d5102ff

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/AnnotationMetaEntity.java

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1900,25 +1900,28 @@ private void createSingleParameterFinder(
19001900
);
19011901
break;
19021902
case NATURAL_ID:
1903-
putMember( methodKey,
1904-
new NaturalIdFinderMethod(
1905-
this, method,
1906-
methodName,
1907-
returnType.toString(),
1908-
containerType,
1909-
paramNames,
1910-
paramTypes,
1911-
parameterNullability(method, entity),
1912-
repository,
1913-
sessionType[0],
1914-
sessionType[1],
1915-
profiles,
1916-
context.addNonnullAnnotation(),
1917-
jakartaDataRepository,
1918-
fullReturnType(method)
1919-
)
1920-
);
1921-
break;
1903+
if ( !usingStatelessSession( sessionType[0] ) ) {// no byNaturalId() lookup API for SS
1904+
putMember( methodKey,
1905+
new NaturalIdFinderMethod(
1906+
this, method,
1907+
methodName,
1908+
returnType.toString(),
1909+
containerType,
1910+
paramNames,
1911+
paramTypes,
1912+
parameterNullability(method, entity),
1913+
repository,
1914+
sessionType[0],
1915+
sessionType[1],
1916+
profiles,
1917+
context.addNonnullAnnotation(),
1918+
jakartaDataRepository,
1919+
fullReturnType(method)
1920+
)
1921+
);
1922+
break;
1923+
}
1924+
// else intentionally fall through
19221925
case BASIC:
19231926
case MULTIVALUED:
19241927
final List<Boolean> paramPatterns = parameterPatterns( method );

0 commit comments

Comments
 (0)