no message
This commit is contained in:
parent
bf10c0c31c
commit
39f124cd63
|
@ -4,7 +4,7 @@ import eu.eudat.dao.databaselayer.service.DatabaseService;
|
|||
import eu.eudat.entities.DataEntity;
|
||||
|
||||
|
||||
public class DatabaseAccess<T extends DataEntity<T>> {
|
||||
public class DatabaseAccess<T extends DataEntity> {
|
||||
private DatabaseService<T> databaseService;
|
||||
|
||||
public DatabaseService<T> getDatabaseService() {
|
||||
|
|
|
@ -4,7 +4,7 @@ package eu.eudat.dao;
|
|||
import eu.eudat.entities.DataEntity;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
|
||||
public interface DatabaseAccessLayer<T extends DataEntity<T>, I> {
|
||||
public interface DatabaseAccessLayer<T extends DataEntity, I> {
|
||||
T createOrUpdate(T item);
|
||||
|
||||
T find(I id);
|
||||
|
|
|
@ -13,7 +13,7 @@ import javax.persistence.PersistenceContext;
|
|||
|
||||
|
||||
@Repository("databaseCtx")
|
||||
public class DatabaseContext<T extends DataEntity<T>> {
|
||||
public class DatabaseContext<T extends DataEntity> {
|
||||
|
||||
@PersistenceContext
|
||||
private EntityManager entityManager;
|
||||
|
@ -30,8 +30,8 @@ public class DatabaseContext<T extends DataEntity<T>> {
|
|||
@Transactional
|
||||
public T createOrUpdate(T item, Class<T> type) {
|
||||
EntityManager entityManager = this.entityManager;
|
||||
if (item.getKeys()[0] != null) {
|
||||
T oldItem = entityManager.find(type, item.getKeys()[0]);
|
||||
if (item.getKeys() != null) {
|
||||
T oldItem = entityManager.find(type, item.getKeys());
|
||||
if (oldItem != null) {
|
||||
oldItem.update(item);
|
||||
entityManager.merge(oldItem);
|
||||
|
|
|
@ -11,7 +11,7 @@ import java.util.Set;
|
|||
|
||||
|
||||
@Service("databaseService")
|
||||
public class DatabaseService<T extends DataEntity<T>> {
|
||||
public class DatabaseService<T extends DataEntity> {
|
||||
|
||||
private DatabaseContext<T> databaseCtx;
|
||||
|
||||
|
|
|
@ -17,5 +17,4 @@ public interface DMPDao extends DatabaseAccessLayer<DMP, UUID> {
|
|||
|
||||
QueryableList<DMP> getAuthenticated(QueryableList<DMP> query, UserInfo principal);
|
||||
|
||||
Long count();
|
||||
}
|
|
@ -77,8 +77,4 @@ public class DMPDaoImpl extends DatabaseAccess<DMP> implements DMPDao {
|
|||
return this.getDatabaseService().getQueryable(DMP.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long count() {
|
||||
return this.getDatabaseService().count(DMP.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,5 +19,4 @@ public interface DatasetDao extends DatabaseAccessLayer<Dataset, UUID> {
|
|||
|
||||
Dataset find(UUID id, String hint);
|
||||
|
||||
Long count();
|
||||
}
|
|
@ -61,11 +61,6 @@ public class DatasetDaoImpl extends DatabaseAccess<Dataset> implements DatasetDa
|
|||
return query;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long count() {
|
||||
return this.getDatabaseService().count(Dataset.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Dataset item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
|
|
|
@ -14,5 +14,4 @@ public interface ProjectDao extends DatabaseAccessLayer<Project, UUID> {
|
|||
|
||||
QueryableList<Project> getAuthenticated(QueryableList<Project> query, UserInfo principal);
|
||||
|
||||
Long count();
|
||||
}
|
|
@ -44,11 +44,6 @@ public class ProjectDaoImpl extends DatabaseAccess<Project> implements ProjectDa
|
|||
return getDatabaseService().getQueryable(Project.class).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long count() {
|
||||
return this.getDatabaseService().count(Project.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Project item) {
|
||||
this.getDatabaseService().delete(item);
|
||||
|
|
|
@ -7,7 +7,7 @@ import java.util.UUID;
|
|||
|
||||
@Entity
|
||||
@Table(name = "\"Credential\"")
|
||||
public class Credential implements DataEntity<Credential> {
|
||||
public class Credential implements DataEntity<Credential,UUID> {
|
||||
|
||||
@Id
|
||||
@Column(name = "\"Id\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
||||
|
@ -119,7 +119,7 @@ public class Credential implements DataEntity<Credential> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object[] getKeys() {
|
||||
return new UUID[]{this.id == null ? null : this.id};
|
||||
public UUID getKeys() {
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.util.*;
|
|||
@NamedAttributeNode("project"), @NamedAttributeNode("profile"),
|
||||
@NamedAttributeNode("users"), @NamedAttributeNode("organisations"), @NamedAttributeNode("researchers")})
|
||||
})
|
||||
public class DMP implements Serializable, DataEntity<DMP> {
|
||||
public class DMP implements DataEntity<DMP,UUID> {
|
||||
|
||||
public enum DMPStatus {
|
||||
ACTIVE((short) 0), DELETED((short) 1);
|
||||
|
@ -286,8 +286,8 @@ public class DMP implements Serializable, DataEntity<DMP> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object[] getKeys() {
|
||||
return new UUID[]{this.id == null ? null : this.id};
|
||||
public UUID getKeys() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import java.util.UUID;
|
|||
|
||||
@Entity
|
||||
@Table(name = "\"DMPOrganisation\"")
|
||||
public class DMPOrganisation implements Serializable {
|
||||
public class DMPOrganisation {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package eu.eudat.entities;
|
||||
|
||||
public interface DataEntity<T> {
|
||||
public interface DataEntity<T,K> {
|
||||
void update(T entity);
|
||||
|
||||
Object[] getKeys();
|
||||
K getKeys();
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import java.util.UUID;
|
|||
|
||||
@Entity
|
||||
@Table(name = "\"DataRepository\"")
|
||||
public class DataRepository implements Serializable, DataEntity<DataRepository> {
|
||||
public class DataRepository implements Serializable, DataEntity<DataRepository,UUID> {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
|
@ -147,7 +147,7 @@ public class DataRepository implements Serializable, DataEntity<DataRepository>
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object[] getKeys() {
|
||||
return new UUID[]{this.id == null ? null : this.id};
|
||||
public UUID getKeys() {
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ import java.util.*;
|
|||
attributeNodes = {@NamedAttributeNode("services"), @NamedAttributeNode("dataRepositories"), @NamedAttributeNode("externalDatasets"), @NamedAttributeNode("registries"),
|
||||
@NamedAttributeNode("dmp"), @NamedAttributeNode("profile"), @NamedAttributeNode("creator")})
|
||||
})
|
||||
public class Dataset implements DataEntity<Dataset> {
|
||||
public class Dataset implements DataEntity<Dataset,UUID> {
|
||||
|
||||
public static Set<String> getHints() {
|
||||
return hints;
|
||||
|
@ -313,7 +313,7 @@ public class Dataset implements DataEntity<Dataset> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object[] getKeys() {
|
||||
return new UUID[]{this.id == null ? null : this.id};
|
||||
public UUID getKeys() {
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ import java.util.UUID;
|
|||
|
||||
@Entity
|
||||
@Table(name = "\"DatasetProfile\"")
|
||||
public class DatasetProfile implements Serializable, DataEntity<DatasetProfile> {
|
||||
public class DatasetProfile implements DataEntity<DatasetProfile,UUID> {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
|
@ -132,7 +132,7 @@ public class DatasetProfile implements Serializable, DataEntity<DatasetProfile>
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object[] getKeys() {
|
||||
return new UUID[]{this.id == null ? null : this.id};
|
||||
public UUID getKeys() {
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import java.util.UUID;
|
|||
|
||||
@Entity
|
||||
@Table(name = "\"DatasetProfileRuleset\"")
|
||||
public class DatasetProfileRuleset implements Serializable {
|
||||
public class DatasetProfileRuleset {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
|
|
|
@ -11,7 +11,7 @@ import java.util.UUID;
|
|||
|
||||
@Entity
|
||||
@Table(name = "\"DatasetRegistry\"")
|
||||
public class DatasetRegistry implements Serializable {
|
||||
public class DatasetRegistry {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
|
|
|
@ -11,7 +11,7 @@ import java.util.UUID;
|
|||
|
||||
@Entity
|
||||
@Table(name = "\"DatasetService\"")
|
||||
public class DatasetService implements Serializable {
|
||||
public class DatasetService {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
|
|
|
@ -10,7 +10,7 @@ import java.util.UUID;
|
|||
|
||||
@Entity
|
||||
@Table(name = "\"ExternalDataset\"")
|
||||
public class ExternalDataset implements DataEntity<ExternalDataset> {
|
||||
public class ExternalDataset implements DataEntity<ExternalDataset,UUID> {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
|
@ -104,7 +104,7 @@ public class ExternalDataset implements DataEntity<ExternalDataset> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object[] getKeys() {
|
||||
return new UUID[]{this.id == null ? null : this.id};
|
||||
public UUID getKeys() {
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import java.util.UUID;
|
|||
|
||||
@Entity
|
||||
@Table(name = "\"Invitation\"")
|
||||
public class Invitation implements DataEntity<Invitation> {
|
||||
public class Invitation implements DataEntity<Invitation,UUID> {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
|
@ -100,7 +100,7 @@ public class Invitation implements DataEntity<Invitation> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object[] getKeys() {
|
||||
return new UUID[]{this.id == null ? null : this.id};
|
||||
public UUID getKeys() {
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ import java.util.UUID;
|
|||
|
||||
@Entity
|
||||
@Table(name = "\"Organisation\"")
|
||||
public class Organisation implements Serializable, DataEntity<Organisation> {
|
||||
public class Organisation implements Serializable, DataEntity<Organisation,UUID> {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
|
@ -151,7 +151,7 @@ public class Organisation implements Serializable, DataEntity<Organisation> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object[] getKeys() {
|
||||
return new UUID[]{this.id == null ? null : this.id};
|
||||
public UUID getKeys() {
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ import java.util.UUID;
|
|||
|
||||
@Entity
|
||||
@Table(name = "\"Project\"")
|
||||
public class Project implements DataEntity<Project> {
|
||||
public class Project implements DataEntity<Project,UUID> {
|
||||
|
||||
public enum Status {
|
||||
ACTIVE((short) 1), INACTIVE((short) 0), DELETED((short) 99);
|
||||
|
@ -248,7 +248,7 @@ public class Project implements DataEntity<Project> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object[] getKeys() {
|
||||
return new UUID[]{this.id == null ? null : this.id};
|
||||
public UUID getKeys() {
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import java.util.UUID;
|
|||
|
||||
@Entity
|
||||
@Table(name = "\"Registry\"")
|
||||
public class Registry implements DataEntity<Registry> {
|
||||
public class Registry implements DataEntity<Registry,UUID> {
|
||||
|
||||
|
||||
@Id
|
||||
|
@ -149,7 +149,7 @@ public class Registry implements DataEntity<Registry> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object[] getKeys() {
|
||||
return new UUID[]{this.id == null ? null : this.id};
|
||||
public UUID getKeys() {
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import java.util.UUID;
|
|||
|
||||
@Entity
|
||||
@Table(name = "\"Researcher\"")
|
||||
public class Researcher implements DataEntity<Researcher> {
|
||||
public class Researcher implements DataEntity<Researcher,UUID> {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
|
@ -150,7 +150,7 @@ public class Researcher implements DataEntity<Researcher> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object[] getKeys() {
|
||||
return new UUID[]{this.id == null ? null : this.id};
|
||||
public UUID getKeys() {
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import java.util.UUID;
|
|||
|
||||
@Entity
|
||||
@Table(name = "\"Service\"")
|
||||
public class Service implements DataEntity<Service> {
|
||||
public class Service implements DataEntity<Service, UUID> {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
|
@ -150,7 +150,7 @@ public class Service implements DataEntity<Service> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object[] getKeys() {
|
||||
return new UUID[]{this.id == null ? null : this.id};
|
||||
public UUID getKeys() {
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import java.util.UUID;
|
|||
|
||||
@Entity
|
||||
@Table(name = "\"UserDMP\"")
|
||||
public class UserDMP implements DataEntity<UserDMP> {
|
||||
public class UserDMP implements DataEntity<UserDMP, UUID> {
|
||||
|
||||
public enum UserDMPRoles {
|
||||
OWNER(0), USER(1);
|
||||
|
@ -90,7 +90,7 @@ public class UserDMP implements DataEntity<UserDMP> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object[] getKeys() {
|
||||
return new UUID[]{this.id == null ? null : this.id};
|
||||
public UUID getKeys() {
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ import java.util.UUID;
|
|||
name = "userInfo",
|
||||
attributeNodes = {@NamedAttributeNode("userRoles"), @NamedAttributeNode("credentials")})
|
||||
})
|
||||
public class UserInfo implements DataEntity<UserInfo> {
|
||||
public class UserInfo implements DataEntity<UserInfo, UUID> {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
|
@ -173,7 +173,7 @@ public class UserInfo implements DataEntity<UserInfo> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object[] getKeys() {
|
||||
return new UUID[]{this.id == null ? null : this.id};
|
||||
public UUID getKeys() {
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import java.util.UUID;
|
|||
|
||||
@Entity
|
||||
@Table(name = "\"UserRole\"")
|
||||
public class UserRole implements DataEntity<UserRole> {
|
||||
public class UserRole implements DataEntity<UserRole, UUID> {
|
||||
|
||||
@Id
|
||||
@GeneratedValue
|
||||
|
@ -53,7 +53,7 @@ public class UserRole implements DataEntity<UserRole> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object[] getKeys() {
|
||||
return new UUID[]{this.id == null ? null : this.id};
|
||||
public UUID getKeys() {
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import java.util.UUID;
|
|||
|
||||
@Entity
|
||||
@Table(name = "\"UserToken\"")
|
||||
public class UserToken implements DataEntity<UserToken> {
|
||||
public class UserToken implements DataEntity<UserToken, UUID> {
|
||||
|
||||
@Id
|
||||
@Column(name = "\"Token\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
||||
|
@ -62,7 +62,7 @@ public class UserToken implements DataEntity<UserToken> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Object[] getKeys() {
|
||||
return new UUID[]{this.token == null ? null : this.token};
|
||||
public UUID getKeys() {
|
||||
return this.token;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,9 +11,9 @@ public class DashBoardManager {
|
|||
|
||||
public DashBoardStatistics getStatistics(DatasetDao datasetRepository, DMPDao dataManagementPlanRepository, ProjectDao projectRepository) {
|
||||
DashBoardStatistics statistics = new DashBoardStatistics();
|
||||
statistics.setTotalDataManagementPlanCount(dataManagementPlanRepository.count());
|
||||
statistics.setTotalDataSetCount(datasetRepository.count());
|
||||
statistics.setTotalProjectCount(projectRepository.count());
|
||||
statistics.setTotalDataManagementPlanCount(dataManagementPlanRepository.asQueryable().count());
|
||||
statistics.setTotalDataSetCount(datasetRepository.asQueryable().count());
|
||||
statistics.setTotalProjectCount(projectRepository.asQueryable().count());
|
||||
return statistics;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,14 +10,14 @@ import java.util.Collection;
|
|||
|
||||
public class PaginationManager {
|
||||
|
||||
public static <T extends DataEntity<T>> QueryableList<T> applyPaging(QueryableList<T> items, TableRequest tableRequest) throws Exception {
|
||||
public static <T extends DataEntity> QueryableList<T> applyPaging(QueryableList<T> items, TableRequest tableRequest) throws Exception {
|
||||
if (tableRequest.getOrderings() != null) applyOrder(items, tableRequest);
|
||||
if (tableRequest.getLength() != null) items.take(tableRequest.getLength());
|
||||
if (tableRequest.getOffset() != null) items.skip(tableRequest.getOffset());
|
||||
return items;
|
||||
}
|
||||
|
||||
public static <T extends DataEntity<T>> void applyOrder(QueryableList<T> items, TableRequest tableRequest) throws Exception {
|
||||
public static <T extends DataEntity> void applyOrder(QueryableList<T> items, TableRequest tableRequest) throws Exception {
|
||||
ColumnOrderings columnOrderings = tableRequest.getOrderings();
|
||||
for (Ordering ordering : columnOrderings.getFieldOrderings()) {
|
||||
if (ordering.getOrderByType() == Ordering.OrderByType.ASC)
|
||||
|
@ -29,7 +29,7 @@ public class PaginationManager {
|
|||
return;
|
||||
}
|
||||
|
||||
private static <T extends DataEntity<T>> void applyAscOrder(QueryableList<T> items, Ordering ordering) {
|
||||
private static <T extends DataEntity> void applyAscOrder(QueryableList<T> items, Ordering ordering) {
|
||||
if (ordering.getColumnType() == Ordering.ColumnType.COUNT) {
|
||||
items.orderBy((builder, root) -> builder.asc(builder.size(root.<Collection>get(ordering.getFieldName()))));
|
||||
} else if (ordering.getColumnType() == Ordering.ColumnType.JOIN_COLUMN) {
|
||||
|
@ -40,7 +40,7 @@ public class PaginationManager {
|
|||
}
|
||||
}
|
||||
|
||||
private static <T extends DataEntity<T>> void applyDescOrder(QueryableList<T> items, Ordering ordering) {
|
||||
private static <T extends DataEntity> void applyDescOrder(QueryableList<T> items, Ordering ordering) {
|
||||
if (ordering.getColumnType() == Ordering.ColumnType.COUNT) {
|
||||
items.orderBy((builder, root) -> builder.desc(builder.size(root.<Collection>get(ordering.getFieldName()))));
|
||||
} else if (ordering.getColumnType() == Ordering.ColumnType.JOIN_COLUMN) {
|
||||
|
|
|
@ -13,7 +13,7 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public interface QueryableList<T extends DataEntity<T>> {
|
||||
public interface QueryableList<T extends DataEntity> {
|
||||
QueryableList<T> where(SinglePredicate<T> predicate);
|
||||
|
||||
<R> List<R> select(SelectPredicate<T, R> predicate);
|
||||
|
|
|
@ -21,12 +21,12 @@ import java.util.Set;
|
|||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class QueryableHibernateList<T extends DataEntity<T>> implements QueryableList<T> {
|
||||
public class QueryableHibernateList<T extends DataEntity> implements QueryableList<T> {
|
||||
|
||||
private EntityManager manager;
|
||||
private CriteriaQuery<T> query;
|
||||
private CriteriaQuery query;
|
||||
private Class<T> tClass;
|
||||
private Root<T> root;
|
||||
private Root root;
|
||||
private Root<T> nestedQueryRoot;
|
||||
private Subquery<T> subquery;
|
||||
private List<SinglePredicate<T>> singlePredicates = new LinkedList<>();
|
||||
|
@ -61,7 +61,7 @@ public class QueryableHibernateList<T extends DataEntity<T>> implements Queryabl
|
|||
|
||||
public QueryableHibernateList<T> setEntity(Class<T> type) {
|
||||
CriteriaBuilder builder = this.manager.getCriteriaBuilder();
|
||||
this.query = builder.createQuery(type);
|
||||
this.query = builder.createTupleQuery();
|
||||
this.root = this.query.from(this.tClass);
|
||||
return this;
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ public class QueryableHibernateList<T extends DataEntity<T>> implements Queryabl
|
|||
if (this.offset != null) typedQuery.setFirstResult(this.offset);
|
||||
if (this.length != null) typedQuery.setMaxResults(this.length);
|
||||
if (this.hint != null && this.hints.contains(hint)) {
|
||||
List ids = typedQuery.getResultList().stream().map(item -> item.getKeys()[0]).collect(Collectors.toList());
|
||||
List ids = typedQuery.getResultList().stream().map(item -> item.getKeys()).collect(Collectors.toList());
|
||||
if (ids != null && !ids.isEmpty()) typedQuery = queryWithHint(ids);
|
||||
}
|
||||
return typedQuery.getResultList();
|
||||
|
@ -184,7 +184,7 @@ public class QueryableHibernateList<T extends DataEntity<T>> implements Queryabl
|
|||
if (this.length != null) typedQuery.setMaxResults(this.length);
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
if (this.hint != null && this.hints.contains(hint)) {
|
||||
List ids = typedQuery.getResultList().stream().map(item -> item.getKeys()[0]).collect(Collectors.toList());
|
||||
List ids = typedQuery.getResultList().stream().map(item -> item.getKeys()).collect(Collectors.toList());
|
||||
if (ids != null && !ids.isEmpty()) return queryWithHint(ids).getResultList();
|
||||
}
|
||||
return typedQuery.getResultList();
|
||||
|
@ -236,7 +236,6 @@ public class QueryableHibernateList<T extends DataEntity<T>> implements Queryabl
|
|||
CriteriaBuilder criteriaBuilder = this.manager.getCriteriaBuilder();
|
||||
CriteriaQuery<T> criteriaQuery = criteriaBuilder.createQuery(tClass);
|
||||
Root<T> criteriaRoot = criteriaQuery.from(this.tClass);
|
||||
|
||||
criteriaQuery.where(criteriaRoot.get("id").in(ids));
|
||||
if (!this.orderings.isEmpty())
|
||||
criteriaQuery.orderBy(this.generateOrderPredicates(this.orderings, criteriaRoot));
|
||||
|
|
Loading…
Reference in New Issue