Search in sources :

Example 21 with JDBCException

use of org.hibernate.JDBCException in project hibernate-orm by hibernate.

the class ContextualLobCreator method createClob.

@Override
public Clob createClob(String string) {
    try {
        final Clob clob = createClob();
        clob.setString(1, string);
        return clob;
    } catch (SQLException e) {
        throw new JDBCException("Unable to set CLOB string after creation", e);
    }
}
Also used : JDBCException(org.hibernate.JDBCException) SQLException(java.sql.SQLException) NClob(java.sql.NClob) Clob(java.sql.Clob)

Example 22 with JDBCException

use of org.hibernate.JDBCException in project hibernate-orm by hibernate.

the class StoredProcedureTest method testInParametersNotSet.

@Test
public void testInParametersNotSet() {
    Session session = openSession();
    session.beginTransaction();
    // since the procedure does not define defaults for parameters this should result in SQLExceptions on
    // execution
    {
        ProcedureCall query = session.createStoredProcedureCall("findUserRange");
        query.registerParameter(1, Integer.class, ParameterMode.IN);
        query.registerParameter(2, Integer.class, ParameterMode.IN).bindValue(2);
        try {
            query.getOutputs();
            fail("Expecting failure due to missing parameter bind");
        } catch (JDBCException expected) {
        }
    }
    // H2 does not support named parameters
    // {
    // ProcedureCall query = session.createStoredProcedureCall( "findUserRange" );
    // query.registerParameter( "start", Integer.class, ParameterMode.IN );
    // query.registerParameter( "end", Integer.class, ParameterMode.IN ).bindValue( 2 );
    // try {
    // query.getOutputs();
    // fail( "Expecting failure due to missing parameter bind" );
    // }
    // catch (JDBCException expected) {
    // }
    // }
    session.getTransaction().commit();
    session.close();
}
Also used : ProcedureCall(org.hibernate.procedure.ProcedureCall) JDBCException(org.hibernate.JDBCException) Session(org.hibernate.Session) Test(org.junit.Test)

Aggregations

JDBCException (org.hibernate.JDBCException)22 SQLException (java.sql.SQLException)13 Test (org.junit.Test)11 Session (org.hibernate.Session)9 PreparedStatement (java.sql.PreparedStatement)7 StaleObjectStateException (org.hibernate.StaleObjectStateException)5 SessionFactoryImplementor (org.hibernate.engine.spi.SessionFactoryImplementor)3 SessionImplementor (org.hibernate.engine.spi.SessionImplementor)3 FeedMetadata (com.thinkbiganalytics.feedmgr.rest.model.FeedMetadata)2 NifiFeed (com.thinkbiganalytics.feedmgr.rest.model.NifiFeed)2 FeedCleanupFailedException (com.thinkbiganalytics.feedmgr.service.FeedCleanupFailedException)2 FeedCleanupTimeoutException (com.thinkbiganalytics.feedmgr.service.FeedCleanupTimeoutException)2 DeployFeedException (com.thinkbiganalytics.feedmgr.service.feed.DeployFeedException)2 DuplicateFeedNameException (com.thinkbiganalytics.feedmgr.service.feed.DuplicateFeedNameException)2 FeedCurrentlyRunningException (com.thinkbiganalytics.feedmgr.service.feed.reindexing.FeedCurrentlyRunningException)2 FeedHistoryDataReindexingNotEnabledException (com.thinkbiganalytics.feedmgr.service.feed.reindexing.FeedHistoryDataReindexingNotEnabledException)2 FeedNotFoundException (com.thinkbiganalytics.metadata.api.feed.FeedNotFoundException)2 VersionNotFoundException (com.thinkbiganalytics.metadata.api.versioning.VersionNotFoundException)2 NifiClientRuntimeException (com.thinkbiganalytics.nifi.rest.client.NifiClientRuntimeException)2 NifiConnectionException (com.thinkbiganalytics.nifi.rest.client.NifiConnectionException)2