protected String getCauseMessage(HibernateException e) { Throwable cause = e.getCause(); if (cause instanceof InvocationTargetException) { cause = ((InvocationTargetException)cause).getTargetException(); } return cause.getMessage(); }
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); } }
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; }
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); } } }
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); } } }
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); } }
} catch (HibernateException e) { logger.error("Could not get DbTest object. {}. {}", e.getCause().getMessage(), e.getMessage()); throw e; } finally {
} catch (HibernateException e) { logger.error("Could not delete DbTest objects. {}. {}", e.getCause().getMessage(), e.getMessage()); throw e;
e.getCause().getMessage(), e.getMessage()); throw e; } finally {
@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; } } }
/** * 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); }
Throwable cause = e.getCause(); if (isCacheConfigurationError(cause)) { LOG.fatal("There was an error configuring the Hibernate second level cache: " + getCauseMessage(e));
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 ); } }
final Throwable throwable = e.getCause(); if ( throwable instanceof BridgeException ) {
final Throwable throwable = e.getCause(); if ( throwable instanceof BridgeException ) {
final Throwable throwable = e.getCause(); if ( throwable instanceof BridgeException ) {