I read about about Persistence Context but not able to get a clear picture about my doubts which are as follows.
1. I have a DAO class which as a @PersistenceContext(unitName="") private EntityManager entityManager and from my Service method i am starting the transaction(Spring Managed) using @Transactional(propagation = Propagation.REQUIRED). I understand here is every time this Service method is called, a Transaction will start and when it reaches to DAO class it will use the same Transaction but for every EntityManager operation it look for Active PersistenceContext and create it as required. Is this approach correct and thread safe?
So, if a new thread starts the same service method then a new Transaction and a persistence Context will be created and flushed away when the method ends?
2. I have multiple WARS which need to interact with database so I am sharing the EntityManagerFactory using Spring Shared contexts. I am having all the Hibernate related configurations at a common place and in every WAR i am specifying where transactionManager will be shared. Is it right?
Please clarify my doubts and your comments are valued. Thanks in advance.
Spring JPA and Sharing Entity Manager across multiple WARS and @Persistence Context thread safety
1.3k Views Asked by Art At
0
There are 0 best solutions below
Related Questions in SPRING
- Redirect inside java interceptor
- Spring RestTemplate passing the type of the response
- spring-integration-dsl-groovy-http return null when i use httpGet method
- Custom Spring annotation for request parameters
- Spring - configure Jboss Intros for xml with java config?
- HTTP Status 404 - Not Found in Spring 3.2.7
- AndroidAnnotations how to use setBearerAuth
- android I/O error: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found
- Show login dialog when not authenticated yet
- Spring Data Rest supporting json and xml
- @Value annotation not resolved in a class that belongs to dependency jar
- Remove nested _embedded fields while using projections
- How to send Rest GET request that contains "#" value in url parameters?
- How to inject spring bean into Validator(hibernate)
- How to keep a variable in the URL when using Spring LocaleChangeInterceptor
Related Questions in JPA
- JPA - How to query with a LIKE operator in combination with an AttributeConverter
- How to create nested selects with sql?
- Play Framework Unable to build entity manager factory when Working with PostGIS
- Getting entity with a join table GAE
- Is it necessary to create an repository and a service for each entity?
- JPA, Hibernate can I do composite primary key which one element is foreign kay @OneToMany?
- Hibernate Search Faceting not working
- EntityManagerSetupException for multiple joins and a sub query for NamedQuery
- JPA and web app
- JPA findDistinctPropertyBy magic method doesn't work as expected when using spring-boot-starter-jpa
- Inject EntityManager in SwitchYard Junit implementation
- QueryDSL where relationship may be null
- JPA, how can i have two queries, one use lazy and one use eager for fetching?
- Duplicate entry '[X]' for key '[Y]' on JPA repository 'save' operation. Saved entity has its key defined already
- Hibernate's bidirectional OneToOne relationship not working within the same class
Related Questions in JPA-2.0
- JPA 2.0 CriteriaQuery with predicate on type being a class or any subclass of
- JPA Portability Between MYSQL and MongoDB
- JPA2 get column metadata (type, lenth, nullable, etc)
- Set Customized Validation Exception Message in JPA 2.0
- Unidirectional @OneToOne with reversed foreign key
- OpenJPA OneToMany and composite key in parent and child table
- JPA number generators without primary key and general use
- Container cannot inject EntityManager using @PersistentContext
- Returning result from 3 tables using JPA criteria
- JPA OneToMany with Jointable, deleting a link deletes right-side object
- Handling field of Integer with specific count of digits in entity
- JPA Criteria API .in-Clause with empty list
- Left Join in Spring Data JPA's Specification
- JPA Criteria Join OneToMany table where clause does not work
- Native query IN clause throwing sql error
Related Questions in ENTITYMANAGER
- Spring context unable to resolve among multiple entity managers
- Error while accessing EntityManager in spring boot
- Refresh collection / empty cache - using entity manager
- What's the difference beetwen EntityManager and DAO?
- BreezeJs features already implemented by AngularJs?
- Why is my EntityManager not properly injected?
- Hibernate Entity Manager
- spring 4 struts 1.x mixing xml and java config
- JPA DAO Update row without full row context
- Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named TEST
- SQL Error: 1795, SQLState: 42000 - maximum number of expressions in a list is 1000
- Return partial Entity from EntityManager
- Table cannot be resolved jpa
- Shouldn't EntityManager#merge work with non identifiable entity?
- Difference between cascade remove and explicit remove
Related Questions in PERSISTENCE-UNIT
- persistence unit gets overwritten
- Glassfish Deployment out of Eclipse Helios SR2 fails
- WLS 10.3.4 - No persistence unit named 'xxx' is available in scope xxx_EJB.jar. Available persistence units: []
- Adding separate persistenceUnit still looks at broadleaf own entities and fails
- Spring JPA and Sharing Entity Manager across multiple WARS and @Persistence Context thread safety
- two persistence units for two schemas?
- Will @PersistenceUnit close my EntityManagerFactory when application is destroyed?
- Can I use one hibernate persistence unit on tomcat and share it between deployed wars?
- spring jpa hibernate with more datasources
- JBoss Wildfly 9 - Multiple Datasources and PersistenceUnits
- "Invalid authorization specification" error on UCanAccess connect
- Wildfly 8.2.0.Final: Misconfiguration because of example datasource or persistence.xml?
- java.lang.IllegalStateException: Unable to retrieve EntityManagerFactory for unitName CarLocPU
- Is it possible to share configuration from persistence.xml?
- Define Entity Class at Runtime Instead Of Only In Persistence.xml
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?