|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.kuali.rice.krad.bo.DataObjectBase
@MappedSuperclass public abstract class DataObjectBase
Declares an optional superclass for classes which can have their state persisted. A data object which is persistable defines some additional methods which allow for various operations to be executed that relate to the persistent nature of the data object. A persistable data object also has some additional data attributes which include the version number, the object id, and the extension.
The version number indicates the version of the data object when it was retrieved from persistent storage. This allows for services to check this version number during persistence operations to prevent silent overwrites of data object state. These kinds of scenarios might arise as a result of concurrent modification to the data object in the persistent store (i.e. two web application users updating the same record in a database). The kind of check which would be performed using the version number is commonly referred to as "optimistic locking".
The object id represents a globally unique identifier for the business object. In practice,
this can be used by other portions of the system to link to data objects which
might be stored in different locations or even different persistent data stores. In general, it
is not the responsibility of the client who implements a persistable data object to handle
generating this value. The framework will handle this automatically at the point in time when
the data object is persisted. If the client does need to do this themselves, however, care
should be taken that an appropriate globally unique value generator algorithm is used
(such as the one provided by UUID
).
The extension object is primarily provided for the purposes of allowing implementer
customization of the data object without requiring the original data object to be
modified. The additional extension object which is linked with the
parent data object via use of ExtensionFor
annotation on the actual extension class} can contain additional data attributes and methods.
The framework will automatically request that this extension object be persisted when the parent
data object is persisted. This is generally the most useful in cases where an application is defining
data objects that will be used in redistributable software packages (such as the
actual Kuali Foundation projects themselves). If using the framework for the purposes
of implementing an internal application, the use of a data object extensions
is likely unnecessary.
Field Summary | |
---|---|
protected String |
objectId
|
protected Long |
versionNumber
|
Constructor Summary | |
---|---|
DataObjectBase()
|
Method Summary | |
---|---|
protected void |
generateAndSetObjectIdIfNeeded()
If this PersistableBusinessObject does not already have a unique objectId, this method will generate one and set it's value on this object. |
Object |
getExtensionObject()
|
String |
getObjectId()
getter for the guid based object id that is assignable to all objects, in order to support custom attributes a mapping must also be added to the OJB file and a column must be added to the database for each business object that extension attributes are supposed to work on. |
Long |
getVersionNumber()
Returns the version number for this object. |
protected void |
prePersist()
Default implementation of the JPA PrePersist hook which generates the unique objectId for this
persistable business object if it does not already have one. |
protected void |
preUpdate()
Default implementation of the JPA PreUpdate hook which generates the unique objectId for this
persistable business object if it does not already have one. |
void |
setExtensionObject(Object extensionObject)
|
void |
setObjectId(String objectId)
setter for the guid based object id that is assignable to all objects, in order to support custom attributes a mapping must also be added to the OJB file and column must be added to the database for each business object that extension attributes are supposed to work on. |
void |
setVersionNumber(Long versionNumber)
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected Long versionNumber
protected String objectId
Constructor Detail |
---|
public DataObjectBase()
Method Detail |
---|
public Long getVersionNumber()
Versioned
getVersionNumber
in interface Versioned
public void setVersionNumber(Long versionNumber)
public String getObjectId()
getObjectId
in interface GloballyUnique
public void setObjectId(String objectId)
objectId
- protected void prePersist()
PrePersist
hook which generates the unique objectId for this
persistable business object if it does not already have one. Any sub-class which overrides this method
should take care to invoke super.prePersist to ensure that the objectId for this persistable
business object is generated properly.
This method is currently invoked by the corresponding OJB #beforeInsert(PersistenceBroker)
hook.
protected void preUpdate()
PreUpdate
hook which generates the unique objectId for this
persistable business object if it does not already have one. Any sub-class which overrides this method
should take care to invoke super.preUpdate to ensure that the objectId for this persistable
business object is generated properly.
This method is currently invoked by the corresponding OJB #beforeUpdate(PersistenceBroker)
hook.
protected void generateAndSetObjectIdIfNeeded()
public Object getExtensionObject()
public void setExtensionObject(Object extensionObject)
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |