Search in sources :

Example 1 with CayenneException

use of org.apache.cayenne.CayenneException in project cayenne by apache.

the class UtilTest method testUnwindException3.

@Test
public void testUnwindException3() throws Exception {
    Throwable root = new Throwable();
    CayenneException e = new CayenneException(root);
    assertSame(root, Util.unwindException(e));
}
Also used : CayenneException(org.apache.cayenne.CayenneException) Test(org.junit.Test)

Example 2 with CayenneException

use of org.apache.cayenne.CayenneException in project cayenne by apache.

the class UtilTest method testUnwindException2.

@Test
public void testUnwindException2() throws Exception {
    CayenneException e = new CayenneException();
    assertSame(e, Util.unwindException(e));
}
Also used : CayenneException(org.apache.cayenne.CayenneException) Test(org.junit.Test)

Example 3 with CayenneException

use of org.apache.cayenne.CayenneException in project cayenne by apache.

the class Oracle8LOBBatchAction method performAction.

@Override
public void performAction(Connection connection, OperationObserver observer) throws SQLException, Exception {
    Oracle8LOBBatchTranslator translator;
    if (query instanceof InsertBatchQuery) {
        translator = new Oracle8LOBInsertBatchTranslator((InsertBatchQuery) query, adapter, OracleAdapter.TRIM_FUNCTION);
    } else if (query instanceof UpdateBatchQuery) {
        translator = new Oracle8LOBUpdateBatchTranslator((UpdateBatchQuery) query, adapter, OracleAdapter.TRIM_FUNCTION);
    } else {
        throw new CayenneException("Unsupported batch type for special LOB processing: " + query);
    }
    translator.setNewBlobFunction(OracleAdapter.NEW_BLOB_FUNCTION);
    translator.setNewClobFunction(OracleAdapter.NEW_CLOB_FUNCTION);
    // no batching is done, queries are translated
    // for each batch set, since prepared statements
    // may be different depending on whether LOBs are NULL or not..
    Oracle8LOBBatchQueryWrapper selectQuery = new Oracle8LOBBatchQueryWrapper(query);
    List<DbAttribute> qualifierAttributes = selectQuery.getDbAttributesForLOBSelectQualifier();
    for (BatchQueryRow row : query.getRows()) {
        selectQuery.indexLOBAttributes(row);
        int updated;
        String updateStr = translator.createSql(row);
        // 1. run row update
        logger.log(updateStr);
        try (PreparedStatement statement = connection.prepareStatement(updateStr)) {
            DbAttributeBinding[] bindings = translator.updateBindings(row);
            logger.logQueryParameters("bind", bindings);
            bind(adapter, statement, bindings);
            updated = statement.executeUpdate();
            logger.logUpdateCount(updated);
        }
        // 2. run row LOB update (SELECT...FOR UPDATE and writing out LOBs)
        processLOBRow(connection, translator, selectQuery, qualifierAttributes, row);
        // finally, notify delegate that the row was updated
        observer.nextCount(query, updated);
    }
}
Also used : InsertBatchQuery(org.apache.cayenne.query.InsertBatchQuery) DbAttribute(org.apache.cayenne.map.DbAttribute) PreparedStatement(java.sql.PreparedStatement) DbAttributeBinding(org.apache.cayenne.access.translator.DbAttributeBinding) BatchQueryRow(org.apache.cayenne.query.BatchQueryRow) UpdateBatchQuery(org.apache.cayenne.query.UpdateBatchQuery) CayenneException(org.apache.cayenne.CayenneException)

Aggregations

CayenneException (org.apache.cayenne.CayenneException)3 Test (org.junit.Test)2 PreparedStatement (java.sql.PreparedStatement)1 DbAttributeBinding (org.apache.cayenne.access.translator.DbAttributeBinding)1 DbAttribute (org.apache.cayenne.map.DbAttribute)1 BatchQueryRow (org.apache.cayenne.query.BatchQueryRow)1 InsertBatchQuery (org.apache.cayenne.query.InsertBatchQuery)1 UpdateBatchQuery (org.apache.cayenne.query.UpdateBatchQuery)1