Java Code Examples for org.hibernate.HibernateException.getMessage()

The following are Jave code examples for showing how to use getMessage() of the org.hibernate.HibernateException class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: OSWf-OSWorkflow-fork   File: HibernatePersistentVarsDAO.java   View Source Code Vote up 6 votes
public Collection<String> getKeys(Long piid, String prefix, Type type) {

        if( piid == null)
            throw new PersistentVarsException("Could not find keys for 'null' piid");

        Session session = null;
        Transaction transaction = null;
        Collection<String> list = null;
        
        try {
            session = sessionFactory.openSession();
            transaction = session.beginTransaction();

            list = getKeysImpl(session, piid, prefix, type);

            transaction.commit();

        } catch (HibernateException hibernateException) {
            throw new PersistentVarsException("HibernatePropertySet.getKeys: " + hibernateException.getMessage());
        } finally {
            if (transaction != null && transaction.isActive())
                 transaction.rollback();

            if (session != null)
                session.close();
        } 

        return list;
    }
 
Example 2
Project: OSWf-OSWorkflow-fork   File: HibernatePersistentVarsDAO.java   View Source Code Vote up 5 votes
public void save(HibernatePersistentVarsItem item) {

        if( item == null)
            throw new PersistentVarsException("Could not save 'null' PropertyItem");
 
       Session session = null;
       Transaction transaction = null;

        try {
            session = this.sessionFactory.openSession();
            transaction = session.beginTransaction();
            
            session.saveOrUpdate(item);
            session.flush();
            
            transaction.commit();
            
        } catch (HibernateException hibernateException) {
            throw new PersistentVarsException("Could not save key '" + item.getKey() + "':" + hibernateException.getMessage());
        } finally {
            
            if (transaction != null && transaction.isActive())
                 transaction.rollback();

            if (session != null)
                session.close();
        }
    }
 
Example 3
Project: OSWf-OSWorkflow-fork   File: HibernatePersistentVarsDAO.java   View Source Code Vote up 5 votes
public HibernatePersistentVarsItem findByKey(Long piid, String key) {

        if( piid == null)
            throw new PersistentVarsException("Could not find property for 'null' piid");

        if( key == null)
            throw new PersistentVarsException("Could not find property for 'null' key");
        
        Session session = null;
        Transaction transaction = null;
        HibernatePersistentVarsItem item = null;

        try {

            session = sessionFactory.openSession();
            transaction = session.beginTransaction();

            item = getItem(session, piid, key);
            session.flush();

            transaction.commit();

        } catch (HibernateException hibernateException) {
            throw new PersistentVarsException("Could not find key '" + key + "': " + hibernateException.getMessage());
        } finally {
            if (transaction != null && transaction.isActive())
                 transaction.rollback();

            if (session != null)
                session.close();
        }

        return item;
    }
 
Example 4
Project: OSWf-OSWorkflow-fork   File: HibernatePersistentVarsDAO.java   View Source Code Vote up 5 votes
public void remove(Long piid, String key) {


        if( piid == null)
            throw new PersistentVarsException("Could not remove property for 'null' piid");

        if( key == null)
            throw new PersistentVarsException("Could not remove property with 'null' key");

       Session session = null;
       Transaction transaction = null;

        try {
            session = this.sessionFactory.openSession();
            transaction = session.beginTransaction();

            session.delete(getItem(session, piid, key));
            session.flush();

            transaction.commit();
        } catch (HibernateException hibernateException) {
            throw new PersistentVarsException("Could not remove key '" + key + "': " + hibernateException.getMessage());
        } finally {
            
            if (transaction != null && transaction.isActive())
                 transaction.rollback();
            
            if (session != null) 
                session.close();
        }
    }
 
Example 5
Project: OSWf-OSWorkflow-fork   File: HibernatePersistentVarsDAO.java   View Source Code Vote up 5 votes
public void remove(Long piid) {

        if( piid == null)
            throw new PersistentVarsException("Could not remove properties for 'null' piid");

        Session session = null;
        Transaction transaction = null;

        try  {
            session = this.sessionFactory.openSession();
            transaction = session.beginTransaction();

            Collection<String> keys = getKeys(piid, null, null);

            for(String key : keys)
                session.delete(getItem(session, piid, key));

            transaction.commit();
            
        } catch( HibernateException hibernateException ) {
            throw new PersistentVarsException("Could not remove all keys: " + hibernateException.getMessage());
        } finally {
            // Rollback if 'commit' failed 
            if(transaction != null && transaction.isActive())
                transaction.rollback();

            if (session != null) 
                session.close();
        }
    }
 
Example 6
Project: OSWf-OSWorkflow-fork   File: HibernatePersistentVarsDAO.java   View Source Code Vote up 3 votes
public HibernatePersistentVarsItem create(Long piid, String key) {

       if( piid == null)
           throw new PersistentVarsException("Could not create property with 'null' piid");

       if( key == null)
           throw new PersistentVarsException("Could not create property with 'null' key");
           
      Session session = null;
      Transaction transaction = null;
   
       HibernatePersistentVarsItem item = new HibernatePersistentVarsItem(piid, key);

       try {
           session = this.sessionFactory.openSession();
           transaction = session.beginTransaction();

           session.save(item);

           transaction.commit();

       } catch (HibernateException hibernateException) {
           throw new PersistentVarsException("Could not save key '" + key + "': " + hibernateException.getMessage());
       } finally {
           
           if (transaction != null && transaction.isActive())
                transaction.rollback();
           
           if (session != null) 
               session.close();
       }
       
       return item;
   }
 
Example 7
Project: lams   File: HibernateSystemException.java   View Source Code Vote up 2 votes
/**
 * Create a new HibernateSystemException,
 * wrapping an arbitrary HibernateException.
 * @param cause the HibernateException thrown
 */
public HibernateSystemException(HibernateException cause) {
	super(cause != null ? cause.getMessage() : null, cause);
}
 
Example 8
Project: lams   File: HibernateSystemException.java   View Source Code Vote up 2 votes
/**
 * Create a new HibernateSystemException,
 * wrapping an arbitrary HibernateException.
 * @param cause the HibernateException thrown
 */
public HibernateSystemException(HibernateException cause) {
	super(cause != null ? cause.getMessage() : null, cause);
}