Class DataObjectBase

java.lang.Object
org.kuali.rice.krad.bo.DataObjectBase
All Implemented Interfaces:
Serializable, org.kuali.rice.core.api.mo.common.GloballyUnique, org.kuali.rice.core.api.mo.common.Versioned
Direct Known Subclasses:
MaintenanceLock, PersistableBusinessObjectBaseAdapter, SessionDocument

@MappedSuperclass public abstract class DataObjectBase extends Object implements org.kuali.rice.core.api.mo.common.Versioned, org.kuali.rice.core.api.mo.common.GloballyUnique, Serializable
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.

Author:
Kuali Rice Team (rice.collab@kuali.org)
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected String
     
    protected Long
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    If this PersistableBusinessObject does not already have a unique objectId, this method will generate one and set it's value on this object.
     
    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.
     
    protected void
    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
    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)
     
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • versionNumber

      protected Long versionNumber
    • objectId

      protected String objectId
  • Constructor Details

    • DataObjectBase

      public DataObjectBase()
  • Method Details

    • getVersionNumber

      public Long getVersionNumber()
      Specified by:
      getVersionNumber in interface org.kuali.rice.core.api.mo.common.Versioned
    • setVersionNumber

      public void setVersionNumber(Long versionNumber)
    • getObjectId

      public 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.
      Specified by:
      getObjectId in interface org.kuali.rice.core.api.mo.common.GloballyUnique
      Returns:
    • setObjectId

      public 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.
      Parameters:
      objectId -
    • prePersist

      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. 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

      invalid reference
      #beforeInsert(PersistenceBroker)
      hook.
    • preUpdate

      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. 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

      invalid reference
      #beforeUpdate(PersistenceBroker)
      hook.
    • generateAndSetObjectIdIfNeeded

      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.
    • getExtensionObject

      public Object getExtensionObject()
    • setExtensionObject

      public void setExtensionObject(Object extensionObject)
    • toString

      public String toString()
      Overrides:
      toString in class Object