Skip to content

Commit dec1eae

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

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
@@ -1921,25 +1921,28 @@ private void createSingleParameterFinder(
19211921
);
19221922
break;
19231923
case NATURAL_ID:
1924-
putMember( methodKey,
1925-
new NaturalIdFinderMethod(
1926-
this, method,
1927-
methodName,
1928-
returnType.toString(),
1929-
containerType,
1930-
paramNames,
1931-
paramTypes,
1932-
parameterNullability(method, entity),
1933-
repository,
1934-
sessionType[0],
1935-
sessionType[1],
1936-
profiles,
1937-
context.addNonnullAnnotation(),
1938-
jakartaDataRepository,
1939-
fullReturnType(method)
1940-
)
1941-
);
1942-
break;
1924+
if ( !usingStatelessSession( sessionType[0] ) ) {// no byNaturalId() lookup API for SS
1925+
putMember( methodKey,
1926+
new NaturalIdFinderMethod(
1927+
this, method,
1928+
methodName,
1929+
returnType.toString(),
1930+
containerType,
1931+
paramNames,
1932+
paramTypes,
1933+
parameterNullability(method, entity),
1934+
repository,
1935+
sessionType[0],
1936+
sessionType[1],
1937+
profiles,
1938+
context.addNonnullAnnotation(),
1939+
jakartaDataRepository,
1940+
fullReturnType(method)
1941+
)
1942+
);
1943+
break;
1944+
}
1945+
// else intentionally fall through
19431946
case BASIC:
19441947
case MULTIVALUED:
19451948
final List<Boolean> paramPatterns = parameterPatterns( method );

0 commit comments

Comments
 (0)