Search in sources :

Example 6 with GenericJDBCException

use of org.hibernate.exception.GenericJDBCException in project vsDiaryWriter by shilongdai.

the class DerbyEntryDatabase method createTable.

private void createTable() {
    try {
        Transaction tr = getSession().beginTransaction();
        getSession().createSQLQuery("create table JOURNAL(Id INTEGER NOT NULL PRIMARY KEY GENERATED ALWAYS AS IDENTITY (START WITH 0, INCREMENT BY 1), Subject VARCHAR(2000), Date TIMESTAMP, Content CLOB(5242880))").executeUpdate();
        tr.commit();
    } catch (GenericJDBCException e) {
        try {
            throw e.getCause();
        } catch (SQLException e1) {
            if (e1.getSQLState().equals("X0Y32")) {
                return;
            }
            throw new RuntimeException(e1);
        } catch (Throwable e1) {
            throw new RuntimeException(e1);
        }
    }
}
Also used : Transaction(org.hibernate.Transaction) SQLException(java.sql.SQLException) GenericJDBCException(org.hibernate.exception.GenericJDBCException)

Aggregations

GenericJDBCException (org.hibernate.exception.GenericJDBCException)6 HibernateException (org.hibernate.HibernateException)3 Query (org.hibernate.Query)3 MifosRuntimeException (org.mifos.core.MifosRuntimeException)3 ConnectionNotFoundException (org.mifos.framework.exceptions.ConnectionNotFoundException)3 PersistenceException (org.mifos.framework.exceptions.PersistenceException)3 Session (org.hibernate.Session)2 Transaction (org.hibernate.Transaction)2 Timer (com.codahale.metrics.Timer)1 Transactional (com.peterphi.std.guice.database.annotation.Transactional)1 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 OptimisticLockException (javax.persistence.OptimisticLockException)1 PersistenceException (javax.persistence.PersistenceException)1 StaleStateException (org.hibernate.StaleStateException)1 DerbyDialect (org.hibernate.dialect.DerbyDialect)1 LockAcquisitionException (org.hibernate.exception.LockAcquisitionException)1 Work (org.hibernate.jdbc.Work)1