org.kuali.rice.krad.bo
Class DataObjectBase

java.lang.Object
  extended by org.kuali.rice.krad.bo.DataObjectBase
All Implemented Interfaces:
Serializable, GloballyUnique, Versioned
Direct Known Subclasses:
ActiveFromToBo, CodedAttributeBo, DelegateTypeBo, DocumentRouteHeaderValue, EntityAddressBase, EntityAffiliationBase, EntityBioDemographicsBo, EntityBo, EntityCitizenshipBase, EntityEmailBase, EntityEmploymentBase, EntityEthnicityBo, EntityExternalIdentifierBo, EntityNameBase, EntityPhoneBase, EntityPrivacyPreferencesBo, EntityResidencyBo, EntityTypeBo, EntityTypeContactInfoBo, EntityVisaBo, GroupBase, KimAttributeDataBo, KimTypeAttributeBo, KimTypeBo, LabsEncryptedTravelAccountType, LabsRoleMember, LabsTravelAttachment, LabsTravelAttachmentGroup, LabsTravelCompany, LabsUserControl, PrincipalBo, ResponsibilityBo, RoleBo, RoleBoLite, RolePermissionBo, RoleResponsibilityActionBo, RoleResponsibilityBo, TravelAccount, TravelCompany, TravelDestination, TravelerDetail, TravelerType, TravelExpenseItem, TravelMileageRate, TravelPerDiemExpense, TravelSubAccount, UIRoleMember

@MappedSuperclass
public abstract class DataObjectBase
extends Object
implements Versioned, 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:
Serialized Form

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

versionNumber

protected Long versionNumber

objectId

protected String objectId
Constructor Detail

DataObjectBase

public DataObjectBase()
Method Detail

getVersionNumber

public Long getVersionNumber()
Description copied from interface: Versioned
Returns the version number for this object. In general, this value should only be null if the object has not yet been stored to a persistent data store. This version number is generally used for the purposes of optimistic locking.

Specified by:
getVersionNumber in interface Versioned
Returns:
the version number, or null if one has not been assigned yet

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


Copyright © 2005–2014 The Kuali Foundation. All rights reserved.