public T findOne(String gyosekiKey, String userKey, Timestamp updDate) { // 必須 Specification<T> whereGyosekiKey = new Specification<T>() { @Override public Predicate toPredicate(Root<T> root, CriteriaQuery<?> query, CriteriaBuilder cb) { return cb.equal(root.get("gyosekiKey"), gyosekiKey); } }; // 必須 Specification<T> whereUserKey = new Specification<T>() { @Override public Predicate toPredicate(Root<T> root, CriteriaQuery<?> query, CriteriaBuilder cb) { return cb.equal(root.get("usUserTbl").get("userKey"), userKey); } }; // 更新日 Specification<T> whereUpdDate = updDate == null ? null : new Specification<T>() { @Override public Predicate toPredicate( Root<T> root, CriteriaQuery<?> query, CriteriaBuilder cb) { return cb.equal(root.get("updDate"), updDate); } }; return (T) repository.findOne( (Specification<T>) Specifications.where(whereGyosekiKey).and(whereUserKey).and(whereUpdDate)); }
/** * Deletes an entity * * @param id The id of the entity to delete */ public void delete(String id) { if (repository.findOne(id) == null) { throw new ResourceNotFoundException(String.format(NOT_FOUND, id)); } repository.delete(id); }
/** * Deletes an entity * * @param entity to be updated. Must include db ID. */ public void update(E entity) { if (repository.findOne(entity.getId()) == null) { throw new ResourceNotFoundException(String.format(NOT_FOUND, entity.getId())); } repository.save(entity); }
/** * Returns an entity by its id * * @param id The id of the entity * @return The entity */ public Optional<E> getById(String id) { return Optional.ofNullable(repository.findOne(id)); }