Code example for HibernateException

Methods: getMessage

0
    			 
    			if (s != null && s.isOpen())
    				s.close();
            } 
        }catch(HibernateException e) {
            logger.error("Exception " + e.getMessage(), e);
            throw new PersistException(e);
        } 
	} 
	 
	public static void beginTransaction(boolean cloudStackTxn) {
	    Transaction tx = null;
		try { 
     	    if(cloudStackTxn){
    	        tx = threadCloudStackTransaction.get();
    	    }else{ 
    	        tx = threadTransaction.get();
    	    } 
 
			if (tx == null) {
				tx = getSession(cloudStackTxn).beginTransaction();
				if(cloudStackTxn){
				    threadCloudStackTransaction.set(tx);
				}else{ 
				    threadTransaction.set(tx);
				} 
			} 
		} catch(HibernateException e) {
			logger.error("Exception " + e.getMessage(), e);
			throw new PersistException(e);
		}		 
	} 
 
	public static void beginTransaction() { 
	    beginTransaction(false); 
	} 
	 
	public static void commitTransaction(boolean cloudStackTxn) {
		Transaction tx = null;
		 
        if(cloudStackTxn){
            tx = threadCloudStackTransaction.get();
        }else{ 
            tx = threadTransaction.get();
        } 
		 
        try { 
			if ( tx != null && !tx.wasCommitted() && !tx.wasRolledBack() ){
				tx.commit();
			} 
            if(cloudStackTxn){
                threadCloudStackTransaction.set(null);
            }else{ 
                threadTransaction.set(null);
            } 
		} catch (HibernateException e) {
			logger.error("Exception " + e.getMessage(), e);
			 
			rollbackTransaction(cloudStackTxn);
			throw new PersistException(e);
		}		 
	} 
	 
	public static void commitTransaction() { 
	    commitTransaction(false); 
	} 
	 
	public static void rollbackTransaction(boolean cloudStackTxn) {
		Transaction tx = null;
		 
        if(cloudStackTxn){
            tx = (Transaction)threadCloudStackTransaction.get();
            threadCloudStackTransaction.set(null);
        }else{ 
            tx = (Transaction)threadTransaction.get();
            threadTransaction.set(null);
        } 
		try { 
			if ( tx != null && !tx.wasCommitted() && !tx.wasRolledBack() ) {
				tx.rollback();
			} 
		} catch (HibernateException e) {
			logger.error("Exception " + e.getMessage(), e);
			throw new PersistException(e);
		} finally { 
			closeSession(cloudStackTxn);
		} 
	}