org.apache.cayenne
Class DataRow

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by java.util.HashMap<String,Object>
          extended by org.apache.cayenne.DataRow
All Implemented Interfaces:
Serializable, Cloneable, Map<String,Object>

public class DataRow
extends HashMap<String,Object>

DataRow a map that holds values retrieved from the database for a given query row. DataRows are used to cache raw database data and as a reference point for tracking DataObject changes.

Since:
1.1
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Field Summary
protected  String entityName
           
protected  long replacesVersion
           
protected  long version
           
 
Constructor Summary
DataRow(int initialCapacity)
           
DataRow(Map<String,?> map)
           
 
Method Summary
 DataRow applyDiff(DataRow diff)
          Builds a new DataRow, merging changes from diff parameter with data contained in this DataRow.
 DataRow createDiff(DataRow row)
          Creates a DataRow that contains only the keys that have values that differ between this object and row parameter.
 ObjectId createObjectId(ObjEntity entity)
          Deprecated. since 3.0 - unused
 ObjectId createObjectId(String entityName, DbEntity entity)
          Deprecated. since 3.0 - unused.
 ObjectId createObjectId(String entityName, DbEntity entity, String namePrefix)
          Deprecated. since 3.0 - unused.
 ObjectId createTargetObjectId(String entityName, DbRelationship relationship)
          Returns an ObjectId of an object on the other side of the to-one relationship, for this DataRow representing a source of relationship.
 String getEntityName()
           
 long getReplacesVersion()
           
 long getVersion()
           
 void setEntityName(String entityName)
           
 void setReplacesVersion(long replacesVersion)
          Sets the version of DataRow replaced by this one in the store.
 String toString()
           
 
Methods inherited from class java.util.HashMap
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values
 
Methods inherited from class java.util.AbstractMap
equals, hashCode
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Map
equals, hashCode
 

Field Detail

version

protected long version

replacesVersion

protected long replacesVersion

entityName

protected String entityName
Since:
3.0
Constructor Detail

DataRow

public DataRow(Map<String,?> map)

DataRow

public DataRow(int initialCapacity)
Method Detail

getVersion

public long getVersion()

getReplacesVersion

public long getReplacesVersion()

setReplacesVersion

public void setReplacesVersion(long replacesVersion)
Sets the version of DataRow replaced by this one in the store.


applyDiff

public DataRow applyDiff(DataRow diff)
Builds a new DataRow, merging changes from diff parameter with data contained in this DataRow.


createDiff

public DataRow createDiff(DataRow row)
Creates a DataRow that contains only the keys that have values that differ between this object and row parameter. Diff values are taken from the row parameter. It is assumed that key sets are compatible in both rows (e.g. they represent snapshots for the same entity). Returns null if no differences are found.


createObjectId

public ObjectId createObjectId(ObjEntity entity)
Deprecated. since 3.0 - unused

Creates an ObjectId from the values in the snapshot. If needed attributes are missing in a snapshot, CayenneRuntimeException is thrown.


createObjectId

public ObjectId createObjectId(String entityName,
                               DbEntity entity)
Deprecated. since 3.0 - unused.


createTargetObjectId

public ObjectId createTargetObjectId(String entityName,
                                     DbRelationship relationship)
Returns an ObjectId of an object on the other side of the to-one relationship, for this DataRow representing a source of relationship. Returns null if snapshot FK columns indicate a null to-one relationship.


createObjectId

public ObjectId createObjectId(String entityName,
                               DbEntity entity,
                               String namePrefix)
Deprecated. since 3.0 - unused.

Extracts PK columns prefixed with some path. If namePrefix is null or empty, no prefixing is done.

Prefixing is useful when extracting an ObjectId of a target row from a row obtained via prefetching. namePrefix must omit the "db:" prefix and must end with ".", e.g. "TO_ARTIST.PAINTING_ARRAY."

Since:
1.2

toString

public String toString()
Overrides:
toString in class AbstractMap<String,Object>

getEntityName

public String getEntityName()
Since:
3.0

setEntityName

public void setEntityName(String entityName)
Since:
3.0


Copyright © 2001-2011 Apache Cayenne. All Rights Reserved.