use of org.apache.openjpa.persistence.ArgumentException in project carbon-business-process by wso2.
the class AttachmentMgtDAOConnectionFactoryImpl method getDAOConnection.
// TODO: Throw a proper exception
@Override
public AttachmentMgtDAOConnection getDAOConnection() {
if (connections.get() != null) {
return connections.get();
} else {
try {
// At the moment a property-map is not passed when constructing the entity-Manager
EntityManager entityManager = entityManagerFactory.createEntityManager();
AttachmentMgtDAOConnectionImpl conn = createAttachmentMgtDAOConnection(entityManager);
connections.set(conn);
return conn;
} catch (ArgumentException argEx) {
log.fatal("Entity-Manager creation failed.", argEx);
throw argEx;
}
}
}
use of org.apache.openjpa.persistence.ArgumentException in project oozie by apache.
the class XTestCase method getCountAndRemoveAll.
private <E> int getCountAndRemoveAll(final EntityManager entityManager, final String queryName, final Class<E> entityClass) {
try {
final TypedQuery<E> getAllQuery = entityManager.createNamedQuery(queryName, entityClass);
final List<E> allEntities = getAllQuery.getResultList();
final int entitiesCount = allEntities.size();
for (final E w : allEntities) {
entityManager.remove(w);
}
return entitiesCount;
} catch (final RollbackException e) {
log.warn("Cannot get count or remove all entities. [queryName={0};entityClass.name={1}]", queryName, entityClass.getName());
return 0;
} catch (final PersistenceException | ArgumentException e) {
log.warn("Cannot get count or remove all entities. [queryName={0};entityClass.name={1}]", queryName, entityClass.getName());
return 0;
}
}
Aggregations