javax.persistence.PersistenceException#getMessage ( )源码实例Demo

下面列出了javax.persistence.PersistenceException#getMessage ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

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;
}
 
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);
    }
  }
}
 
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 flush() {
    if (entityManager != null && (!handleTransactions || isTransactionActive())) {
        try {
            entityManager.flush();
        } catch (IllegalStateException ise) {
            throw new FlowableException("Error while flushing EntityManager, illegal state", ise);
        } catch (TransactionRequiredException tre) {
            throw new FlowableException("Cannot flush EntityManager, an active transaction is required", tre);
        } catch (PersistenceException pe) {
            throw new FlowableException("Error while flushing EntityManager: " + pe.getMessage(), pe);
        }
    }
}
 
@Override
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 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);
    }
  }
}
 
源代码8 项目: lams   文件: JpaSystemException.java
@Deprecated
public JpaSystemException(PersistenceException ex) {
	super(ex.getMessage(), ex);
}
 
public JpaSystemException(PersistenceException ex) {
	super(ex.getMessage(), ex);
}
 
 同类方法