fix @Find method with varargs Order parameter
This commit is contained in:
parent
a7d57357d1
commit
2cfe93cd88
|
@ -15,6 +15,7 @@ import org.hibernate.query.Page;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import static java.util.stream.Collectors.toList;
|
||||
import static org.hibernate.jpamodelgen.util.Constants.SESSION_TYPES;
|
||||
import static org.hibernate.jpamodelgen.util.TypeUtils.isPrimitive;
|
||||
|
||||
|
@ -69,6 +70,14 @@ public abstract class AbstractQueryMethod implements MetaAttribute {
|
|||
|
||||
abstract boolean isNullable(int index);
|
||||
|
||||
List<String> parameterTypes() {
|
||||
return paramTypes.stream()
|
||||
.map(paramType -> isOrderParam(paramType) && paramType.endsWith("[]")
|
||||
? paramType.substring(0, paramType.length() - 2) + "..."
|
||||
: paramType)
|
||||
.collect(toList());
|
||||
}
|
||||
|
||||
String parameterList() {
|
||||
return paramTypes.stream()
|
||||
.map(this::strip)
|
||||
|
|
|
@ -46,6 +46,7 @@ public class CriteriaFinderMethod extends AbstractFinderMethod {
|
|||
|
||||
@Override
|
||||
public String getAttributeDeclarationString() {
|
||||
final List<String> paramTypes = parameterTypes();
|
||||
final StringBuilder declaration = new StringBuilder();
|
||||
comment( declaration );
|
||||
modifiers( declaration );
|
||||
|
|
|
@ -9,12 +9,9 @@ package org.hibernate.jpamodelgen.annotation;
|
|||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.jpamodelgen.util.Constants;
|
||||
import org.hibernate.query.Order;
|
||||
import org.hibernate.query.Page;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static java.util.stream.Collectors.toList;
|
||||
import static org.hibernate.jpamodelgen.util.StringUtil.getUpperUnderscoreCaseFromLowerCamelCase;
|
||||
|
||||
/**
|
||||
|
@ -205,14 +202,6 @@ public class QueryMethod extends AbstractQueryMethod {
|
|||
return type;
|
||||
}
|
||||
|
||||
private List<String> parameterTypes() {
|
||||
return paramTypes.stream()
|
||||
.map(paramType -> isOrderParam(paramType) && paramType.endsWith("[]")
|
||||
? paramType.substring(0, paramType.length() - 2) + "..."
|
||||
: paramType)
|
||||
.collect(toList());
|
||||
}
|
||||
|
||||
private void comment(StringBuilder declaration) {
|
||||
declaration
|
||||
.append("\n/**");
|
||||
|
|
|
@ -74,4 +74,10 @@ public interface Dao {
|
|||
|
||||
@Find
|
||||
List<Bean> beansForText(String text);
|
||||
|
||||
@HQL("where isbn = ?1")
|
||||
List<Book> sortedBooksForIsbn(String isbn, Order<? super Book>... order);
|
||||
|
||||
@Find
|
||||
List<Book> sortedBooks(String isbn, Order<? super Book>... order);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue