com.blazebit.storage.testsuite.common.DataService Maven / Gradle / Ivy
package com.blazebit.storage.testsuite.common;
import javax.ejb.Stateless;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import com.blazebit.storage.core.config.api.persistence.MasterOnly;
@Stateless
public class DataService {
@Inject
@MasterOnly
private EntityManager em;
public E persist(final E entity) {
em.persist(entity);
em.flush();
return entity;
}
public void detach(final Object entity) {
em.detach(entity);
}
public E merge(E entity) {
return em.merge(entity);
}
public T transactional(TxWork consumer) {
return consumer.doWork(em);
}
public void transactional(TxVoidWork consumer) {
consumer.doWork(em);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy