Search in sources :

Example 16 with ExtendedType

use of org.apache.cayenne.access.types.ExtendedType in project cayenne by apache.

the class JdbcAdapter method initExtendedTypes.

/**
 * @since 3.1
 */
protected void initExtendedTypes(List<ExtendedType> defaultExtendedTypes, List<ExtendedType> userExtendedTypes, List<ExtendedTypeFactory> extendedTypeFactories, ValueObjectTypeRegistry valueObjectTypeRegistry) {
    for (ExtendedType type : defaultExtendedTypes) {
        extendedTypes.registerType(type);
    }
    // loading adapter specific extended types
    configureExtendedTypes(extendedTypes);
    for (ExtendedType type : userExtendedTypes) {
        extendedTypes.registerType(type);
    }
    for (ExtendedTypeFactory typeFactory : extendedTypeFactories) {
        extendedTypes.addFactory(typeFactory);
    }
    extendedTypes.addFactory(new ValueObjectTypeFactory(extendedTypes, valueObjectTypeRegistry));
}
Also used : ExtendedTypeFactory(org.apache.cayenne.access.types.ExtendedTypeFactory) ValueObjectTypeFactory(org.apache.cayenne.access.types.ValueObjectTypeFactory) ExtendedType(org.apache.cayenne.access.types.ExtendedType)

Example 17 with ExtendedType

use of org.apache.cayenne.access.types.ExtendedType in project cayenne by apache.

the class ProcedureAction method readProcedureOutParameters.

/**
 * Helper method that reads OUT parameters of a CallableStatement.
 */
protected void readProcedureOutParameters(CallableStatement statement, OperationObserver delegate) throws SQLException, Exception {
    long t1 = System.currentTimeMillis();
    // build result row...
    DataRow result = null;
    List<ProcedureParameter> parameters = getProcedure().getCallParameters();
    for (int i = 0; i < parameters.size(); i++) {
        ProcedureParameter parameter = parameters.get(i);
        if (!parameter.isOutParam()) {
            continue;
        }
        if (result == null) {
            result = new DataRow(2);
        }
        ColumnDescriptor descriptor = new ColumnDescriptor(parameter);
        ExtendedType type = dataNode.getAdapter().getExtendedTypes().getRegisteredType(descriptor.getJavaClass());
        Object val = type.materializeObject(statement, i + 1, descriptor.getJdbcType());
        result.put(descriptor.getDataRowKey(), val);
    }
    if (result != null && !result.isEmpty()) {
        // treat out parameters as a separate data row set
        dataNode.getJdbcEventLogger().logSelectCount(1, System.currentTimeMillis() - t1);
        delegate.nextRows(query, Collections.singletonList(result));
    }
}
Also used : ProcedureParameter(org.apache.cayenne.map.ProcedureParameter) ExtendedType(org.apache.cayenne.access.types.ExtendedType) DataRow(org.apache.cayenne.DataRow)

Aggregations

ExtendedType (org.apache.cayenne.access.types.ExtendedType)17 DbAttributeBinding (org.apache.cayenne.access.translator.DbAttributeBinding)8 DbAttribute (org.apache.cayenne.map.DbAttribute)5 ResultSet (java.sql.ResultSet)2 DataRow (org.apache.cayenne.DataRow)2 ColumnDescriptor (org.apache.cayenne.access.jdbc.ColumnDescriptor)2 RowDescriptor (org.apache.cayenne.access.jdbc.RowDescriptor)2 ExtendedTypeFactory (org.apache.cayenne.access.types.ExtendedTypeFactory)2 ProcedureParameter (org.apache.cayenne.map.ProcedureParameter)2 DeleteBatchQuery (org.apache.cayenne.query.DeleteBatchQuery)2 Blob (java.sql.Blob)1 Clob (java.sql.Clob)1 PreparedStatement (java.sql.PreparedStatement)1 CayenneRuntimeException (org.apache.cayenne.CayenneRuntimeException)1 ParameterBinding (org.apache.cayenne.access.translator.ParameterBinding)1 ProcedureParameterBinding (org.apache.cayenne.access.translator.ProcedureParameterBinding)1 ValueObjectTypeFactory (org.apache.cayenne.access.types.ValueObjectTypeFactory)1 ValueObjectTypeRegistry (org.apache.cayenne.access.types.ValueObjectTypeRegistry)1 RuntimeProperties (org.apache.cayenne.configuration.RuntimeProperties)1 DerbyAdapter (org.apache.cayenne.dba.derby.DerbyAdapter)1