Class DataRow

java.lang.Object
org.apache.cayenne.DataRow
All Implemented Interfaces:
Serializable, Map<String,Object>

public final class DataRow extends Object implements Map<String,Object>, Serializable
DataRow is a precursor of a persistent object that holds its database values, but models no relationships. A row is immutable and the mutating Map methods throw UnsupportedOperationException. A row is serializable when its values are. Rows serialized in one stream keep sharing their layout.
Since:
1.1
See Also:
  • Method Details

    • of

      public static DataRow of(String entityName, DataRowLayout layout, Object[] values, long version)
      Creates a row over the given values laid out by the given layout, with the given entity name and snapshot version. The array is not copied: the row takes ownership of it, and the caller must not use the array after this call.
      Since:
      5.0
    • getEntityName

      public String getEntityName()
      Returns the name of the ObjEntity this row is a snapshot of, or null if the row is not mapped to an entity.
      Since:
      3.0
    • getVersion

      public long getVersion()
      Returns the snapshot version of this row: the version of the operation (a SQL statement result, a commit) that produced it.
    • withEntityName

      public DataRow withEntityName(String entityName)
      Returns a row with the given entity name and this row's values and version. The values are shared: rows are immutable, so the copy is free.
      Since:
      5.0
    • merged

      public DataRow merged(Map<String,?> changes, long version)
      Returns a row with this row's entity name and the given version, holding this row's values overlaid with the given ones. The row keeps its layout when every changed key is a column of it, and gets its own wider layout otherwise.
      Since:
      5.0
    • size

      public int size()
      Specified by:
      size in interface Map<String,Object>
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface Map<String,Object>
    • containsKey

      public boolean containsKey(Object key)
      Specified by:
      containsKey in interface Map<String,Object>
    • containsValue

      public boolean containsValue(Object value)
      Specified by:
      containsValue in interface Map<String,Object>
    • get

      public Object get(Object key)
      Specified by:
      get in interface Map<String,Object>
    • getOrDefault

      public Object getOrDefault(Object key, Object defaultValue)
      Specified by:
      getOrDefault in interface Map<String,Object>
    • put

      public Object put(String key, Object value)
      Specified by:
      put in interface Map<String,Object>
    • remove

      public Object remove(Object key)
      Specified by:
      remove in interface Map<String,Object>
    • putAll

      public void putAll(Map<? extends String, ?> m)
      Specified by:
      putAll in interface Map<String,Object>
    • clear

      public void clear()
      Specified by:
      clear in interface Map<String,Object>
    • keySet

      public Set<String> keySet()
      Specified by:
      keySet in interface Map<String,Object>
    • values

      public Collection<Object> values()
      Specified by:
      values in interface Map<String,Object>
    • entrySet

      public Set<Map.Entry<String,Object>> entrySet()
      Specified by:
      entrySet in interface Map<String,Object>
    • forEach

      public void forEach(BiConsumer<? super String, ? super Object> action)
      Visits the entries in column order. Unlike the entry set, allocates nothing per entry.
      Specified by:
      forEach in interface Map<String,Object>
    • equals

      public boolean equals(Object o)
      Compares the rows as maps, i.e. by their keys and values and regardless of their entity names, versions or the order of their columns.
      Specified by:
      equals in interface Map<String,Object>
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface Map<String,Object>
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object