use of org.apache.openjpa.persistence.OpenJPAEntityManager in project openmeetings by apache.
the class RoomDao method get.
public List<Room> get() {
OpenJPAEntityManager oem = OpenJPAPersistence.cast(em);
boolean qrce = oem.getFetchPlan().getQueryResultCacheEnabled();
try {
// update in cache during update
oem.getFetchPlan().setQueryResultCacheEnabled(false);
TypedQuery<Room> q = oem.createNamedQuery("getBackupRooms", Room.class);
@SuppressWarnings("unchecked") OpenJPAQuery<Room> kq = OpenJPAPersistence.cast(q);
kq.getFetchPlan().addFetchGroups("roomModerators", "roomGroups", "roomFiles");
return kq.getResultList();
} finally {
oem.getFetchPlan().setQueryResultCacheEnabled(qrce);
}
}
use of org.apache.openjpa.persistence.OpenJPAEntityManager in project oozie by apache.
the class Store method getConnection.
public String getConnection() {
OpenJPAEntityManager kem = OpenJPAPersistence.cast(entityManager);
Connection conn = (Connection) kem.getConnection();
return conn.toString();
}
use of org.apache.openjpa.persistence.OpenJPAEntityManager in project oozie by apache.
the class Store method isClosed.
public boolean isClosed() {
OpenJPAEntityManager kem = OpenJPAPersistence.cast(entityManager);
Connection conn = (Connection) kem.getConnection();
try {
return conn.isClosed();
} catch (SQLException e) {
XLog.getLog(getClass()).info(XLog.STD, e.getMessage(), e);
}
return true;
}
use of org.apache.openjpa.persistence.OpenJPAEntityManager in project syncope by apache.
the class OpenJpaDialect method beginTransaction.
@Override
public Object beginTransaction(final EntityManager entityManager, final TransactionDefinition definition) throws PersistenceException, SQLException, TransactionException {
OpenJPAEntityManager openJpaEntityManager = getOpenJPAEntityManager(entityManager);
if (definition.getIsolationLevel() != TransactionDefinition.ISOLATION_DEFAULT) {
// Pass custom isolation level on to OpenJPA's JDBCFetchPlan configuration
FetchPlan fetchPlan = openJpaEntityManager.getFetchPlan();
if (fetchPlan instanceof JDBCFetchPlan) {
IsolationLevel isolation = IsolationLevel.fromConnectionConstant(definition.getIsolationLevel());
((JDBCFetchPlan) fetchPlan).setIsolation(isolation);
}
}
entityManager.getTransaction().begin();
if (!definition.isReadOnly()) {
// Like with EclipseLink, make sure to start the logic transaction early so that other
// participants using the connection (such as JdbcTemplate) run in a transaction.
openJpaEntityManager.beginStore();
}
// Custom implementation for OpenJPA savepoint handling
return new OpenJpaTransactionData(openJpaEntityManager);
}
use of org.apache.openjpa.persistence.OpenJPAEntityManager in project openmeetings by apache.
the class UserDao method getAllBackupUsers.
public List<User> getAllBackupUsers() {
OpenJPAEntityManager oem = OpenJPAPersistence.cast(em);
boolean qrce = oem.getFetchPlan().getQueryResultCacheEnabled();
try {
// update in cache during update
oem.getFetchPlan().setQueryResultCacheEnabled(false);
TypedQuery<User> q = oem.createNamedQuery("getAllUsers", User.class);
@SuppressWarnings("unchecked") OpenJPAQuery<User> kq = OpenJPAPersistence.cast(q);
kq.getFetchPlan().addFetchGroups("backupexport", "groupUsers");
return kq.getResultList();
} finally {
oem.getFetchPlan().setQueryResultCacheEnabled(qrce);
}
}
Aggregations