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(annotationMetaEntity.importType(entity))
.append("} by ");
int paramCount = paramNames.size();
for (int i = 0; i < paramCount; i++) {
String param = paramNames.get(i);
if ( i>0 ) {
if ( i + 1 == paramCount) {
declaration
.append(paramCount>2 ? ", and " : " and "); //Oxford comma
}
else {
declaration
.append(", ");
long paramCount = paramTypes.stream()
.filter(type -> !isOrderParam(type) && !isPageParam(type)
&& !isSessionParameter(type))
.count();
int count = 0;
for (int i = 0; i < paramTypes.size(); i++) {
String type = paramTypes.get(i);
if ( !isPageParam(type) && !isOrderParam(type)
&& !isSessionParameter(type) ) {
if ( count>0 ) {
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
.append('.')

View File

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