use of com.google.inject.persist.Transactional in project che by eclipse.
the class JpaUserDao method getAll.
@Override
@Transactional
public Page<UserImpl> getAll(int maxItems, long skipCount) throws ServerException {
// TODO need to ensure that 'getAll' query works with same data as 'getTotalCount'
checkArgument(maxItems >= 0, "The number of items to return can't be negative.");
checkArgument(skipCount >= 0 && skipCount <= Integer.MAX_VALUE, "The number of items to skip can't be negative or greater than " + Integer.MAX_VALUE);
try {
final List<UserImpl> list = managerProvider.get().createNamedQuery("User.getAll", UserImpl.class).setMaxResults(maxItems).setFirstResult((int) skipCount).getResultList().stream().map(JpaUserDao::erasePassword).collect(toList());
return new Page<>(list, skipCount, maxItems, getTotalCount());
} catch (RuntimeException x) {
throw new ServerException(x.getLocalizedMessage(), x);
}
}
use of com.google.inject.persist.Transactional in project che by eclipse.
the class JpaSshDao method doCreate.
@Transactional
protected void doCreate(SshPairImpl entity) {
EntityManager manager = managerProvider.get();
manager.persist(entity);
manager.flush();
}
use of com.google.inject.persist.Transactional in project che by eclipse.
the class JpaSshDao method doRemove.
@Transactional
protected void doRemove(String owner, String service, String name) throws NotFoundException {
EntityManager manager = managerProvider.get();
SshPairImpl entity = manager.find(SshPairImpl.class, new SshPairPrimaryKey(owner, service, name));
if (entity == null) {
throw new NotFoundException(format("Ssh pair with service '%s' and name '%s' was not found.", service, name));
}
manager.remove(entity);
manager.flush();
}
use of com.google.inject.persist.Transactional in project pinot by linkedin.
the class TaskManagerImpl method deleteRecordsOlderThanDaysWithStatus.
@Override
@Transactional
public int deleteRecordsOlderThanDaysWithStatus(int days, TaskStatus status) {
DateTime expireDate = new DateTime().minusDays(days);
Timestamp expireTimestamp = new Timestamp(expireDate.getMillis());
Predicate timestampPredicate = Predicate.LT("createTime", expireTimestamp);
Predicate statusPredicate = Predicate.EQ("status", status.toString());
List<TaskBean> list = genericPojoDao.get(Predicate.AND(statusPredicate, timestampPredicate), TaskBean.class);
for (TaskBean bean : list) {
deleteById(bean.getId());
}
return list.size();
}
use of com.google.inject.persist.Transactional in project pinot by linkedin.
the class TaskManagerImpl method findByStatusNotIn.
@Override
@Transactional
public List<TaskDTO> findByStatusNotIn(TaskStatus status) {
Predicate statusPredicate = Predicate.NEQ("status", status.toString());
List<TaskBean> list = genericPojoDao.get(statusPredicate, TaskBean.class);
List<TaskDTO> result = new ArrayList<>();
for (TaskBean bean : list) {
result.add((TaskDTO) MODEL_MAPPER.map(bean, TaskDTO.class));
}
return result;
}
Aggregations