本文整理了Java中org.hibernate.HibernateException.getCause()
方法的一些代码示例,展示了HibernateException.getCause()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HibernateException.getCause()
方法的具体详情如下:
包路径:org.hibernate.HibernateException
类名称:HibernateException
方法名:getCause
暂无
代码示例来源:origin: spring-projects/spring-framework
if (ex.getCause() instanceof LockAcquisitionException) {
return new CannotAcquireLockException(ex.getMessage(), ex.getCause());
代码示例来源:origin: spring-projects/spring-framework
if (ex.getCause() instanceof LockAcquisitionException) {
return new CannotAcquireLockException(ex.getMessage(), ex.getCause());
代码示例来源:origin: org.springframework/spring-orm
if (ex.getCause() instanceof LockAcquisitionException) {
return new CannotAcquireLockException(ex.getMessage(), ex.getCause());
代码示例来源:origin: org.springframework/spring-orm
if (ex.getCause() instanceof LockAcquisitionException) {
return new CannotAcquireLockException(ex.getMessage(), ex.getCause());
代码示例来源:origin: org.grails/grails-hibernate
protected String getCauseMessage(HibernateException e) {
Throwable cause = e.getCause();
if (cause instanceof InvocationTargetException) {
cause = ((InvocationTargetException)cause).getTargetException();
}
return cause.getMessage();
}
代码示例来源:origin: bhdrkn/Java-Examples
public void delete(T entity) {
if (entity == null) {
throw new IllegalArgumentException("Entity Must not be Null");
}
try {
Session session = this.getCurrentSession();
Transaction transaction = session.beginTransaction();
session.delete(entity);
transaction.commit();
} catch (HibernateException e) {
LOG.error("Error while delete Entity. M: " + e.getMessage()
+ " C: " + e.getCause(), e);
}
}
代码示例来源:origin: bhdrkn/Java-Examples
public Serializable save(T entity) {
Serializable serializable = null;
if (entity == null) {
throw new IllegalArgumentException("Entity must not be null");
}
try {
Session session = this.getCurrentSession();
Transaction transaction = session.beginTransaction();
serializable = session.save(entity);
transaction.commit();
} catch (HibernateException e) {
LOG.error("Error while saving Entity. M: " + e.getMessage()
+ " C: " + e.getCause(), e);
}
return serializable;
}
代码示例来源:origin: org.hibernate/hibernate-tools
protected MetadataDescriptor createMetadataDescriptor() {
try {
Properties overrides = new Properties();
Properties p = loadPropertiesFile();
if(p!=null) {
overrides.putAll( p );
}
return MetadataDescriptorFactory
.createJpaDescriptor(persistenceUnit, overrides);
}
catch(HibernateException t) {
Throwable cause = t.getCause();
if (cause != null) {
throw new BuildException(cause);
} else {
throw new BuildException("Problems in creating a configuration for JPA. Have you remembered to add hibernate EntityManager jars to the classpath ?",t);
}
}
}
代码示例来源:origin: hibernate/hibernate-tools
protected MetadataDescriptor createMetadataDescriptor() {
try {
Properties overrides = new Properties();
Properties p = loadPropertiesFile();
if(p!=null) {
overrides.putAll( p );
}
return MetadataDescriptorFactory
.createJpaDescriptor(persistenceUnit, overrides);
}
catch(HibernateException t) {
Throwable cause = t.getCause();
if (cause != null) {
throw new BuildException(cause);
} else {
throw new BuildException("Problems in creating a configuration for JPA. Have you remembered to add hibernate EntityManager jars to the classpath ?",t);
}
}
}
代码示例来源:origin: bhdrkn/Java-Examples
public void saveOrUpdate(T entity) {
if (entity == null) {
throw new IllegalArgumentException("Entity must not be null");
}
try {
Session session = this.getCurrentSession();
Transaction transaction = session.beginTransaction();
session.saveOrUpdate(entity);
transaction.commit();
} catch (HibernateException e) {
LOG.error("Error while saveOrUpdate Entity. M: " + e.getMessage()
+ " C: " + e.getCause(), e);
}
}
代码示例来源:origin: Transitime/core
} catch (HibernateException e) {
logger.error("Could not get DbTest object. {}. {}",
e.getCause().getMessage(), e.getMessage());
throw e;
} finally {
代码示例来源:origin: Transitime/core
} catch (HibernateException e) {
logger.error("Could not delete DbTest objects. {}. {}",
e.getCause().getMessage(),
e.getMessage());
throw e;
代码示例来源:origin: Transitime/core
e.getCause().getMessage(), e.getMessage());
throw e;
} finally {
代码示例来源:origin: org.grails/grails-hibernate
@Override
public void destroy() throws HibernateException {
if (grailsApplication.isWarDeployed()) {
MetaClassRegistry registry = GroovySystem.getMetaClassRegistry();
Map<?, ?> classMetaData = getSessionFactory().getAllClassMetadata();
for (Object o : classMetaData.values()) {
ClassMetadata classMetadata = (ClassMetadata) o;
Class<?> mappedClass = classMetadata.getMappedClass(EntityMode.POJO);
registry.removeMetaClass(mappedClass);
}
}
try {
super.destroy();
} catch (HibernateException e) {
if (e.getCause() instanceof NameNotFoundException) {
LOG.debug(e.getCause().getMessage(), e);
}
else {
throw e;
}
}
}
代码示例来源:origin: org.bitbucket.askllc.fermenter.stout/stout-hibernate
/**
* Turn the database exception into a meaningful error message
*
* @param pk
* @param dae
* @return
*/
private BO handleDataAccessException(PK pk, HibernateException dae) {
Throwable cause = dae.getCause();
if (cause != null && cause instanceof ObjectDeletedException) {
// Object was deleted - return null
return null;
} else if (cause != null && cause instanceof ObjectNotFoundException) {
// Object not found - return null
return null;
}
AbstractBusinessObjectFactoryInterface factory = (AbstractBusinessObjectFactoryInterface) FactoryManager
.createFactory(FactoryManager.BUSINESS_OBJECT, pk.getClass());
BusinessObject bo = factory.createBusinessObject(pk.getEntityName());
bo.setKey(pk);
return handleDataAccessException((BO) bo, dae);
}
代码示例来源:origin: org.grails/grails-hibernate
Throwable cause = e.getCause();
if (isCacheConfigurationError(cause)) {
LOG.fatal("There was an error configuring the Hibernate second level cache: " + getCauseMessage(e));
代码示例来源:origin: hibernate/hibernate-search
public static void assertCfgIsInvalid(Configuration configuration, Class[] mapping) {
try {
for ( Class annotated : mapping ) {
( configuration ).addAnnotatedClass( annotated );
}
configuration.setProperty( "hibernate.search.default.directory_provider", "local-heap" );
configuration.buildSessionFactory();
fail();
}
catch (HibernateException e) {
//thrown exceptions means the test is ok when caused by a SearchException
Throwable cause = e.getCause();
assertTrue( cause instanceof SearchException );
}
}
代码示例来源:origin: hibernate/hibernate-search
final Throwable throwable = e.getCause();
if ( throwable instanceof BridgeException ) {
代码示例来源:origin: hibernate/hibernate-search
final Throwable throwable = e.getCause();
if ( throwable instanceof BridgeException ) {
代码示例来源:origin: hibernate/hibernate-search
final Throwable throwable = e.getCause();
if ( throwable instanceof BridgeException ) {
内容来源于网络,如有侵权,请联系作者删除!