use of com.google.inject.persist.Transactional in project pinot by linkedin.
the class DetectionStatusManagerImpl method deleteRecordsOlderThanDays.
@Override
@Transactional
public int deleteRecordsOlderThanDays(int days) {
DateTime expireDate = new DateTime().minusDays(days);
Timestamp expireTimestamp = new Timestamp(expireDate.getMillis());
Predicate timestampPredicate = Predicate.LT("createTime", expireTimestamp);
List<DetectionStatusBean> list = genericPojoDao.get(timestampPredicate, DetectionStatusBean.class);
for (DetectionStatusBean bean : list) {
deleteById(bean.getId());
}
return list.size();
}
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;
}
use of com.google.inject.persist.Transactional in project ninja by ninjaframework.
the class ArticleDao method postArticle.
/**
* Returns false if user cannot be found in database.
*/
@Transactional
public boolean postArticle(String username, ArticleDto articleDto) {
EntityManager entityManager = entitiyManagerProvider.get();
Query query = entityManager.createQuery("SELECT x FROM User x WHERE username = :usernameParam");
User user = (User) query.setParameter("usernameParam", username).getSingleResult();
if (user == null) {
return false;
}
Article article = new Article(user, articleDto.title, articleDto.content);
entityManager.persist(article);
return true;
}
use of com.google.inject.persist.Transactional in project querydsl by querydsl.
the class AbstractPersistenceTest method before.
@Before
@Transactional
public void before() {
EntityManager entityManager = em.get();
entityManager.getEntityManagerFactory().getCache().evictAll();
Session session = entityManager.unwrap(Session.class);
session.doWork(new Work() {
@Override
public void execute(Connection connection) throws SQLException {
List<String> tables = new ArrayList<String>();
DatabaseMetaData md = connection.getMetaData();
ResultSet rs = md.getTables(null, null, null, new String[] { "TABLE" });
try {
while (rs.next()) {
tables.add(rs.getString("TABLE_NAME"));
}
} finally {
rs.close();
}
java.sql.Statement stmt = connection.createStatement();
try {
stmt.execute("SET REFERENTIAL_INTEGRITY FALSE");
for (String table : tables) {
stmt.execute("TRUNCATE TABLE " + table);
}
stmt.execute("SET REFERENTIAL_INTEGRITY TRUE");
} finally {
stmt.close();
}
}
});
}
Aggregations