|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.cayenne.PersistentObject
org.apache.cayenne.CayenneDataObject
public class CayenneDataObject
A default implementation of DataObject interface. It is normally used as a superclass of Cayenne persistent objects.
Field Summary | |
---|---|
protected long |
snapshotVersion
|
protected java.util.Map<java.lang.String,java.lang.Object> |
values
|
Fields inherited from class org.apache.cayenne.PersistentObject |
---|
objectContext, objectId, persistenceState |
Fields inherited from interface org.apache.cayenne.DataObject |
---|
DEFAULT_VERSION |
Constructor Summary | |
---|---|
CayenneDataObject()
|
Method Summary | |
---|---|
void |
addToManyTarget(java.lang.String relName,
DataObject value,
boolean setReverse)
Adds an object to a to-many relationship. |
protected void |
appendProperties(java.lang.StringBuffer buffer)
|
void |
decodeFromXML(XMLDecoder decoder)
Deprecated. since 3.1 XML serialization package is deprecated and will be removed in the following releases. It has a number of functional and performance limitations that make it impossible to evolve further. A replacement may be provided in an undefined future. For now we recommend the users to implement XML serialization of persistent objects based JAXB, XStream or other similar frameworks. |
void |
encodeAsXML(XMLEncoder encoder)
Deprecated. since 3.1 XML serialization package is deprecated and will be removed in the following releases. It has a number of functional and performance limitations that make it impossible to evolve further. A replacement may be provided in an undefined future. For now we recommend the users to implement XML serialization of persistent objects based JAXB, XStream or other similar frameworks. |
long |
getSnapshotVersion()
Returns a version of a DataRow snapshot that was used to create this object. |
static java.lang.String |
makePath(java.lang.String... pathParts)
Convenience method to invoke Cayenne.makePath(String...) from
within a DataObject subclass to create a dotted path using the generated
string constants for attributes and relationships. |
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 propertyName)
Returns a value of the property identified by propName. |
java.lang.Object |
readPropertyDirectly(java.lang.String propName)
Returns mapped property value as curently stored in the DataObject. |
void |
removeToManyTarget(java.lang.String relName,
DataObject value,
boolean setReverse)
Removes an object from a to-many relationship. |
void |
setObjectContext(ObjectContext objectContext)
|
void |
setPersistenceState(int persistenceState)
|
protected void |
setReverseRelationship(java.lang.String relName,
DataObject val)
Initializes reverse relationship from object val to this object. |
void |
setSnapshotVersion(long snapshotVersion)
|
void |
setToOneTarget(java.lang.String relationshipName,
DataObject value,
boolean setReverse)
Sets to-one relationship to a new value. |
java.lang.String |
toString()
|
java.lang.StringBuffer |
toStringBuffer(java.lang.StringBuffer buffer,
boolean fullDesc)
A variation of "toString" method, that may be more efficient in some cases. |
protected void |
unsetReverseRelationship(java.lang.String relName,
DataObject val)
Removes current object from reverse relationship of object val to this
object. |
void |
validateForDelete(ValidationResult validationResult)
This implementation does nothing. |
void |
validateForInsert(ValidationResult validationResult)
Calls validateForSave(ValidationResult) . |
protected void |
validateForSave(ValidationResult validationResult)
Performs property validation of the object, appending any validation failures to the provided validationResult object. |
void |
validateForUpdate(ValidationResult validationResult)
Calls validateForSave(ValidationResult) . |
protected void |
willConnect(java.lang.String relationshipName,
Persistent object)
Called before establishing a relationship with another object. |
void |
writeProperty(java.lang.String propName,
java.lang.Object val)
Sets the property to the new value. |
void |
writePropertyDirectly(java.lang.String propName,
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 class org.apache.cayenne.PersistentObject |
---|
getMapKey, getObjectContext, getObjectId, getObjEntity, getPersistenceState, setObjectId |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.apache.cayenne.Persistent |
---|
getObjectContext, getObjectId, getPersistenceState, setObjectId |
Field Detail |
---|
protected long snapshotVersion
protected java.util.Map<java.lang.String,java.lang.Object> values
Constructor Detail |
---|
public CayenneDataObject()
Method Detail |
---|
public void setPersistenceState(int persistenceState)
setPersistenceState
in interface Persistent
setPersistenceState
in class PersistentObject
public java.lang.Object readNestedProperty(java.lang.String path)
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:
String name = (String)artist.readNestedProperty("name");
Gallery g = (Gallery)paintingInfo.readNestedProperty("toPainting.toGallery");
String name = (String)painting.readNestedProperty("toArtist.artistName");
List exhibits = (List)painting.readNestedProperty("toGallery.exhibitArray");
List names = (List)artist.readNestedProperty("paintingArray.paintingName");
readNestedProperty
in interface DataObject
public java.lang.Object readProperty(java.lang.String propertyName)
DataObject
readProperty
in interface DataObject
public java.lang.Object readPropertyDirectly(java.lang.String propName)
DataObject
readPropertyDirectly
in interface DataObject
public void writeProperty(java.lang.String propName, java.lang.Object val)
DataObject
DataObject.setToOneTarget(String, DataObject, boolean)
.
writeProperty
in interface DataObject
propName
- a name of the bean property being modified.val
- a new value of the property.public void writePropertyDirectly(java.lang.String propName, java.lang.Object val)
DataObject
writePropertyDirectly
in interface DataObject
public void removeToManyTarget(java.lang.String relName, DataObject value, boolean setReverse)
DataObject
removeToManyTarget
in interface DataObject
public void addToManyTarget(java.lang.String relName, DataObject value, boolean setReverse)
DataObject
addToManyTarget
in interface DataObject
public void setToOneTarget(java.lang.String relationshipName, DataObject value, boolean setReverse)
DataObject
setToOneTarget
in interface DataObject
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.protected void willConnect(java.lang.String relationshipName, Persistent object)
protected void setReverseRelationship(java.lang.String relName, DataObject val)
val
to this object.
relName
- name of relationship from this object to val
.protected void unsetReverseRelationship(java.lang.String relName, DataObject val)
val
to this
object.
public java.lang.StringBuffer toStringBuffer(java.lang.StringBuffer buffer, boolean fullDesc)
protected void appendProperties(java.lang.StringBuffer buffer)
public java.lang.String toString()
toString
in class PersistentObject
public long getSnapshotVersion()
getSnapshotVersion
in interface DataObject
public void setSnapshotVersion(long snapshotVersion)
setSnapshotVersion
in interface DataObject
public static java.lang.String makePath(java.lang.String... pathParts)
Cayenne.makePath(String...)
from
within a DataObject subclass to create a dotted path using the generated
string constants for attributes and relationships.
Cayenne.makePath(String...)
protected void validateForSave(ValidationResult validationResult)
public void validateForInsert(ValidationResult validationResult)
validateForSave(ValidationResult)
. CayenneDataObject subclasses may
override it providing validation logic that should be executed for the newly
created objects before saving them.
validateForInsert
in interface Validating
public void validateForUpdate(ValidationResult validationResult)
validateForSave(ValidationResult)
. CayenneDataObject subclasses may
override it providing validation logic that should be executed for the modified
objects before saving them.
validateForUpdate
in interface Validating
public void validateForDelete(ValidationResult validationResult)
validateForDelete
in interface Validating
@Deprecated public void encodeAsXML(XMLEncoder encoder)
encodeAsXML
in interface XMLSerializable
encoder
- The encoder object.@Deprecated public void decodeFromXML(XMLDecoder decoder)
XMLSerializable
decodeFromXML
in interface XMLSerializable
decoder
- The decoder object.public void setObjectContext(ObjectContext objectContext)
setObjectContext
in interface Persistent
setObjectContext
in class PersistentObject
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |