JR Utily

fix the big issue regarding transaction at startup

1 package org.legrog.entities; 1 package org.legrog.entities;
2 2
3 import org.springframework.data.jpa.repository.JpaRepository; 3 import org.springframework.data.jpa.repository.JpaRepository;
4 +import org.springframework.data.repository.cdi.Eager;
4 5
6 +@Eager
5 public interface AccountAttributeRepository extends JpaRepository<AccountAttribute, Integer> { 7 public interface AccountAttributeRepository extends JpaRepository<AccountAttribute, Integer> {
6 } 8 }
......
1 package org.legrog.entities; 1 package org.legrog.entities;
2 2
3 import org.springframework.data.jpa.repository.JpaRepository; 3 import org.springframework.data.jpa.repository.JpaRepository;
4 +import org.springframework.data.repository.cdi.Eager;
4 5
6 +@Eager
5 public interface AccountPropertyRepository extends JpaRepository<AccountProperty, Integer> { 7 public interface AccountPropertyRepository extends JpaRepository<AccountProperty, Integer> {
6 } 8 }
......
1 package org.legrog.entities; 1 package org.legrog.entities;
2 2
3 import org.springframework.data.jpa.repository.JpaRepository; 3 import org.springframework.data.jpa.repository.JpaRepository;
4 +import org.springframework.data.repository.cdi.Eager;
4 5
5 import java.util.List; 6 import java.util.List;
6 7
8 +@Eager
7 public interface AccountRepository extends JpaRepository<Account, Integer> { 9 public interface AccountRepository extends JpaRepository<Account, Integer> {
8 /** 10 /**
9 * 11 *
......
1 package org.legrog.entities; 1 package org.legrog.entities;
2 2
3 import org.springframework.data.jpa.repository.JpaRepository; 3 import org.springframework.data.jpa.repository.JpaRepository;
4 +import org.springframework.data.repository.cdi.Eager;
4 5
6 +@Eager
5 public interface AccountRoleRepository extends JpaRepository<AccountRole, Integer> { 7 public interface AccountRoleRepository extends JpaRepository<AccountRole, Integer> {
6 } 8 }
...\ No newline at end of file ...\ No newline at end of file
......
1 package org.legrog.entities; 1 package org.legrog.entities;
2 2
3 import org.springframework.data.jpa.repository.JpaRepository; 3 import org.springframework.data.jpa.repository.JpaRepository;
4 +import org.springframework.data.repository.cdi.Eager;
4 5
6 +@Eager
5 public interface CountryRepository extends JpaRepository<Country, Integer> { 7 public interface CountryRepository extends JpaRepository<Country, Integer> {
6 } 8 }
......
1 package org.legrog.entities; 1 package org.legrog.entities;
2 2
3 import org.springframework.data.jpa.repository.JpaRepository; 3 import org.springframework.data.jpa.repository.JpaRepository;
4 +import org.springframework.data.repository.cdi.Eager;
4 5
5 import java.util.List; 6 import java.util.List;
6 7
7 /** 8 /**
8 * Interface for accessing PublisherAction 9 * Interface for accessing PublisherAction
9 */ 10 */
11 +@Eager
10 public interface PublisherActionRepository extends JpaRepository<PublisherAction, Integer> { 12 public interface PublisherActionRepository extends JpaRepository<PublisherAction, Integer> {
11 13
12 /** 14 /**
......
1 package org.legrog.entities; 1 package org.legrog.entities;
2 2
3 import org.springframework.data.jpa.repository.JpaRepository; 3 import org.springframework.data.jpa.repository.JpaRepository;
4 +import org.springframework.data.repository.cdi.Eager;
4 5
5 import java.util.List; 6 import java.util.List;
6 7
8 +@Eager
7 public interface PublisherRepository extends JpaRepository<Publisher, Integer> { 9 public interface PublisherRepository extends JpaRepository<Publisher, Integer> {
8 List<Publisher> findByValidatedVersionIsNotNull(); 10 List<Publisher> findByValidatedVersionIsNotNull();
9 } 11 }
......
1 package org.legrog.entities; 1 package org.legrog.entities;
2 2
3 import org.springframework.data.jpa.repository.JpaRepository; 3 import org.springframework.data.jpa.repository.JpaRepository;
4 +import org.springframework.data.repository.cdi.Eager;
4 5
5 import java.util.List; 6 import java.util.List;
6 7
8 +@Eager
7 public interface PublisherVersionRepository extends JpaRepository<PublisherVersion, Integer> { 9 public interface PublisherVersionRepository extends JpaRepository<PublisherVersion, Integer> {
8 /** 10 /**
9 * 11 *
......
1 package org.legrog.configuration; 1 package org.legrog.configuration;
2 2
3 -import javax.enterprise.context.RequestScoped; 3 +import javax.enterprise.context.Dependent;
4 -import javax.enterprise.inject.Disposes;
5 import javax.enterprise.inject.Produces; 4 import javax.enterprise.inject.Produces;
6 import javax.persistence.EntityManager; 5 import javax.persistence.EntityManager;
7 import javax.persistence.PersistenceContext; 6 import javax.persistence.PersistenceContext;
...@@ -18,17 +17,9 @@ public class EntityManagerProducer { ...@@ -18,17 +17,9 @@ public class EntityManagerProducer {
18 /** 17 /**
19 * Injectable interface for persistence handling 18 * Injectable interface for persistence handling
20 */ 19 */
21 - @Produces 20 + @Produces @Dependent
22 - @RequestScoped
23 @PersistenceContext(unitName = "Grog-DB") 21 @PersistenceContext(unitName = "Grog-DB")
24 public EntityManager entityManager; 22 public EntityManager entityManager;
25 23
26 24
27 - public void closeEntityManager(@Disposes EntityManager entityManager) {
28 - if (entityManager.isOpen()) {
29 - entityManager.close();
30 - }
31 -
32 - }
33 -
34 } 25 }
......