public class CayenneDataObject extends PersistentObject implements DataObject, Validating, XMLSerializable
| Modifier and Type | Field and Description |
|---|---|
protected long |
snapshotVersion |
protected Map<String,Object> |
values |
objectContext, objectId, persistenceStateDEFAULT_VERSION| Constructor and Description |
|---|
CayenneDataObject() |
| Modifier and Type | Method and Description |
|---|---|
void |
addToManyTarget(String relName,
DataObject value,
boolean setReverse)
Adds an object to a to-many relationship.
|
protected void |
appendProperties(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 String |
makePath(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. |
Object |
readNestedProperty(String path)
Returns a value of the property identified by a property path.
|
Object |
readProperty(String propertyName)
Returns a value of the property identified by propName.
|
Object |
readPropertyDirectly(String propName)
Returns mapped property value as curently stored in the DataObject.
|
void |
removeToManyTarget(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(String relName,
DataObject val)
Initializes reverse relationship from object
val to this object. |
void |
setSnapshotVersion(long snapshotVersion) |
void |
setToOneTarget(String relationshipName,
DataObject value,
boolean setReverse)
Sets to-one relationship to a new value.
|
String |
toString() |
StringBuffer |
toStringBuffer(StringBuffer buffer,
boolean fullDesc)
A variation of "toString" method, that may be more efficient in some cases.
|
protected void |
unsetReverseRelationship(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)
|
protected void |
validateForSave(ValidationResult validationResult)
Performs property validation of the object, appending any validation failures to
the provided validationResult object.
|
void |
validateForUpdate(ValidationResult validationResult)
|
protected void |
willConnect(String relationshipName,
Persistent object)
Called before establishing a relationship with another object.
|
void |
writeProperty(String propName,
Object val)
Sets the property to the new value.
|
void |
writePropertyDirectly(String propName,
Object val)
Modifies a value of a named property without altering the object state in any way,
and without triggering any database operations.
|
getMapKey, getObjectContext, getObjectId, getObjEntity, getPersistenceState, setObjectIdclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetObjectContext, getObjectId, getPersistenceState, setObjectIdpublic void setPersistenceState(int persistenceState)
setPersistenceState in interface PersistentsetPersistenceState in class PersistentObjectpublic Object readNestedProperty(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 DataObjectpublic Object readProperty(String propertyName)
DataObjectreadProperty in interface DataObjectpublic Object readPropertyDirectly(String propName)
DataObjectreadPropertyDirectly in interface DataObjectpublic void writeProperty(String propName, Object val)
DataObjectDataObject.setToOneTarget(String, DataObject, boolean).writeProperty in interface DataObjectpropName - a name of the bean property being modified.val - a new value of the property.public void writePropertyDirectly(String propName, Object val)
DataObjectwritePropertyDirectly in interface DataObjectpublic void removeToManyTarget(String relName, DataObject value, boolean setReverse)
DataObjectremoveToManyTarget in interface DataObjectpublic void addToManyTarget(String relName, DataObject value, boolean setReverse)
DataObjectaddToManyTarget in interface DataObjectpublic void setToOneTarget(String relationshipName, DataObject value, boolean setReverse)
DataObjectsetToOneTarget in interface DataObjectrelationshipName - 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(String relationshipName, Persistent object)
protected void setReverseRelationship(String relName, DataObject val)
val to this object.relName - name of relationship from this object to val.protected void unsetReverseRelationship(String relName, DataObject val)
val to this
object.public StringBuffer toStringBuffer(StringBuffer buffer, boolean fullDesc)
protected void appendProperties(StringBuffer buffer)
public String toString()
toString in class PersistentObjectpublic long getSnapshotVersion()
getSnapshotVersion in interface DataObjectpublic void setSnapshotVersion(long snapshotVersion)
setSnapshotVersion in interface DataObjectpublic static String makePath(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 Validatingpublic 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 Validatingpublic void validateForDelete(ValidationResult validationResult)
validateForDelete in interface Validating@Deprecated public void encodeAsXML(XMLEncoder encoder)
encodeAsXML in interface XMLSerializableencoder - The encoder object.@Deprecated public void decodeFromXML(XMLDecoder decoder)
XMLSerializabledecodeFromXML in interface XMLSerializabledecoder - The decoder object.public void setObjectContext(ObjectContext objectContext)
setObjectContext in interface PersistentsetObjectContext in class PersistentObjectCopyright © 2001–2018 Apache Cayenne. All rights reserved.