From 39ce9fa7a7a435459e177bd9401b07db257f357b Mon Sep 17 00:00:00 2001 From: Moritz Halbritter Date: Wed, 25 Jan 2023 14:14:55 +0100 Subject: [PATCH] Polish --- .../src/main/java/com/example/spring/orm/CLR.java | 3 --- .../src/main/java/com/example/spring/orm/model/Category.java | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/framework/hibernate-enhancer/src/main/java/com/example/spring/orm/CLR.java b/framework/hibernate-enhancer/src/main/java/com/example/spring/orm/CLR.java index 73416e38..3d24e828 100644 --- a/framework/hibernate-enhancer/src/main/java/com/example/spring/orm/CLR.java +++ b/framework/hibernate-enhancer/src/main/java/com/example/spring/orm/CLR.java @@ -24,7 +24,6 @@ public class CLR implements CommandLineRunner { } public void lazyLoad(Long id) { - clearCache(); Category result = entityManager.find(Category.class, id); @@ -32,7 +31,6 @@ public class CLR implements CommandLineRunner { } public Long insertTestData() { - Product product = new Product(); product.setName("lazy-loading-works :)"); entityManager.persist(product); @@ -47,7 +45,6 @@ public class CLR implements CommandLineRunner { } void clearCache() { - Session s = (Session) entityManager.getDelegate(); SessionFactory sf = s.getSessionFactory(); sf.getCache().evictEntityData(); diff --git a/framework/hibernate-enhancer/src/main/java/com/example/spring/orm/model/Category.java b/framework/hibernate-enhancer/src/main/java/com/example/spring/orm/model/Category.java index bfeb23b7..de9edd9f 100644 --- a/framework/hibernate-enhancer/src/main/java/com/example/spring/orm/model/Category.java +++ b/framework/hibernate-enhancer/src/main/java/com/example/spring/orm/model/Category.java @@ -13,7 +13,7 @@ public class Category { @GeneratedValue private Long id; - @ManyToOne(fetch = FetchType.LAZY) // + @ManyToOne(fetch = FetchType.LAZY) private Product product; public Category(Product product) {