Skip to content

Commit f4d17be

Browse files
committed
small fixes to @find and @hql methods
don't include session parameter type where not necessary
1 parent 8e4755f commit f4d17be

File tree

2 files changed

+31
-21
lines changed

2 files changed

+31
-21
lines changed

tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/AbstractFinderMethod.java

+29-20
Original file line numberDiff line numberDiff line change
@@ -88,28 +88,37 @@ void comment(StringBuilder declaration) {
8888
.append("{@link ")
8989
.append(annotationMetaEntity.importType(entity))
9090
.append("} by ");
91-
int paramCount = paramNames.size();
92-
for (int i = 0; i < paramCount; i++) {
93-
String param = paramNames.get(i);
94-
if ( i>0 ) {
95-
if ( i + 1 == paramCount) {
96-
declaration
97-
.append(paramCount>2 ? ", and " : " and "); //Oxford comma
98-
}
99-
else {
100-
declaration
101-
.append(", ");
91+
long paramCount = paramTypes.stream()
92+
.filter(type -> !isOrderParam(type) && !isPageParam(type)
93+
&& !isSessionParameter(type))
94+
.count();
95+
int count = 0;
96+
for (int i = 0; i < paramTypes.size(); i++) {
97+
String type = paramTypes.get(i);
98+
if ( !isPageParam(type) && !isOrderParam(type)
99+
&& !isSessionParameter(type) ) {
100+
if ( count>0 ) {
101+
if ( count + 1 == paramCount) {
102+
declaration
103+
.append(paramCount>2 ? ", and " : " and "); //Oxford comma
104+
}
105+
else {
106+
declaration
107+
.append(", ");
108+
}
102109
}
110+
count++;
111+
final String path = paramNames.get(i)
112+
.replace('$', '.');
113+
declaration
114+
.append("{@link ")
115+
.append(annotationMetaEntity.importType(entity))
116+
.append('#')
117+
.append(qualifier(path))
118+
.append(' ')
119+
.append(path)
120+
.append("}");
103121
}
104-
final String path = param.replace('$', '.');
105-
declaration
106-
.append("{@link ")
107-
.append(annotationMetaEntity.importType(entity))
108-
.append('#')
109-
.append(qualifier(path))
110-
.append(' ')
111-
.append(path)
112-
.append("}");
113122
}
114123
declaration
115124
.append('.')

tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/QueryMethod.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,8 @@ private String getConstantName() {
254254
else {
255255
return stem + "_"
256256
+ paramTypes.stream()
257-
.filter(name -> !isPageParam(name) && !isOrderParam(name))
257+
.filter(type -> !isPageParam(type) && !isOrderParam(type)
258+
&& !isSessionParameter(type))
258259
.map(StringHelper::unqualify)
259260
.reduce((x,y) -> x + '_' + y)
260261
.orElse("");

0 commit comments

Comments
 (0)