com.avaje.ebean
Interface BeanState


public interface BeanState

Provides access to the internal state of an entity bean.


Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          Add a propertyChangeListener.
 Set<String> getChangedProps()
          Return the set of changed properties.
 Set<String> getLoadedProps()
          For partially populated beans returns the properties that are loaded on the bean.
 boolean isDirty()
          Return true if the bean has been changed but not yet saved.
 boolean isNew()
          Return true if the bean is new (and not yet saved).
 boolean isNewOrDirty()
          Return true if the bean is new or dirty (and probably needs to be saved).
 boolean isReadOnly()
          Return true if the bean is readOnly.
 boolean isReference()
          Return true if this is a lazy loading reference bean.
 boolean isSharedInstance()
          Return true if this is a shared instance.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Remove a propertyChangeListener.
 void setLoaded(Set<String> loadedProperties)
          Advanced - Used to programmatically build a partially or fully loaded entity bean.
 void setReadOnly(boolean readOnly)
          Set the readOnly status for the bean.
 void setReference()
          Advanced - Used to programmatically build a reference object.
 

Method Detail

isReference

boolean isReference()
Return true if this is a lazy loading reference bean.

If so the this bean only holds the Id property and will invoke lazy loading if any other property is get or set.


isNew

boolean isNew()
Return true if the bean is new (and not yet saved).


isNewOrDirty

boolean isNewOrDirty()
Return true if the bean is new or dirty (and probably needs to be saved).


isDirty

boolean isDirty()
Return true if the bean has been changed but not yet saved.


getLoadedProps

Set<String> getLoadedProps()
For partially populated beans returns the properties that are loaded on the bean.

Accessing another property will cause lazy loading to occur.


getChangedProps

Set<String> getChangedProps()
Return the set of changed properties.


isReadOnly

boolean isReadOnly()
Return true if the bean is readOnly.

If a setter is called on a readOnly bean it will throw an exception.


setReadOnly

void setReadOnly(boolean readOnly)
Set the readOnly status for the bean.


isSharedInstance

boolean isSharedInstance()
Return true if this is a shared instance.

This means the instance is potentially being used by other users/threads concurrently and must always be read only.

Typically this instance has come from the server cache. If a 'readOnly' object is request by a query etc and the cache is used then Ebean can return the shared instance rather than creating and returning a copy.


addPropertyChangeListener

void addPropertyChangeListener(PropertyChangeListener listener)
Add a propertyChangeListener.


removePropertyChangeListener

void removePropertyChangeListener(PropertyChangeListener listener)
Remove a propertyChangeListener.


setReference

void setReference()
Advanced - Used to programmatically build a reference object.

You can create a new EntityBean ( EbeanServer.createEntityBean(Class), set its Id property and then call this setReference() method.


setLoaded

void setLoaded(Set<String> loadedProperties)
Advanced - Used to programmatically build a partially or fully loaded entity bean. First create an entity bean via EbeanServer.createEntityBean(Class), then populate its properties and then call this method specifying which properties where loaded or null for a fully loaded entity bean.

Parameters:
loadedProperties - the properties that where loaded or null for a fully loaded entity bean.


Copyright © 2010. All Rights Reserved.