Skip to content
Advertisement

Tag: transactions

Cleaning up after changing the isolation level in JPA / EclipsLink EntityManager

I’m performing a transaction in JPA (EclipseLink) using a custom transaction isolation level, which I set on the underlying connection of the JPA EntityManager using this code: If I try to reset the isolation level to the old value after having committed the transaction, the underlying connection is null (entityManager.unwrap(Connection.class) returns null). I’m worried, if I just don’t reset the

HibernateException: Couldn’t obtain transaction-synchronized Session for current thread

I’m getting the following exception when trying to use my @Service annotated classes: The way I initialize my application is complicated so I need to provide a link to the full base code to get additional information: https://github.com/dtrunk90/webapp-base. I’m using this as a maven overlay. And here is the necessary code: Initializer (from webapp-base): Initializer (from my webapp): @Configuration (from

javax.transaction.Transactional vs org.springframework.transaction.annotation.Transactional

I don’t understand what is the actual difference between annotations javax.transaction.Transactional and org.springframework.transaction.annotation.Transactional? Is org.springframework.transaction.annotation.Transactional an extension of javax.transaction.Transactional or they have totally different meaning? When should each of them be used? Spring @Transactinal in service layer and javax in DAO? Thanks for answering. Answer Spring has defined its own Transactional annotation to make Spring bean methods transactional, years ago.

Do you need a database transaction for reading data?

When I try to read data from the database, at least using ((Session)em.getDelegate()).createCriteria() an exception is throws saying that a transaction is not present. When I add the annotation: it works fine. However, since reading will happen million of times per second to access and read data, I want to make sure that our environment is not clogged up unnecessarily.

JPA PessimisticLockScope.NORMAL and locking “relationships”

I am studying JPA Documentation and encountered the following lines: Entity relationships for which the locked entity contains the foreign key will also be locked, but not the state of the referenced entities (unless those entities are explicitly locked). Element collections and relationships for which the entity does not contain the foreign key (such as relationships that are mapped to

Advertisement