no message
This commit is contained in:
parent
fec219c3ee
commit
4d191f50ca
|
@ -26,7 +26,7 @@ public class UserTokenDaoImpl extends DatabaseAccess<UserToken> implements UserT
|
|||
|
||||
@Override
|
||||
public UserToken find(UUID id) {
|
||||
return this.getDatabaseService().getQueryable(UserToken.class).where((builder, root) -> builder.equal(root.get("token"),id)).getSingle();
|
||||
return this.getDatabaseService().getQueryable(UserToken.class).where((builder, root) -> builder.equal(root.get("token"),id)).getSingleOrDefault();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,6 +19,8 @@ public interface QueryableList<T extends DataEntity<T>> {
|
|||
|
||||
T getSingle();
|
||||
|
||||
T getSingleOrDefault();
|
||||
|
||||
QueryableList<T> skip(Integer offset);
|
||||
|
||||
QueryableList<T> take(Integer length);
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package eu.eudat.queryable.exceptions;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 1/30/2018.
|
||||
*/
|
||||
public class NotSingleResultException extends RuntimeException{
|
||||
public NotSingleResultException() {
|
||||
super();
|
||||
}
|
||||
public NotSingleResultException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
public NotSingleResultException(String message) {
|
||||
super(message);
|
||||
}
|
||||
public NotSingleResultException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
|
@ -3,6 +3,7 @@ package eu.eudat.queryable.hibernatequeryablelist;
|
|||
|
||||
import eu.eudat.entities.DataEntity;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.queryable.exceptions.NotSingleResultException;
|
||||
import eu.eudat.queryable.predicates.OrderByPredicate;
|
||||
import eu.eudat.queryable.predicates.SelectPredicate;
|
||||
import eu.eudat.queryable.predicates.SinglePredicate;
|
||||
|
@ -133,6 +134,18 @@ public class QueryableHibernateList<T extends DataEntity<T>> implements Queryabl
|
|||
return typedQuery.getSingleResult();
|
||||
}
|
||||
|
||||
public T getSingleOrDefault() {
|
||||
Predicate[] array = new Predicate[this.predicates.size()];
|
||||
this.predicates.toArray(array);
|
||||
this.query.where(array);
|
||||
|
||||
TypedQuery<T> typedQuery = this.manager.createQuery(this.query);
|
||||
List<T> results = typedQuery.getResultList();
|
||||
if (results.size() == 0) return null;
|
||||
if (results.size() == 1) return results.get(0);
|
||||
else throw new NotSingleResultException("Query returned more than one items");
|
||||
}
|
||||
|
||||
private TypedQuery<T> queryWithHint(List ids) {
|
||||
CriteriaBuilder criteriaBuilder = this.manager.getCriteriaBuilder();
|
||||
CriteriaQuery<T> criteriaQuery = criteriaBuilder.createQuery(tClass);
|
||||
|
|
|
@ -26,7 +26,6 @@ export class DatasetWizardModel implements Serializable<DatasetWizardModel> {
|
|||
public externalDatasets: ExternalDatasetModel[] = [];
|
||||
public dmp: DataManagementPlanModel = new DataManagementPlanModel();
|
||||
public datasetProfileDefinition;
|
||||
public properties: any;
|
||||
public errorModel: BaseErrorModel = new BaseErrorModel();
|
||||
|
||||
fromJSONObject(item: any): DatasetWizardModel {
|
||||
|
|
Loading…
Reference in New Issue