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

## org.objectstyle.cayenne
Interface DataObject

All Superinterfaces:
  Persistent, java.io.Serializable

All Known Implementing Classes:
  CayenneDataObject

    public interface DataObject

extends Persistent

Defines basic methods for a persistent object in Cayenne.

Author:
  Andrei Adamchik

Field Summary
`static long` | `DEFAULT_VERSION`

Method Summary
`void` | `addToManyTarget(java.lang.String relName, DataObject val, boolean setReverse)`
`void` | `fetchFinished()` Notification method called by DataContext after the object was read from the database.
`DataContext` | `getDataContext()` Returns a data context this object is registered with, or null if this object has no associated DataContext.
`long` | `getSnapshotVersion()` Returns a version of a DataRow snapshot that was used to create this object.
`java.lang.Object` | `readNestedProperty(java.lang.String path)` Returns a value of the property identified by a property path.
`java.lang.Object` | `readProperty(java.lang.String propName)` Returns a value of the property identified by propName.
`java.lang.Object` | `readPropertyDirectly(java.lang.String propertyName)` Returns mapped property value as curently stored in the DataObject.
`void` | `removeToManyTarget(java.lang.String relName, DataObject val, boolean setReverse)`
`void` | `resolveFault()` Deprecated. since 1.2 use 'getObjectContext().prepareForAccess(object)'
`void` | `setDataContext(DataContext ctxt)` Sets object DataContext.
`void` | `setSnapshotVersion(long snapshotVersion)`
`void` | `setToOneTarget(java.lang.String relationshipName, DataObject value, boolean setReverse)` Sets to-one relationship to a new value.
`void` | `validateForDelete(ValidationResult validationResult)` Performs property validation of the DELETED object, appending any validation failures to the provided validationResult object.
`void` | `validateForInsert(ValidationResult validationResult)` Performs property validation of the NEW object, appending any validation failures to the provided validationResult object.
`void` | `validateForUpdate(ValidationResult validationResult)` Performs property validation of the MODIFIED object, appending any validation failures to the provided validationResult object.
`void` | `writeProperty(java.lang.String propertyName, java.lang.Object value)` Sets the property to the new value.
`void` | `writePropertyDirectly(java.lang.String propertyName, java.lang.Object val)` Modifies a value of a named property without altering the object state in any way, and without triggering any database operations.

Methods inherited from interface org.objectstyle.cayenne.Persistent
`getObjectContext, getObjectId, getPersistenceState, setObjectContext, setObjectId, setPersistenceState`

Field Detail

### DEFAULT_VERSION

    static final long DEFAULT_VERSION

See Also:
  Constant Field Values

Method Detail

### getDataContext

    DataContext getDataContext()

  Returns a data context this object is registered with, or null if this object has no associated DataContext.

### setDataContext

    void setDataContext(DataContext ctxt)

  Sets object DataContext.

### writePropertyDirectly

    void writePropertyDirectly(java.lang.String propertyName,
                               java.lang.Object val)

  Modifies a value of a named property without altering the object state in any way, and without triggering any database operations. This method is intended mostly for internal use by Cayenne framework, and shouldn't be called from the application code.

### readPropertyDirectly

    java.lang.Object readPropertyDirectly(java.lang.String propertyName)

  Returns mapped property value as curently stored in the DataObject. Returned value maybe a fault or a real value. This method will not attempt to resolve faults, or to read unmapped properties.

### readNestedProperty

    java.lang.Object readNestedProperty(java.lang.String path)

  Returns a value of the property identified by a property path. Supports reading both mapped and unmapped properties. Unmapped properties are accessed in a manner consistent with JavaBeans specification.

  Property path (or nested property) is a dot-separated path used to traverse object relationships until the final object is found. If a null object found while traversing path, null is returned. If a list is encountered in the middle of the path, CayenneRuntimeException is thrown. Unlike `readPropertyDirectly(String)`, this method will resolve an object if it is HOLLOW.

  Examples:

  - Read this object property:
    `String name = (String)artist.readNestedProperty("name");`
  - Read an object related to this object:
    `Gallery g = (Gallery)paintingInfo.readNestedProperty("toPainting.toGallery");`
  - Read a property of an object related to this object:
    `String name = (String)painting.readNestedProperty("toArtist.artistName");`
  - Read to-many relationship list:
    `List exhibits = (List)painting.readNestedProperty("toGallery.exhibitArray");`
  - Read to-many relationship in the middle of the path (throws exception):
    `String name = (String)artist.readNestedProperty("paintingArray.paintingName");`

  Since:
    1.0.5

### readProperty

    java.lang.Object readProperty(java.lang.String propName)

  Returns a value of the property identified by propName. Resolves faults if needed. This method can safely be used instead of or in addition to the auto-generated property accessors in subclasses of CayenneDataObject.

### writeProperty

    void writeProperty(java.lang.String propertyName,
                       java.lang.Object value)

  Sets the property to the new value. Resolves faults if needed. This method can be safely used instead of or in addition to the auto-generated property modifiers to set simple properties. Note that to set to-one relationships use `setToOneTarget(String, DataObject, boolean)`.

  Parameters:
    `propertyName` - a name of the bean property being modified.
    `value` - a new value of the property.

### addToManyTarget

    void addToManyTarget(java.lang.String relName,
                         DataObject val,
                         boolean setReverse)

### removeToManyTarget

    void removeToManyTarget(java.lang.String relName,
                            DataObject val,
                            boolean setReverse)

### setToOneTarget

    void setToOneTarget(java.lang.String relationshipName,
                        DataObject value,
                        boolean setReverse)

  Sets to-one relationship to a new value. Resolves faults if needed. This method can safely be used instead of or in addition to the auto-generated property modifiers to set properties that are to-one relationships.

  Parameters:
    `relationshipName` - a name of the bean property being modified - same as the name of ObjRelationship.
    `value` - a new value of the property.
    `setReverse` - whether to update the reverse relationship pointing from the old and new values of the property to this object.

### fetchFinished

    void fetchFinished()

  Notification method called by DataContext after the object was read from the database.

### getSnapshotVersion

    long getSnapshotVersion()

  Returns a version of a DataRow snapshot that was used to create this object.

  Since:
    1.1

### setSnapshotVersion

    void setSnapshotVersion(long snapshotVersion)

  Since:
    1.1

### resolveFault

    void resolveFault()

  Deprecated. since 1.2 use 'getObjectContext().prepareForAccess(object)'

  Initializes object with data from cache or from the database, if this object is not fully resolved.

  Since:
    1.1

### validateForInsert

    void validateForInsert(ValidationResult validationResult)

  Performs property validation of the NEW object, appending any validation failures to the provided validationResult object. This method is invoked by DataContext before committing a NEW object to the database.

  Since:
    1.1

### validateForUpdate

    void validateForUpdate(ValidationResult validationResult)

  Performs property validation of the MODIFIED object, appending any validation failures to the provided validationResult object. This method is invoked by DataContext before committing a MODIFIED object to the database.

  Since:
    1.1

### validateForDelete

    void validateForDelete(ValidationResult validationResult)

  Performs property validation of the DELETED object, appending any validation failures to the provided validationResult object. This method is invoked by DataContext before committing a DELETED object to the database.

  Since:
    1.1

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 ObjectStyle.org All Rights Reserved.