Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void removeTowns() {
- this.entityManager.getTransaction().begin();
- List<Town> towns = this.entityManager.createQuery("FROM Town", Town.class).getResultList();
- towns.forEach(e -> {
- if (e.getName().length() > 5) {
- this.entityManager.remove(e);
- } else {
- e.setName(e.getName().toLowerCase());
- }
- });
- this.entityManager.flush();
- this.entityManager.getTransaction().commit();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement