private EntityManagerFactory buildNativeEntityManagerFactory() { EntityManagerFactory emf; try { emf = createNativeEntityManagerFactory(); } catch (PersistenceException ex) { if (ex.getClass() == PersistenceException.class) { // Plain PersistenceException wrapper for underlying exception? // Make sure the nested exception message is properly exposed, // along the lines of Spring's NestedRuntimeException.getMessage() Throwable cause = ex.getCause(); if (cause != null) { String message = ex.getMessage(); String causeString = cause.toString(); if (!message.endsWith(causeString)) { throw new PersistenceException(message + "; nested exception is " + causeString, cause); } } } throw ex; } JpaVendorAdapter jpaVendorAdapter = getJpaVendorAdapter(); if (jpaVendorAdapter != null) { jpaVendorAdapter.postProcessEntityManagerFactory(emf); } if (logger.isInfoEnabled()) { logger.info("Initialized JPA EntityManagerFactory for persistence unit '" + getPersistenceUnitName() + "'"); } return emf; }
public void flush() { if (entityManager != null && (!handleTransactions || isTransactionActive())) { try { entityManager.flush(); } catch (IllegalStateException ise) { throw new ActivitiException("Error while flushing EntityManager, illegal state", ise); } catch (TransactionRequiredException tre) { throw new ActivitiException("Cannot flush EntityManager, an active transaction is required", tre); } catch (PersistenceException pe) { throw new ActivitiException("Error while flushing EntityManager: " + pe.getMessage(), pe); } } }
private EntityManagerFactory buildNativeEntityManagerFactory() { EntityManagerFactory emf; try { emf = createNativeEntityManagerFactory(); } catch (PersistenceException ex) { if (ex.getClass() == PersistenceException.class) { // Plain PersistenceException wrapper for underlying exception? // Make sure the nested exception message is properly exposed, // along the lines of Spring's NestedRuntimeException.getMessage() Throwable cause = ex.getCause(); if (cause != null) { String message = ex.getMessage(); String causeString = cause.toString(); if (!message.endsWith(causeString)) { throw new PersistenceException(message + "; nested exception is " + causeString, cause); } } } throw ex; } JpaVendorAdapter jpaVendorAdapter = getJpaVendorAdapter(); if (jpaVendorAdapter != null) { jpaVendorAdapter.postProcessEntityManagerFactory(emf); } if (logger.isInfoEnabled()) { logger.info("Initialized JPA EntityManagerFactory for persistence unit '" + getPersistenceUnitName() + "'"); } return emf; }
assertTrue(ex.getMessage().contains("changed an immutable collection instance")); log.debug("success"); fail(); } catch (PersistenceException e) { assertTrue(e.getMessage().contains("changed an immutable collection instance")); log.debug("success");
assertTrue( e.getMessage().contains( "Transaction was rolled back in a different thread!" ) );
public void flush() { if (entityManager != null && (!handleTransactions || isTransactionActive()) ) { try { entityManager.flush(); } catch (IllegalStateException ise) { throw new ProcessEngineException("Error while flushing EntityManager, illegal state", ise); } catch (TransactionRequiredException tre) { throw new ProcessEngineException("Cannot flush EntityManager, an active transaction is required", tre); } catch (PersistenceException pe) { throw new ProcessEngineException("Error while flushing EntityManager: " + pe.getMessage(), pe); } } }
public void flush() { if (entityManager != null && (!handleTransactions || isTransactionActive()) ) { try { entityManager.flush(); } catch (IllegalStateException ise) { throw new ProcessEngineException("Error while flushing EntityManager, illegal state", ise); } catch (TransactionRequiredException tre) { throw new ProcessEngineException("Cannot flush EntityManager, an active transaction is required", tre); } catch (PersistenceException pe) { throw new ProcessEngineException("Error while flushing EntityManager: " + pe.getMessage(), pe); } } }
try { mySessionBean.createSOUser(userName, rep); } catch (PersistenceException e) { showSomeGlobalErrorMessage(e.getMessage()); }
@Test public void testException() { try { someDao.save(employee2); fail("expected an exception"); } catch (PersistenceException ex) { assertEquals(Error, ex.getMessage()); } }
private static net.sf.hibernate.NonUniqueResultException adaptNonUniqueResultException( final PersistenceException ex) { final String message = ex.getMessage(); return new net.sf.hibernate.NonUniqueResultException(-1) { @Override public String getMessage() { return message; } @Override public String toString() { return toStringWithClassName(this, net.sf.hibernate.NonUniqueResultException.class); } }; }
@Override public Response toResponse(PersistenceException e) { return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).type(MediaType.TEXT_PLAIN).build(); } }
@Override public Group getById(String id) { try { return groupConverter.toScim(groupDao.getById(id)); } catch (NoResultException nre) { LOGGER.log(Level.INFO, nre.getMessage(), nre); throw new ResourceNotFoundException(String.format("Group with id '%s' not found", id), nre); } catch (PersistenceException pe) { LOGGER.log(Level.WARNING, pe.getMessage(), pe); throw new ResourceNotFoundException(String.format("Group with id '%s' not found", id), pe); } }
public void flush() { if (entityManager != null && (!handleTransactions || isTransactionActive()) ) { try { entityManager.flush(); } catch (IllegalStateException ise) { throw new ProcessEngineException("Error while flushing EntityManager, illegal state", ise); } catch (TransactionRequiredException tre) { throw new ProcessEngineException("Cannot flush EntityManager, an active transaction is required", tre); } catch (PersistenceException pe) { throw new ProcessEngineException("Error while flushing EntityManager: " + pe.getMessage(), pe); } } }
@Override public Response toResponse(PersistenceException exception) { if (exception.getCause() instanceof ConstraintViolationException) { return ResponseFactory .response(Response.Status.CONFLICT, new ErrorResponse(Response.Status.CONFLICT.getStatusCode(), Messages.CONFLICT_MESSAGE)); } logger.error("Error: ", exception); return ResponseFactory .response(Response.Status.INTERNAL_SERVER_ERROR, new ErrorResponse(exception.getMessage())); } }
@Override public User getById(String id) { try { UserEntity userEntity = userDao.getById(id); User user = userConverter.toScim(userEntity); return getUserWithoutPassword(user); } catch (NoResultException nre) { LOGGER.log(Level.INFO, nre.getMessage(), nre); throw new ResourceNotFoundException(String.format("User with id '%s' not found", id), nre); } catch (PersistenceException pe) { LOGGER.log(Level.WARNING, pe.getMessage(), pe); throw new ResourceNotFoundException(String.format("User with id '%s' not found", id), pe); } }
public void flush() { if (entityManager != null && (!handleTransactions || isTransactionActive()) ) { try { entityManager.flush(); } catch (IllegalStateException ise) { throw new ActivitiException("Error while flushing EntityManager, illegal state", ise); } catch (TransactionRequiredException tre) { throw new ActivitiException("Cannot flush EntityManager, an active transaction is required", tre); } catch (PersistenceException pe) { throw new ActivitiException("Error while flushing EntityManager: " + pe.getMessage(), pe); } } }
public void flush() { if (entityManager != null && (!handleTransactions || isTransactionActive())) { try { entityManager.flush(); } catch (IllegalStateException ise) { throw new ActivitiException("Error while flushing EntityManager, illegal state", ise); } catch (TransactionRequiredException tre) { throw new ActivitiException("Cannot flush EntityManager, an active transaction is required", tre); } catch (PersistenceException pe) { throw new ActivitiException("Error while flushing EntityManager: " + pe.getMessage(), pe); } } }
@Override public void init() { try { super.init(); fail("Failure expected"); } catch (PersistenceException expected) { assertEquals("[PersistenceUnit: EagerFetchingOneToManyBagsFindEntityTest] Unable to build Hibernate SessionFactory", expected.getMessage()); } }
Assert.assertEquals("bad jpa query: p", e.getMessage());
Assert.assertEquals("bad jpa query: p", e.getMessage());