|
11 | 11 | import com.beyt.jdq.util.ApplicationContextUtil; |
12 | 12 | import lombok.extern.slf4j.Slf4j; |
13 | 13 | import org.apache.commons.collections4.IterableUtils; |
14 | | -import org.hibernate.metamodel.model.domain.internal.SingularAttributeImpl; |
15 | | -import org.hibernate.query.criteria.internal.path.RootImpl; |
16 | | -import org.hibernate.query.criteria.internal.path.SingularAttributePath; |
| 14 | +import org.hibernate.query.criteria.JpaRoot; |
| 15 | +import org.hibernate.query.sqm.tree.domain.AbstractSqmPath; |
17 | 16 | import org.springframework.core.GenericTypeResolver; |
18 | 17 | import org.springframework.data.domain.Page; |
19 | 18 | import org.springframework.data.domain.PageImpl; |
20 | 19 | import org.springframework.data.domain.PageRequest; |
21 | 20 | import org.springframework.data.domain.Pageable; |
22 | 21 | import org.springframework.data.jpa.domain.Specification; |
23 | 22 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
24 | | -import org.springframework.data.repository.support.PageableExecutionUtils; |
| 23 | +import org.springframework.data.support.PageableExecutionUtils; |
25 | 24 | import org.springframework.data.util.Pair; |
26 | 25 | import org.springframework.lang.Nullable; |
27 | 26 | import org.springframework.util.Assert; |
28 | 27 | import org.springframework.util.CollectionUtils; |
29 | 28 |
|
30 | | -import javax.persistence.EntityManager; |
31 | | -import javax.persistence.Tuple; |
32 | | -import javax.persistence.TypedQuery; |
33 | | -import javax.persistence.criteria.*; |
| 29 | +import jakarta.persistence.metamodel.Attribute; |
| 30 | +import jakarta.persistence.EntityManager; |
| 31 | +import jakarta.persistence.Tuple; |
| 32 | +import jakarta.persistence.TypedQuery; |
| 33 | +import jakarta.persistence.criteria.*; |
34 | 34 | import java.lang.reflect.Field; |
35 | 35 | import java.lang.reflect.Method; |
36 | 36 | import java.util.*; |
@@ -156,8 +156,8 @@ protected static <Entity, ResultType> Iterable<ResultType> getEntityListBySelect |
156 | 156 | } else { |
157 | 157 |
|
158 | 158 | if (!IterableUtils.isEmpty(entityListBySelectableFilter)) { |
159 | | - List<Pair<String, String>> parameters = entityListBySelectableFilter.iterator().next().getElements().stream().filter(e -> SingularAttributePath.class.isAssignableFrom(e.getClass())) |
160 | | - .map(e -> Pair.of(((SingularAttributePath) e).getAttribute().getName(), Objects.isNull(e.getAlias()) ? ((SingularAttributePath) e).getAttribute().getName() : e.getAlias())).collect(Collectors.toList()); |
| 159 | + List<Pair<String, String>> parameters = entityListBySelectableFilter.iterator().next().getElements().stream().filter(e -> AbstractSqmPath.class.isAssignableFrom(e.getClass())) |
| 160 | + .map(e -> Pair.of(((AbstractSqmPath) e).getModel().getPathName(), Objects.isNull(e.getAlias()) ? ((AbstractSqmPath) e).getModel().getPathName() : e.getAlias())).collect(Collectors.toList()); |
161 | 161 | return convertResultToResultTypeList(parameters, resultTypeClass, entityListBySelectableFilter, isPage); |
162 | 162 | } else { |
163 | 163 | return new ArrayList<>(); |
@@ -204,8 +204,8 @@ protected static <Entity, ResultType> Iterable<ResultType> getEntityListWithRetu |
204 | 204 | query.multiselect(selectionList); |
205 | 205 | } else if (!resultTypeClass.equals(entityClass)) { |
206 | 206 | List<Selection<?>> selectionList = new ArrayList<>(); |
207 | | - Set<SingularAttributeImpl> declaredAttributes = ((RootImpl) root).getModel().getDeclaredAttributes(); |
208 | | - for (SingularAttributeImpl declaredAttribute : declaredAttributes) { |
| 207 | + Set<Attribute> declaredAttributes = ((JpaRoot) root).getModel().getDeclaredAttributes(); |
| 208 | + for (Attribute declaredAttribute : declaredAttributes) { |
209 | 209 | selectionList.add(root.get(declaredAttribute.getName())); |
210 | 210 | } |
211 | 211 | query.multiselect(selectionList); |
|
0 commit comments