small fixes to @Find and @HQL methods

don't include session parameter type where not necessary
This commit is contained in:
Gavin King 2024-02-03 00:11:43 +01:00
parent 8e4755f84e
commit f4d17be10c
2 changed files with 31 additions and 21 deletions

View File

@ -88,28 +88,37 @@ public abstract class AbstractFinderMethod extends AbstractQueryMethod {
.append("{@link ") .append("{@link ")
.append(annotationMetaEntity.importType(entity)) .append(annotationMetaEntity.importType(entity))
.append("} by "); .append("} by ");
int paramCount = paramNames.size(); long paramCount = paramTypes.stream()
for (int i = 0; i < paramCount; i++) { .filter(type -> !isOrderParam(type) && !isPageParam(type)
String param = paramNames.get(i); && !isSessionParameter(type))
if ( i>0 ) { .count();
if ( i + 1 == paramCount) { int count = 0;
declaration for (int i = 0; i < paramTypes.size(); i++) {
.append(paramCount>2 ? ", and " : " and "); //Oxford comma String type = paramTypes.get(i);
} if ( !isPageParam(type) && !isOrderParam(type)
else { && !isSessionParameter(type) ) {
declaration if ( count>0 ) {
.append(", "); if ( count + 1 == paramCount) {
declaration
.append(paramCount>2 ? ", and " : " and "); //Oxford comma
}
else {
declaration
.append(", ");
}
} }
count++;
final String path = paramNames.get(i)
.replace('$', '.');
declaration
.append("{@link ")
.append(annotationMetaEntity.importType(entity))
.append('#')
.append(qualifier(path))
.append(' ')
.append(path)
.append("}");
} }
final String path = param.replace('$', '.');
declaration
.append("{@link ")
.append(annotationMetaEntity.importType(entity))
.append('#')
.append(qualifier(path))
.append(' ')
.append(path)
.append("}");
} }
declaration declaration
.append('.') .append('.')

View File

@ -254,7 +254,8 @@ public class QueryMethod extends AbstractQueryMethod {
else { else {
return stem + "_" return stem + "_"
+ paramTypes.stream() + paramTypes.stream()
.filter(name -> !isPageParam(name) && !isOrderParam(name)) .filter(type -> !isPageParam(type) && !isOrderParam(type)
&& !isSessionParameter(type))
.map(StringHelper::unqualify) .map(StringHelper::unqualify)
.reduce((x,y) -> x + '_' + y) .reduce((x,y) -> x + '_' + y)
.orElse(""); .orElse("");