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

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