Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.cayenne
Interface ObjectContext

All Superinterfaces:
  java.io.Serializable

All Known Implementing Classes:
  CayenneContext, DataContext

    public interface ObjectContext

extends java.io.Serializable

A Cayenne object facade to a persistent store. Instances of ObjectContext are used in the application code to access Cayenne persistence features.

Since:
  1.2
Author:
  Andrus Adamchik

Method Summary
`void` | `commitChanges()` Flushes all changes to objects in this context to the parent DataChannel, cascading flush operation all the way through the stack, ultimately saving data in the database.
`void` | `commitChangesToParent()` Flushes all changes to objects in this context to the parent DataChannel.
`java.util.Collection` | `deletedObjects()` Returns a collection of objects that are registered with this ObjectContext and have a state PersistenceState.DELETED
`void` | `deleteObject(Persistent object)` Schedules a persistent object for deletion on next commit.
`DataChannel` | `getChannel()` Returns an DataChannel used by this context.
`EntityResolver` | `getEntityResolver()` Returns EntityResolver that stores all mapping information accessible by this ObjectContext.
`GraphManager` | `getGraphManager()` Returns GraphManager that manages object graph associated with this context.
`Persistent` | `localObject(ObjectId id, Persistent prototype)` Returns an object local to this ObjectContext and matching the ObjectId.
`java.util.Collection` | `modifiedObjects()` Returns a collection of objects that are registered with this ObjectContext and have a state PersistenceState.MODIFIED
`Persistent` | `newObject(java.lang.Class persistentClass)` Creates a new persistent object scheduled to be inserted to the database on next commit.
`java.util.Collection` | `newObjects()` Returns a collection of objects that are registered with this ObjectContext and have a state PersistenceState.NEW
`QueryResponse` | `performGenericQuery(Query query)` Executes any kind of query providing the result in a form of QueryResponse.
`java.util.List` | `performQuery(Query query)` Executes a selecting query, returning a list of persistent objects or data rows.
`void` | `prepareForAccess(Persistent object, java.lang.String property)` A callback method that child Persistent objects are expected to call from inside the getter before returning a value of a persistent property.
`void` | `propertyChanged(Persistent object, java.lang.String property, java.lang.Object oldValue, java.lang.Object newValue)` A callback method that child Persistent objects are expected to call from inside the setter after modifying a value of a persistent property.
`void` | `rollbackChanges()` Resets all uncommitted changes made to the objects in this ObjectContext, cascading rollback operation all the way through the stack.
`void` | `rollbackChangesLocally()` Resets all uncommitted changes made to the objects in this ObjectContext.
`java.util.Collection` | `uncommittedObjects()` Returns a collection of MODIFIED, DELETED or NEW objects.

Method Detail

### getEntityResolver

    EntityResolver getEntityResolver()

  Returns EntityResolver that stores all mapping information accessible by this ObjectContext.

### newObjects

    java.util.Collection newObjects()

  Returns a collection of objects that are registered with this ObjectContext and have a state PersistenceState.NEW

### deletedObjects

    java.util.Collection deletedObjects()

  Returns a collection of objects that are registered with this ObjectContext and have a state PersistenceState.DELETED

### modifiedObjects

    java.util.Collection modifiedObjects()

  Returns a collection of objects that are registered with this ObjectContext and have a state PersistenceState.MODIFIED

### uncommittedObjects

    java.util.Collection uncommittedObjects()

  Returns a collection of MODIFIED, DELETED or NEW objects.

### localObject

    Persistent localObject(ObjectId id,
                           Persistent prototype)

  Returns an object local to this ObjectContext and matching the ObjectId. If `prototype` is not null, local object is refreshed with the prototype values.

  This method can do both "mapping" (i.e. finding an object with the same id in this context) and "synchronization" (i.e. updating the state of the found object with the state of the prototype object).

### newObject

    Persistent newObject(java.lang.Class persistentClass)

  Creates a new persistent object scheduled to be inserted to the database on next commit.

### deleteObject

    void deleteObject(Persistent object)
                      throws DeleteDenyException

  Schedules a persistent object for deletion on next commit.

  Throws:
    `DeleteDenyException` - if a `DeleteRule.DENY` delete rule is applicable for object deletion.

### prepareForAccess

    void prepareForAccess(Persistent object,
                          java.lang.String property)

  A callback method that child Persistent objects are expected to call from inside the getter before returning a value of a persistent property. Such callback allows ObjectContext to "inflate" unresolved objects on demand.

### propertyChanged

    void propertyChanged(Persistent object,
                         java.lang.String property,
                         java.lang.Object oldValue,
                         java.lang.Object newValue)

  A callback method that child Persistent objects are expected to call from inside the setter after modifying a value of a persistent property.

### commitChanges

    void commitChanges()

  Flushes all changes to objects in this context to the parent DataChannel, cascading flush operation all the way through the stack, ultimately saving data in the database.

### commitChangesToParent

    void commitChangesToParent()

  Flushes all changes to objects in this context to the parent DataChannel. Same as `commitChanges()`, but no cascading flush occurs.

### rollbackChanges

    void rollbackChanges()

  Resets all uncommitted changes made to the objects in this ObjectContext, cascading rollback operation all the way through the stack.

### rollbackChangesLocally

    void rollbackChangesLocally()

  Resets all uncommitted changes made to the objects in this ObjectContext. Same as `rollbackChanges()()`, but rollback is local to this context and no cascading changes undoing occurs.

### performQuery

    java.util.List performQuery(Query query)

  Executes a selecting query, returning a list of persistent objects or data rows.

### performGenericQuery

    QueryResponse performGenericQuery(Query query)

  Executes any kind of query providing the result in a form of QueryResponse.

### getGraphManager

    GraphManager getGraphManager()

  Returns GraphManager that manages object graph associated with this context.

### getChannel

    DataChannel getChannel()

  Returns an DataChannel used by this context.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2006 Apache.org All Rights Reserved.