What is the best way to determine if a Transfer Object is populated or is new object?
What is the best way to determine if a Transfer Object is populated or is new object?
getIsPersisted() tells you if the object came from, or has been stored (persisted) in the database.
getIsDirty() tells you if the object has changed since it was last committed, OR if it was never committed in the first place.
- A new object - persisted: false, dirty: true
- A saved object - persisted: true, dirty: false
- A saved object that has been modified, but not re-saved - persisted: true, dirty: true
- A get'd object - persisted: true, dirty: false.
Generally, you only ever need check getIsPersisted(). More details can be seen at Generated Methods.
Wiki Menu
User Login