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,11 +88,17 @@ 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) {
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
}
@ -101,7 +107,9 @@ public abstract class AbstractFinderMethod extends AbstractQueryMethod {
.append(", ");
}
}
final String path = param.replace('$', '.');
count++;
final String path = paramNames.get(i)
.replace('$', '.');
declaration
.append("{@link ")
.append(annotationMetaEntity.importType(entity))
@ -111,6 +119,7 @@ public abstract class AbstractFinderMethod extends AbstractQueryMethod {
.append(path)
.append("}");
}
}
declaration
.append('.')
.append("\n *");

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("");