Skip to content

Commit 1816139

Browse files
committed
Remove usage of deprecated methods.
1 parent 1982301 commit 1816139

File tree

4 files changed

+5
-6
lines changed

4 files changed

+5
-6
lines changed

spring-data-jpa-showcase/src/snippets/java/org/springframework/data/jpa/showcase/snippets/AccountPredicates.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ public static BooleanExpression isExpired() {
2020
}
2121

2222
public static BooleanExpression expiresBefore(LocalDate date) {
23-
return $.expiryDate.before(date.toDateMidnight().toDate());
23+
return $.expiryDate.before(date.toDateTimeAtStartOfDay().toDate());
2424
}
2525
}

spring-data-jpa-showcase/src/snippets/java/org/springframework/data/jpa/showcase/snippets/AccountRepositoryImpl.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
@Repository
1919
class AccountRepositoryImpl implements AccountRepositoryCustom {
2020

21-
@PersistenceContext
22-
private EntityManager em;
21+
@PersistenceContext private EntityManager em;
2322

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

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

3736
for (Account each : em.createQuery(query).getResultList()) {
3837
em.remove(each);

spring-data-jpa-showcase/src/snippets/java/org/springframework/data/jpa/showcase/snippets/AccountRepositoryJdbcImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ public void setTemplate(JdbcTemplate template) {
2222
*/
2323
@Override
2424
public void removedExpiredAccounts(LocalDate reference) {
25-
template.update("DELETE Account AS a WHERE a.expiryDate < ?", reference.toDateMidnight().toDate());
25+
template.update("DELETE Account AS a WHERE a.expiryDate < ?", reference.toDateTimeAtStartOfDay().toDate());
2626
}
2727
}

spring-data-jpa-showcase/src/snippets/java/org/springframework/data/jpa/showcase/snippets/CustomerSpecifications.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public Predicate toPredicate(Root<Customer> root, CriteriaQuery<?> query, Criter
3636
Root<Account> accounts = query.from(Account.class);
3737
Path<Date> expiryDate = accounts.<Date> get("expiryDate");
3838
Predicate customerIsAccountOwner = cb.equal(accounts.<Customer> get("customer"), root);
39-
Predicate accountExpiryDateBefore = cb.lessThan(expiryDate, date.toDateMidnight().toDate());
39+
Predicate accountExpiryDateBefore = cb.lessThan(expiryDate, date.toDateTimeAtStartOfDay().toDate());
4040

4141
return cb.and(customerIsAccountOwner, accountExpiryDateBefore);
4242
}

0 commit comments

Comments
 (0)