Skip to content

Commit

Permalink
Remove usage of deprecated methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
odrotbohm committed Oct 29, 2013
1 parent 1982301 commit 1816139
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ public static BooleanExpression isExpired() {
}

public static BooleanExpression expiresBefore(LocalDate date) {
return $.expiryDate.before(date.toDateMidnight().toDate());
return $.expiryDate.before(date.toDateTimeAtStartOfDay().toDate());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
@Repository
class AccountRepositoryImpl implements AccountRepositoryCustom {

@PersistenceContext
private EntityManager em;
@PersistenceContext private EntityManager em;

/*
* (non-Javadoc)
Expand All @@ -32,7 +31,7 @@ public void removedExpiredAccounts(LocalDate reference) {
CriteriaQuery<Account> query = cb.createQuery(Account.class);
Root<Account> account = query.from(Account.class);

query.where(cb.lessThan(account.get("expiryDate").as(Date.class), reference.toDateMidnight().toDate()));
query.where(cb.lessThan(account.get("expiryDate").as(Date.class), reference.toDateTimeAtStartOfDay().toDate()));

for (Account each : em.createQuery(query).getResultList()) {
em.remove(each);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ public void setTemplate(JdbcTemplate template) {
*/
@Override
public void removedExpiredAccounts(LocalDate reference) {
template.update("DELETE Account AS a WHERE a.expiryDate < ?", reference.toDateMidnight().toDate());
template.update("DELETE Account AS a WHERE a.expiryDate < ?", reference.toDateTimeAtStartOfDay().toDate());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public Predicate toPredicate(Root<Customer> root, CriteriaQuery<?> query, Criter
Root<Account> accounts = query.from(Account.class);
Path<Date> expiryDate = accounts.<Date> get("expiryDate");
Predicate customerIsAccountOwner = cb.equal(accounts.<Customer> get("customer"), root);
Predicate accountExpiryDateBefore = cb.lessThan(expiryDate, date.toDateMidnight().toDate());
Predicate accountExpiryDateBefore = cb.lessThan(expiryDate, date.toDateTimeAtStartOfDay().toDate());

return cb.and(customerIsAccountOwner, accountExpiryDateBefore);
}
Expand Down

0 comments on commit 1816139

Please sign in to comment.