Class SDataSet

java.lang.Object
simpleorm.dataset.SDataSet
All Implemented Interfaces:
Serializable

public class SDataSet extends Object implements Serializable
A DataSet contains records of various types together with their meta data. The records are indexed by their type and primary keys, and so can be efficiently retrieved. A list of dirty records that need to be updated is also maintained.

A DataSet is normally associated with a SSession/Jdbc, and is accessed indirectly via the SSessionJdbc methods. But a DataSet can also be accessed directly when it is detached from the SSession.

See Also:
  • Constructor Details

    • SDataSet

      public SDataSet()
  • Method Details

    • findOrCreate

      public <RI extends SRecordInstance> RI findOrCreate(SRecordMeta<RI> rmeta, Object... keys)
    • find

      public <RI extends SRecordInstance> RI find(SRecordMeta<RI> rmeta, Object... keys)
    • create

      public <RI extends SRecordInstance> RI create(SRecordMeta<RI> rmeta, Object... keys)
    • createWithNullKey

      public <RI extends SRecordInstance> RI createWithNullKey(SRecordMeta<RI> rmeta)
      Used if no key is known, and one is to be provided later.
    • removeRecord

      public void removeRecord(SRecordInstance rinst)
      Remove record from cache, does not flag it for deletion.
    • queryAllRecords

      public Collection<SRecordInstance> queryAllRecords()
    • queryReferencing

      public <I extends SRecordInstance, R extends SRecordInstance> List<R> queryReferencing(I refed, SFieldReference<I> ref)
      Return all records in dataset where rec.ref == ref. Ie. the inverse of findRecrod.
    • isAttached

      public boolean isAttached()
    • clearDirtyList

      public void clearDirtyList()
    • getDirtyRecords

      public List<SRecordInstance> getDirtyRecords()
      Ordered list of SRecordInstances to flush and purge.
    • purge

      public void purge()
      Remove all records from cache and update list.
    • destroy

      public void destroy()
    • clone

      public SDataSet clone()
      Clone the dataset. Useful befor attempting to attach and commit to recover from errors. (See LongTransactionTest).

      Curent implementation uses slow serialization alg, should really use clone()/able.

      Overrides:
      clone in class Object
    • newInstanceNotInDataSet

      @Deprecated public <RI extends SRecordInstance> RI newInstanceNotInDataSet(SRecordMeta<RI> rmeta)
      Deprecated.
      Create a new instance of this record, used by SSession during the fiddly doFindOrCreate etc.

    • findUsingPrototype

      @Deprecated public <RI extends SRecordInstance> RI findUsingPrototype(RI rinst)
      Deprecated.
    • pokeIntoDataSet

      @Deprecated public void pokeIntoDataSet(SRecordInstance rinst)
      Deprecated.
    • getLogger

      public SLog getLogger()
    • createDetachedInstance

      @Deprecated public static <RI extends SRecordInstance> RI createDetachedInstance(SRecordMeta<RI> rmeta)
      Deprecated.
      Create a new instance of this record, unattached to a dataset. Used for backward compatibility, records normally ONLY live within a DataSet. Detached records are marked as new.
    • attach

      @Deprecated public void attach(SRecordInstance rinst)
      Deprecated.
      Attach rinst into the dataset, checking that it is not already there. References should be null. Only for compatibility with 2.*, normally records only normal created within data sets.
    • dumpDataSet

      public void dumpDataSet()
      Dumps out the entire cache of records for this connection. For debugging wierd bugs only.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getSession

      public SSessionI getSession()
    • setSession

      public void setSession(SSessionI session)