com.caucho.amber.entity
Class AmberEntityHome

java.lang.Object
  extended by com.caucho.amber.entity.AmberEntityHome
All Implemented Interfaces:
java.lang.Comparable

public class AmberEntityHome
extends java.lang.Object
implements java.lang.Comparable

Manages the set of persistent beans.


Constructor Summary
AmberEntityHome(AmberPersistenceUnit manager, EntityType type)
           
 
Method Summary
 void addUpdate(CacheUpdate update)
          Adds a cache update.
 int compareTo(java.lang.Object b)
           
 void delete(AmberConnection aConn, long primaryKey)
          Deletes by the primary key.
 void delete(AmberConnection aConn, java.lang.Object key)
          Deletes by the primary key.
 EntityItem findDiscriminatorEntityItem(AmberConnection aConn, java.lang.Object key, java.lang.String discriminator)
          Loads an entity where the type is determined by a discriminator
 EntityItem findEntityItem(AmberConnection aConn, java.lang.Object key)
           
 EntityItem findItem(AmberConnection aConn, java.sql.ResultSet rs, int index)
          Finds by the primary key.
 long getCacheTimeout()
          Returns the cache timeout.
 java.lang.reflect.Method getCauchoGetBeanMethod()
          Returns the getBean method to instantiate the Amber object.
 EntityFactory getEntityFactory()
          Returns the entity factory.
 EntityType getEntityType()
          Returns the entity type
 java.lang.Class getInstanceClass()
          Returns the instance class.
 java.lang.Class getJavaClass()
          Returns the java class.
 java.lang.Object getKeyFromEntity(Entity entity)
          Returns the entity from the key.
 AmberPersistenceUnit getManager()
          Returns the manager.
 EntityType getRootType()
          Returns the entity type
 void init()
          Initialize the home.
 java.lang.Object loadFull(AmberConnection aConn, java.sql.ResultSet rs, int index)
          Finds by the primary key.
 java.lang.Object loadLazy(AmberConnection aConn, java.sql.ResultSet rs, int index)
          Finds by the primary key.
 Entity makePersistent(Entity entity, AmberConnection aConn, boolean isLazy)
          Finds by the primary key.
 Entity newDiscriminatorEntity(java.lang.Object key, java.lang.String discriminator)
          Loads an entity where the type is determined by a discriminator
 Entity newEntity(java.lang.Object key)
          Instantiates a new entity for this home.
 void save(AmberConnection aConn, Entity entity)
          Saves based on the object.
 void setEntityFactory(EntityFactory factory)
          Sets the entity factory.
 EntityItem setEntityItem(java.lang.Object key, EntityItem item)
          Loads an entity based on the primary key.
 java.lang.Object toObjectKey(long key)
          Converts a long key to the key.
 java.lang.String toString()
           
 void update(Entity entity)
          Update for a modification.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AmberEntityHome

public AmberEntityHome(AmberPersistenceUnit manager,
                       EntityType type)
Method Detail

getCauchoGetBeanMethod

public java.lang.reflect.Method getCauchoGetBeanMethod()
Returns the getBean method to instantiate the Amber object.


getManager

public AmberPersistenceUnit getManager()
Returns the manager.


getEntityType

public EntityType getEntityType()
Returns the entity type


getRootType

public EntityType getRootType()
Returns the entity type


getJavaClass

public java.lang.Class getJavaClass()
Returns the java class.


getEntityFactory

public EntityFactory getEntityFactory()
Returns the entity factory.


setEntityFactory

public void setEntityFactory(EntityFactory factory)
Sets the entity factory.


getCacheTimeout

public long getCacheTimeout()
Returns the cache timeout.


getInstanceClass

public java.lang.Class getInstanceClass()
Returns the instance class.


init

public void init()
          throws ConfigException
Initialize the home.

Throws:
ConfigException

getKeyFromEntity

public java.lang.Object getKeyFromEntity(Entity entity)
                                  throws AmberException
Returns the entity from the key.

Throws:
AmberException

toObjectKey

public java.lang.Object toObjectKey(long key)
Converts a long key to the key.


findItem

public EntityItem findItem(AmberConnection aConn,
                           java.sql.ResultSet rs,
                           int index)
                    throws java.sql.SQLException
Finds by the primary key.

Throws:
java.sql.SQLException

loadFull

public java.lang.Object loadFull(AmberConnection aConn,
                                 java.sql.ResultSet rs,
                                 int index)
                          throws java.sql.SQLException
Finds by the primary key.

Throws:
java.sql.SQLException

loadLazy

public java.lang.Object loadLazy(AmberConnection aConn,
                                 java.sql.ResultSet rs,
                                 int index)
                          throws java.sql.SQLException
Finds by the primary key.

Throws:
java.sql.SQLException

findEntityItem

public EntityItem findEntityItem(AmberConnection aConn,
                                 java.lang.Object key)
                          throws AmberException
Throws:
AmberException

setEntityItem

public EntityItem setEntityItem(java.lang.Object key,
                                EntityItem item)
                         throws AmberException
Loads an entity based on the primary key.

Parameters:
key - the primary key
aConn - the Amber connection to associate with the loaded item
isLoad - if true, try to load the bean
Throws:
AmberException

findDiscriminatorEntityItem

public EntityItem findDiscriminatorEntityItem(AmberConnection aConn,
                                              java.lang.Object key,
                                              java.lang.String discriminator)
                                       throws java.sql.SQLException
Loads an entity where the type is determined by a discriminator

Parameters:
aConn - the connection to associate with the entity
key - the primary key
discriminator - the object's discriminator
Throws:
java.sql.SQLException

newEntity

public Entity newEntity(java.lang.Object key)
Instantiates a new entity for this home.


newDiscriminatorEntity

public Entity newDiscriminatorEntity(java.lang.Object key,
                                     java.lang.String discriminator)
Loads an entity where the type is determined by a discriminator

Parameters:
aConn - the connection to associate with the entity
key - the primary key
discriminator - the object's discriminator

makePersistent

public Entity makePersistent(Entity entity,
                             AmberConnection aConn,
                             boolean isLazy)
                      throws java.sql.SQLException
Finds by the primary key.

Throws:
java.sql.SQLException

save

public void save(AmberConnection aConn,
                 Entity entity)
          throws java.sql.SQLException
Saves based on the object.

Throws:
java.sql.SQLException

delete

public void delete(AmberConnection aConn,
                   java.lang.Object key)
            throws java.sql.SQLException
Deletes by the primary key.

Throws:
java.sql.SQLException

delete

public void delete(AmberConnection aConn,
                   long primaryKey)
            throws java.sql.SQLException
Deletes by the primary key.

Throws:
java.sql.SQLException

update

public void update(Entity entity)
            throws java.sql.SQLException
Update for a modification.

Throws:
java.sql.SQLException

addUpdate

public void addUpdate(CacheUpdate update)
Adds a cache update.


compareTo

public int compareTo(java.lang.Object b)
Specified by:
compareTo in interface java.lang.Comparable

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object