-
Notifications
You must be signed in to change notification settings - Fork 1.7k
JPA Extended Persistence Context #88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Added jpa/extended-pc |
Needs further investigation. Entites are committed even when outside a transaction. Is that the expected behavior ? |
Hi Arun, from my investigation: it looks like when we calling persistWithoutTransaction, method is without transaction context and employee entity is not persisted to the database, but stays in Persistence Context. When there is no JTA transaction, the Persistence Context is not propagated, outside of a transaction inserts, updates and deletes will be queued until you access the persistence context within a transaction. Extended Persistence Context is created once only and is used for every transaction within the scope of the class. Next when calling get where Entity Manager is invoked within transaction what means our Extended Persistence Context will be bound to this transaction and employee entity from previous call which is located in Persistence Context should be persisted into database. Solution would be setting annotation @TransactionAttribute(TransactionAttributeType.NEVER) for class scope. In that case invoking get method has no influence for employee entity in Persistence Context because none JTA transaction will be bound with Extended Persistence Context. I’ve created arquilian test for this sample and made some changes in your code. Tests for now works only with wildfly-managed-arquillian profile. What is the policy of writing arquillian tests for JPA samples ? Should tests cover every maven profile ? For example: glassfish-embedded profile needs a little different persistence.xml than wildfly-managed and defined datasource configuration. Best regards, |
@arun-gupta i have made some changes to make this more visual and straightforward https://github.com/nikom1337/javaee7-samples/blob/jpa-extended-pc/jpa/extended-pc/ |
No description provided.
The text was updated successfully, but these errors were encountered: