Search in sources :

Example 16 with UserType

use of org.apache.derby.iapi.types.UserType in project derby by apache.

the class CacheLock method saveProperty.

void saveProperty(TransactionController tc, String key, Serializable value) throws StandardException {
    if (saveServiceProperty(key, value))
        return;
    // Do a scan to see if the property already exists in the Conglomerate.
    ScanController scan = this.openScan(tc, key, TransactionController.OPENMODE_FORUPDATE);
    DataValueDescriptor[] row = makeNewTemplate();
    if (scan.fetchNext(row)) {
        if (value == null) {
            // A null input value means that we should delete the row
            scan.delete();
        } else {
            // a value already exists, just replace the second columm
            row[1] = new UserType(value);
            scan.replace(row, (FormatableBitSet) null);
        }
        scan.close();
    } else {
        // The value does not exist in the Conglomerate.
        scan.close();
        scan = null;
        if (value != null) {
            // not a delete request, so insert the new property.
            row = makeNewTemplate(key, value);
            ConglomerateController cc = tc.openConglomerate(propertiesConglomId, false, TransactionController.OPENMODE_FORUPDATE, TransactionController.MODE_TABLE, TransactionController.ISOLATION_SERIALIZABLE);
            cc.insert(row);
            cc.close();
        }
    }
}
Also used : ScanController(org.apache.derby.iapi.store.access.ScanController) ConglomerateController(org.apache.derby.iapi.store.access.ConglomerateController) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) UserType(org.apache.derby.iapi.types.UserType)

Aggregations

UserType (org.apache.derby.iapi.types.UserType)16 DataValueDescriptor (org.apache.derby.iapi.types.DataValueDescriptor)13 ExecRow (org.apache.derby.iapi.sql.execute.ExecRow)9 SQLChar (org.apache.derby.iapi.types.SQLChar)7 SQLBoolean (org.apache.derby.iapi.types.SQLBoolean)5 SQLVarchar (org.apache.derby.iapi.types.SQLVarchar)5 UUID (org.apache.derby.catalog.UUID)4 ScanController (org.apache.derby.iapi.store.access.ScanController)4 Timestamp (java.sql.Timestamp)3 FormatableBitSet (org.apache.derby.iapi.services.io.FormatableBitSet)3 SQLLongint (org.apache.derby.iapi.types.SQLLongint)3 ReferencedColumns (org.apache.derby.catalog.ReferencedColumns)2 ColPermsDescriptor (org.apache.derby.iapi.sql.dictionary.ColPermsDescriptor)2 ExecIndexRow (org.apache.derby.iapi.sql.execute.ExecIndexRow)2 DataTypeDescriptor (org.apache.derby.iapi.types.DataTypeDescriptor)2 Serializable (java.io.Serializable)1 Hashtable (java.util.Hashtable)1 AliasInfo (org.apache.derby.catalog.AliasInfo)1 DependableFinder (org.apache.derby.catalog.DependableFinder)1 IndexDescriptor (org.apache.derby.catalog.IndexDescriptor)1