fixed broken persistence implementation after refactor generalization
This commit is contained in:
@ -33,10 +33,10 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
@Transactional(value = REQUIRED)
|
||||
@Interceptor
|
||||
@Priority(value=TransactionJoinInterceptor.PRIORITY)
|
||||
public class TransactionJoinInterceptor {
|
||||
@Priority(value=AccountTransactionJoinInterceptor.PRIORITY)
|
||||
public class AccountTransactionJoinInterceptor {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(TransactionJoinInterceptor.class);
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AccountTransactionJoinInterceptor.class);
|
||||
|
||||
// attach behind the interceptor of the container
|
||||
public static final int PRIORITY = Interceptor.Priority.PLATFORM_BEFORE+250;
|
||||
@ -1,6 +1,5 @@
|
||||
package de.muehlencord.shared.account.business;
|
||||
package de.muehlencord.shared.account.util;
|
||||
|
||||
import de.muehlencord.shared.account.util.ApplicationPU;
|
||||
import javax.annotation.Priority;
|
||||
import javax.inject.Inject;
|
||||
import javax.interceptor.AroundInvoke;
|
||||
@ -9,36 +8,40 @@ import javax.interceptor.InvocationContext;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.transaction.Transactional;
|
||||
import static javax.transaction.Transactional.TxType.REQUIRED;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Joern Muehlencord <joern at muehlencord.de>
|
||||
*/
|
||||
@Transactional(value = REQUIRED)
|
||||
@Interceptor
|
||||
@Priority(value = TransactionJoinInterceptor.PRIORITY)
|
||||
public class TransactionJoinInterceptor {
|
||||
@Priority(value = ApplicationTransactionJoinInterceptor.PRIORITY)
|
||||
public class ApplicationTransactionJoinInterceptor {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(TransactionJoinInterceptor.class);
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ApplicationTransactionJoinInterceptor.class);
|
||||
|
||||
// attach behind the interceptor of the container
|
||||
public static final int PRIORITY = Interceptor.Priority.PLATFORM_BEFORE + 250;
|
||||
|
||||
@Inject
|
||||
@NotNull
|
||||
@ApplicationPU
|
||||
private EntityManager em;
|
||||
|
||||
@AroundInvoke
|
||||
public Object joinTransaction(InvocationContext context) throws Exception {
|
||||
if (em.isJoinedToTransaction()) {
|
||||
LOGGER.trace("transaction already joined");
|
||||
if (em == null) {
|
||||
return context.proceed();
|
||||
} else {
|
||||
LOGGER.trace("joining transaction");
|
||||
em.joinTransaction();
|
||||
if (em.isJoinedToTransaction()) {
|
||||
LOGGER.trace("transaction already joined");
|
||||
} else {
|
||||
LOGGER.trace("joining transaction");
|
||||
em.joinTransaction();
|
||||
}
|
||||
}
|
||||
return context.proceed();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user