use of org.eclipse.persistence.sessions.DatabaseRecord in project eclipselink by eclipse-ee4j.
the class CacheInvalidator method invalidateObject.
// invalidates in tjhe cache the object corresponding to the massage
public void invalidateObject(Session session, javax.jms.Message msg) throws javax.jms.JMSException {
String tableName = msg.getStringProperty("TABLE");
if (tableName == null) {
return;
}
Class<?> baseClass = (Class) tableNameToClass.get(tableName);
if (baseClass == null) {
return;
}
Vector pkFieldNames = (Vector) tableNameToPkFieldNames.get(tableName);
if (pkFieldNames == null) {
return;
}
// create DatabaseRecord corresponding to the message
DatabaseRecord row = new DatabaseRecord(pkFieldNames.size());
for (int i = 0; i < pkFieldNames.size(); i++) {
String fieldName = (String) pkFieldNames.elementAt(i);
Object value = msg.getObjectProperty(fieldName);
row.put(fieldName, value);
}
// invalidate in TopLink cache the object corresponding to the row and the baseClass
session.getIdentityMapAccessor().invalidateObject(row, baseClass);
}
use of org.eclipse.persistence.sessions.DatabaseRecord in project eclipselink by eclipse-ee4j.
the class CascadeLockingPolicy method getMappedTranslationRow.
/**
* INTERNAL:
*/
protected AbstractRecord getMappedTranslationRow(Object changedObj, UnitOfWorkImpl uow) {
AbstractRecord translationRow = new DatabaseRecord();
Iterator<Map.Entry<DatabaseField, DatabaseField>> it = m_mappedQueryKeyFields.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<DatabaseField, DatabaseField> entry = it.next();
Object value = m_descriptor.getObjectBuilder().extractValueFromObjectForField(changedObj, entry.getValue(), uow);
translationRow.add(entry.getKey(), value);
}
return translationRow;
}
use of org.eclipse.persistence.sessions.DatabaseRecord in project eclipselink by eclipse-ee4j.
the class CascadeLockingPolicy method getUnmappedTranslationRow.
/**
* INTERNAL:
*/
protected AbstractRecord getUnmappedTranslationRow(Object changedObj, UnitOfWorkImpl uow) {
AbstractRecord unmappedFieldsQueryTranslationRow = new DatabaseRecord();
Iterator<DatabaseField> itPrimaryKey = m_descriptor.getPrimaryKeyFields().iterator();
while (itPrimaryKey.hasNext()) {
DatabaseField primaryKey = itPrimaryKey.next();
Object value = m_descriptor.getObjectBuilder().extractValueFromObjectForField(changedObj, primaryKey, uow);
unmappedFieldsQueryTranslationRow.add(primaryKey, value);
}
List result = (List) uow.executeQuery(m_unmappedFieldsQuery, unmappedFieldsQueryTranslationRow);
if (result == null || result.isEmpty()) {
// the object is not in the db
return null;
}
AbstractRecord unmappedValues = (AbstractRecord) result.get(0);
AbstractRecord translationRow = new DatabaseRecord();
Iterator<Map.Entry<DatabaseField, DatabaseField>> it = m_unmappedQueryKeyFields.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<DatabaseField, DatabaseField> entry = it.next();
Object value = unmappedValues.get(entry.getValue());
translationRow.add(entry.getKey(), value);
}
return translationRow;
}
use of org.eclipse.persistence.sessions.DatabaseRecord in project eclipselink by eclipse-ee4j.
the class OneToOneMapping method buildShallowOriginalFromRow.
/**
* INTERNAL:
* Builds a shallow original object. Only direct attributes and primary
* keys are populated. In this way the minimum original required for
* instantiating a working copy clone can be built without placing it in
* the shared cache (no concern over cycles).
*/
@Override
public void buildShallowOriginalFromRow(AbstractRecord databaseRow, Object original, JoinedAttributeManager joinManager, ObjectBuildingQuery query, AbstractSession executionSession) {
// Now we are only building this original so we can extract the primary
// key out of it. If the primary key is stored across a 1-1 a value
// holder needs to be built/triggered to get at it.
// In this case recursively build the shallow original across the 1-1.
// We only need the primary key for that object, and we know
// what that primary key is: it is the foreign key in our row.
ClassDescriptor descriptor = getReferenceDescriptor();
AbstractRecord targetRow = new DatabaseRecord();
for (Iterator<DatabaseField> keys = getSourceToTargetKeyFields().keySet().iterator(); keys.hasNext(); ) {
DatabaseField foreignKey = keys.next();
DatabaseField targetKey = getSourceToTargetKeyFields().get(foreignKey);
targetRow.put(targetKey, databaseRow.get(foreignKey));
}
Object targetObject = descriptor.getObjectBuilder().buildNewInstance();
descriptor.getObjectBuilder().buildAttributesIntoShallowObject(targetObject, targetRow, query);
targetObject = getIndirectionPolicy().valueFromRow(targetObject);
setAttributeValueInObject(original, targetObject);
}
use of org.eclipse.persistence.sessions.DatabaseRecord in project eclipselink by eclipse-ee4j.
the class AbstractTransformationMapping method buildPhantomRowFrom.
/**
* INTERNAL
* Build a phantom row that contains only the fields
* for the mapping, populated with the values generated by
* invoking the field methods on the specified object.
*/
protected AbstractRecord buildPhantomRowFrom(Object domainObject, AbstractSession session) {
AbstractRecord row = new DatabaseRecord(this.fieldToTransformers.size());
for (Object[] pair : this.fieldToTransformers) {
DatabaseField field = (DatabaseField) pair[0];
FieldTransformer transformer = (FieldTransformer) pair[1];
Object fieldValue = this.invokeFieldTransformer(field, transformer, domainObject, session);
row.put(field, fieldValue);
}
return row;
}
Aggregations