This commit is contained in:
Moritz Halbritter
2023-01-25 14:14:55 +01:00
parent 96532bf6f3
commit 39ce9fa7a7
2 changed files with 1 additions and 4 deletions

View File

@@ -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();

View File

@@ -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) {