/** * PUBLIC: * Returns the Object associated with the given key * (null if the key does not map to an Object.) * @param key DatabaseField * @return Object - the value associated with the key */ public Object getValues(DatabaseField key) { return super.get(key); }
/** * INTERNAL: * Used by cursored stream. * Return the first field in the row. */ public Object buildObject(AbstractRecord row) { Object value = row.get(row.getFields().firstElement()); if (getValueConverter() != null) { value = getValueConverter().convertDataValueToObjectValue(value, session); } return value; }
/** * PUBLIC: * Retrieves the value with the given name of the DatabaseField. * A field is constructed on the name to check the hash table. * If missing, null is returned. * @param fieldName String, the DatabaseField name * @return Object - the value */ public Object get(String fieldName) { return super.get(fieldName); }
/** * PUBLIC: * Returns the Object associated with the given key * (null if the key does not map to an Object.) * @param key String * @return Object - the value associated with the key */ public Object getValues(String key) { return super.get(key); }
/** * PUBLIC: * Retrieves the value for the given key. * A field is constructed with the key to check the hash table. * If missing, null is returned. * @param key Object, either String or DatabaseField * @return Object */ public Object get(Object key) { return super.get(key); }
public Object getValues(String key) { return get(key); }
public Object getValues(DatabaseField key) { return get(key); }
/** * PUBLIC: * Retrieve the value for the field name. * A field is constructed on the name to check the hash table. * If missing null is returned. */ public Object get(Object key) { if (key instanceof String) { return get((String)key); } else if (key instanceof DatabaseField) { return get((DatabaseField)key); } return null; }
/** * INTERNAL: * Return whether all the aggregate fields in the specified * row are NULL. */ protected boolean allAggregateFieldsAreNull(AbstractRecord databaseRow) { for (Enumeration fieldsEnum = getReferenceFields().elements(); fieldsEnum.hasMoreElements();) { DatabaseField field = (DatabaseField)fieldsEnum.nextElement(); Object value = databaseRow.get(field); if (value != null) { return false; } } return true; }
/** * INTERNAL: * In the case of building a UnitOfWork clone directly from a row, the * session set in the query will not know which database platform to use * for converting the value. Allows the correct session to be passed in. * @param row * @param query * @param executionSession * @return */ public Object valueFromRow(AbstractRecord row, JoinedAttributeManager joinManager, ObjectBuildingQuery query, AbstractSession executionSession) { // PERF: Direct variable access. Object fieldValue = row.get(this.field); Object attributeValue = getAttributeValue(fieldValue, executionSession); return attributeValue; }
/** * INTERNAL: * This method is used to get all the database tables and add them into a vector. */ public void initializeTables(AbstractSession session) { Vector result = session.getAccessor().getTableInfo(null, null, null, null, session); for (Enumeration resultEnum = result.elements(); resultEnum.hasMoreElements();) { AbstractRecord row = (AbstractRecord)resultEnum.nextElement(); tables.addElement(row.get("TABLE_NAME")); } }
/** * INTERNAL: * Return the value of the field from the row or a value holder on the query to obtain the object. * Check for batch + aggregation reading. */ protected Object valueFromRowInternal(AbstractRecord row, JoinedAttributeManager joinManager, AbstractSession executionSession) throws DatabaseException { // If any field in the foreign key is null then it means there are no referenced objects // Skip for partial objects as fk may not be present. int size = this.fields.size(); for (int index = 0; index < size; index++) { DatabaseField field = (DatabaseField)this.fields.get(index); if (row.get(field) == null) { return this.indirectionPolicy.nullValueFromRow(); } } // Call the default which executes the selection query, // or wraps the query with a value holder. return super.valueFromRowInternal(row, joinManager, executionSession); }
/** * INTERNAL: * Return the value that should be stored in the identity map. * If the value is stored in the object, then return a null. */ public Object getValueToPutInCache(AbstractRecord row, AbstractSession session) { if (isStoredInCache()) { return row.get(getWriteLockField()); } else { return null; } }
/** * INTERNAL: * A subclass should implement this method if it wants different behaviour. * Write the foreign key values from the attribute to the row. */ public void writeFromAttributeIntoRow(Object attribute, AbstractRecord row, AbstractSession session) { AbstractRecord targetRow = buildRowFromAggregate(null, attribute, session); for (Enumeration stream = targetRow.keys(); stream.hasMoreElements(); ) { DatabaseField field = (DatabaseField) stream.nextElement(); Object value = targetRow.get(field); row.put(field, value); } }
/** * INTERNAL: * Write fields needed for insert into the template for with null values. */ public void writeInsertFieldsIntoRow(AbstractRecord databaseRow, AbstractSession session) { if (isReadOnly()) { return; } AbstractRecord targetRow = buildTemplateInsertRow(session); for (Enumeration keyEnum = targetRow.keys(); keyEnum.hasMoreElements();) { DatabaseField field = (DatabaseField)keyEnum.nextElement(); Object value = targetRow.get(field); //CR-3286097 - Should use add not put, to avoid linear search. databaseRow.add(field, value); } }
/** * INTERNAL: * Get the attribute value from the object and add the appropriate * values to the specified database row. */ public void writeFromObjectIntoRowWithChangeRecord(ChangeRecord changeRecord, AbstractRecord databaseRow, AbstractSession session) throws DescriptorException { if (isReadOnly()) { return; } AbstractRecord targetRow = buildRowFromAggregateWithChangeRecord(changeRecord, (ObjectChangeSet)((AggregateChangeRecord)changeRecord).getChangedObject(), session); for (Enumeration stream = targetRow.keys(); stream.hasMoreElements();) { DatabaseField field = (DatabaseField)stream.nextElement(); Object value = targetRow.get(field); databaseRow.add(field, value); } }
/** * INTERNAL: * Get the attribute value from the object and add the appropriate * values to the specified database row. */ public void writeFromObjectIntoRow(Object object, AbstractRecord databaseRow, AbstractSession session) throws DescriptorException { if (isReadOnly()) { return; } AbstractRecord targetRow = buildRowFromAggregate(object, getAttributeValueFromObject(object), session); for (Enumeration stream = targetRow.keys(); stream.hasMoreElements();) { DatabaseField field = (DatabaseField)stream.nextElement(); Object value = targetRow.get(field); databaseRow.add(field, value); } }
/** * INTERNAL: * Return the value that should be stored in the identity map. If the value * is stored in the object, then return a null. */ public Object getValueToPutInCache(AbstractRecord row, AbstractSession session) { if (isStoredInCache()) { return session.getDatasourcePlatform().convertObject(row.get(getWriteLockField()), ClassConstants.TIMESTAMP); } else { return null; } }
/** * INTERNAL: * Get the attribute value from the object and add the changed * values to the specified database row. */ public void writeFromObjectIntoRowForUpdate(WriteObjectQuery query, AbstractRecord databaseRow) throws DescriptorException { if (isReadOnly()) { return; } AbstractRecord targetRow = buildRowFromAggregateForUpdate(query, getAttributeValueFromObject(query.getObject())); for (Enumeration stream = targetRow.keys(); stream.hasMoreElements();) { DatabaseField field = (DatabaseField)stream.nextElement(); Object value = targetRow.get(field); databaseRow.add(field, value); } }
/** * Update the rows on the database. Assume the call is correct. * @exception DatabaseException - an error has occurred on the database. */ public Integer updateAll() throws DatabaseException { if(((UpdateAllQuery)getQuery()).isPreparedUsingTempStorage() && getSession().getPlatform().supportsTempTables()) { return updateAllUsingTempTables(); } else { Integer rowCount = executeNoSelectCall(); if(((UpdateAllQuery)getQuery()).isPreparedUsingTempStorage()) { // the query was prepared using Oracle anonymous block AbstractRecord outputRow = (AbstractRecord)getQuery().getProperty("output"); rowCount = (Integer)outputRow.get("ROW_COUNT"); } return rowCount; } }