diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/AbstractQueryMethod.java b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/AbstractQueryMethod.java index b85d5609e3..b432ffb2b9 100644 --- a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/AbstractQueryMethod.java +++ b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/AbstractQueryMethod.java @@ -248,93 +248,10 @@ public abstract class AbstractQueryMethod implements MetaAttribute { if ( isPageParam(paramType) ) { setPage( declaration, paramName, paramType ); } -// if ( isOrderParam(paramType) && !isJakartaSortParam(paramType) ) { -// setOrder( declaration, unwrapped, paramName, paramType ); -// unwrapped = true; -// } } } } -// boolean setOrder(StringBuilder declaration, boolean unwrapped, String paramName, String paramType) { -// unwrapQuery( declaration, unwrapped ); -// if ( paramType.startsWith(JD_ORDER) -// || paramType.startsWith(JD_PAGE_REQUEST) ) { -// final String sortableEntityClass = getSortableEntityClass(); -// if ( sortableEntityClass != null ) { -// annotationMetaEntity.staticImport("org.hibernate.query.SortDirection", "*"); -// annotationMetaEntity.staticImport(Collectors.class.getName(), "toList"); -// annotationMetaEntity.staticImport(HIB_ORDER, "by"); -// declaration -// .append("\n\t\t\t.setOrder(") -// .append(paramName) -// .append(".sorts().stream()") -// .append("\n\t\t\t\t\t") -// .append(".map(_sort -> by(") -// .append(annotationMetaEntity.importType(sortableEntityClass)) -// .append(".class, _sort.property(),") -// .append("\n\t\t\t\t\t\t\t") -// .append("_sort.isAscending() ? ASCENDING : DESCENDING,") -// .append("\n\t\t\t\t\t\t\t") -// .append("_sort.ignoreCase()))") -// .append("\n\t\t\t\t\t") -// .append(".collect(toList()))"); -// } -// } -// else if ( paramType.startsWith(JD_SORT) && paramType.endsWith("...") ) { -// final String sortableEntityClass = getSortableEntityClass(); -// if ( sortableEntityClass != null ) { -// annotationMetaEntity.staticImport("org.hibernate.query.SortDirection", "*"); -// annotationMetaEntity.staticImport(Arrays.class.getName(), "asList"); -// annotationMetaEntity.staticImport(Collectors.class.getName(), "toList"); -// annotationMetaEntity.staticImport(HIB_ORDER, "by"); -// declaration -// .append("\n\t\t\t.setOrder(asList(") -// .append(paramName) -// .append(").stream().map(_sort -> by(") -// .append(annotationMetaEntity.importType(sortableEntityClass)) -// .append(".class, ") -// .append("_sort.property()") -// .append(",\n\t\t\t\t\t\t") -// .append("_sort.isAscending() ? ASCENDING : DESCENDING, ") -// .append("_sort.ignoreCase()))\n\t\t\t\t.collect(toList())\n\t\t\t)"); -// } -// } -// else if ( paramType.startsWith(JD_SORT) ) { -// final String sortableEntityClass = getSortableEntityClass(); -// if ( sortableEntityClass != null ) { -// annotationMetaEntity.staticImport("org.hibernate.query.SortDirection", "*"); -// declaration -// .append("\n\t\t\t.setOrder(") -// .append(annotationMetaEntity.importType(HIB_ORDER)) -// .append(".by(") -// .append(annotationMetaEntity.importType(sortableEntityClass)) -// .append(".class, ") -// .append(paramName) -// .append(".property()") -// .append(",\n\t\t\t\t\t") -// .append(paramName) -// .append(".isAscending() ? ASCENDING : DESCENDING") -// .append("))"); -// } -// } -// else if ( paramType.endsWith("...") ) { -// declaration -// .append("\n\t\t\t.setOrder(") -// .append(annotationMetaEntity.importType(LIST)) -// .append(".of(") -// .append(paramName) -// .append("))"); -// } -// else { -// declaration -// .append("\n\t\t\t.setOrder(") -// .append(paramName) -// .append(")"); -// } -// return true; -// } - void convertExceptions(StringBuilder declaration) { if (dataRepository) { declaration @@ -382,16 +299,6 @@ public abstract class AbstractQueryMethod implements MetaAttribute { declaration .append("\t\t\t.unwrap("); final String selectionQuery = annotationMetaEntity.importType(HIB_SELECTION_QUERY); -// final String className = getSortableEntityClass(); -// if ( className != null ) { -// final String entityClass = annotationMetaEntity.importType(className); -// declaration -// .append("(Class<") -// .append(selectionQuery) -// .append("<") -// .append(entityClass) -// .append(">>) (Class) "); -// } declaration .append(selectionQuery) .append(".class)\n"); @@ -572,10 +479,8 @@ public abstract class AbstractQueryMethod implements MetaAttribute { .append(".class, \"") .append(orderBy.fieldName) .append("\", ") -// .append("\n\t\t\t\t\t\t") .append(orderBy.descending ? "DESCENDING" : "ASCENDING") .append(", ") -// .append("\n\t\t\t\t\t\t") .append(orderBy.ignoreCase) .append("));\n"); diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/CriteriaFinderMethod.java b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/CriteriaFinderMethod.java index f78a498bfe..b58de8628e 100644 --- a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/CriteriaFinderMethod.java +++ b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/CriteriaFinderMethod.java @@ -114,9 +114,6 @@ public class CriteriaFinderMethod extends AbstractFinderMethod { boolean unwrapped = !isUsingEntityManager(); unwrapped = enableFetchProfile( declaration, unwrapped ); unwrapped = unwrapIfNecessary( declaration, containerType, unwrapped ); -// if ( unwrapped ) { -// declaration.append("\n\t\t\t"); -// } return unwrapped; } @@ -171,45 +168,6 @@ public class CriteriaFinderMethod extends AbstractFinderMethod { .append(paramName) .append("\");\n"); } -// -// private void orderBy(List paramTypes, StringBuilder declaration) { -// final boolean hasSortParameter = -// paramTypes.stream().anyMatch(CriteriaFinderMethod::isJakartaSortParam); -// if ( !orderBys.isEmpty() || hasSortParameter ) { -// declaration.append("\n\t_query.orderBy("); -// } -// boolean firstOrderBy = true; -// if ( !orderBys.isEmpty() ) { -// for ( OrderBy orderBy : orderBys ) { -// if ( firstOrderBy ) { -// firstOrderBy = false; -// } -// else { -// declaration.append(','); -// } -// orderBy(declaration, orderBy); -// } -// } -// if ( hasSortParameter ) { -// for ( int i = 0; i < paramNames.size(); i ++ ) { -// final String paramName = paramNames.get(i); -// final String paramType = paramTypes.get(i); -// //TODO: Jakarta Order!! -// if ( isJakartaSortParam(paramType) ) { -// if ( firstOrderBy ) { -// firstOrderBy = false; -// } -// else { -// declaration.append(','); -// } -// orderBy(declaration, paramName, paramType.endsWith("...")); -// } -// } -// } -// if ( !orderBys.isEmpty() || hasSortParameter ) { -// declaration.append("\n\t);"); -// } -// } private void where(StringBuilder declaration, List paramTypes) { declaration @@ -233,56 +191,6 @@ public class CriteriaFinderMethod extends AbstractFinderMethod { .append("\n\t);"); } -// private static boolean isJakartaSortParam(String paramType) { -// return paramType.startsWith(JD_SORT); -// } -// -// private static void orderBy(StringBuilder declaration, OrderBy orderBy) { -// declaration -// .append("\n\t\t") -// .append("_builder.") -// .append(orderBy.descending ? "desc" : "asc") -// .append('('); -// if ( orderBy.ignoreCase ) { -// declaration.append("_builder.lower("); -// } -// declaration -// .append("_entity.get(\"") -// .append(orderBy.fieldName) -// .append("\")"); -// if ( orderBy.ignoreCase ) { -// declaration -// .append(')'); -// } -// declaration -// .append(')'); -// } - -// private static final String ORDER_CONVERSION = -// "_builder.sort(_entity.get(_sort.property())," + -// "\n\t\t\t\t\t_sort.isAscending() ? ASCENDING : DESCENDING," + -// "\n\t\t\t\t\tNONE, _sort.ignoreCase())"; - -// private void orderBy(StringBuilder declaration, String paramName, boolean variadic) { -// // TODO: Sort.ignoreCase() -// if ( variadic ) { -// annotationMetaEntity.staticImport(Arrays.class.getName(), "asList"); -// annotationMetaEntity.staticImport(Collectors.class.getName(), "toList"); -// annotationMetaEntity.staticImport(NullPrecedence.class.getName(), "NONE"); -// declaration -// .append("\n\t\tasList(") -// .append(paramName) -// .append(")\n\t\t\t.stream()\n\t\t\t.map(_sort -> ") -// .append(ORDER_CONVERSION) -// .append("\n\t\t\t)\n\t\t\t.collect(toList())"); -// } -// else { -// declaration -// .append("\n\t\t") -// .append(ORDER_CONVERSION.replace("_sort", paramName)); -// } -// } - private void parameter(StringBuilder declaration, int i, String paramName, String paramType) { declaration .append("\n\t\t\t"); diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/QueryMethod.java b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/QueryMethod.java index 342b5a1dda..4c80b8821a 100644 --- a/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/QueryMethod.java +++ b/tooling/metamodel-generator/src/main/java/org/hibernate/jpamodelgen/annotation/QueryMethod.java @@ -106,65 +106,10 @@ public class QueryMethod extends AbstractQueryMethod { private boolean specialNeeds(StringBuilder declaration) { boolean unwrapped = !isUsingEntityManager(); -// if ( isJakartaKeyedSlice(containerType) ) { -// unwrapped = !isUsingEntityManager(); -// } -// else { -// unwrapped = orderBy( declaration, unwrapped ); -// } unwrapped = unwrapIfNecessary( declaration, containerType, unwrapped ); -// if ( isUpdate || containerType == null || !isQueryType(containerType)) { -// declaration -// .append("\t\t\t"); -// } return unwrapped; } -// private boolean isQueryType(String containerType) { -// return HIB_QUERY.equals(containerType) -// || HIB_SELECTION_QUERY.equals(containerType) -// || QUERY.equals(containerType) -// || TYPED_QUERY.equals(containerType); -// } - -// private boolean orderBy(StringBuilder declaration, boolean unwrapped) { -// if ( !orderBys.isEmpty() && returnTypeName!=null ) { -// unwrapQuery( declaration, unwrapped ); -// declaration.append("\n\t\t\t.setOrder("); -// if ( orderBys.size() > 1) { -// annotationMetaEntity.staticImport(Arrays.class.getName(), "asList"); -// declaration -// .append("asList("); -// } -// boolean first = true; -// for (OrderBy orderBy : orderBys) { -// if (first) { -// first = false; -// } -// else { -// declaration -// .append(",\n\t\t\t\t\t\t\t"); -// } -// declaration -// .append(annotationMetaEntity.importType(HIB_ORDER)) -// .append(orderBy.descending ? ".desc(" : ".asc(") -// .append(annotationMetaEntity.importType(returnTypeName)) -// .append(".class, \"") -// .append(orderBy.fieldName) -// .append("\")"); -// } -// if ( orderBys.size() > 1) { -// declaration -// .append(')'); -// } -// declaration.append(')'); -// return true; -// } -// else { -// return unwrapped; -// } -// } - @Override void createQuery(StringBuilder declaration) { declaration