public class EntityType extends AmberBeanType
Modifier and Type | Field and Description |
---|---|
protected int |
_defaultLoadGroupIndex |
protected int |
_dirtyIndex |
protected boolean |
_hasLoadCallback |
protected int |
_loadGroupIndex |
protected int |
_minDirtyIndex |
Constructor and Description |
---|
EntityType(AmberPersistenceUnit amberPersistenceUnit) |
Modifier and Type | Method and Description |
---|---|
void |
addField(AmberField field)
Adds a new field.
|
void |
addListener(ListenerType listener)
Adds an entity listener.
|
void |
addMappedSuperclassField(AmberField field)
Adds a mapped superclass field.
|
void |
addSecondaryTable(AmberTable table)
Adds a secondary table.
|
void |
addSubClass(EntityType type)
Adds a sub-class.
|
Entity |
createBean()
Creates a new entity for this specific instance type.
|
AmberCompletion |
createManyToOneCompletion(java.lang.String name,
Entity source,
java.lang.Object newTarget)
Returns a completion for the given field.
|
void |
delete(AmberConnection aConn,
java.lang.Object key)
Deletes by the primary key.
|
EntityItem |
findItem(AmberConnection aConn,
java.sql.ResultSet rs,
int index)
Finds the object
|
java.lang.String |
generateAutoCreateSQL(AmberTable table)
Generates the auto insert sql.
|
void |
generateCopyLoadObject(JavaWriter out,
java.lang.String dst,
java.lang.String src,
int loadGroup)
Copy from an object.
|
void |
generateCopyUpdateObject(JavaWriter out,
java.lang.String dst,
java.lang.String src,
int updateIndex)
Copy from an object.
|
java.lang.String |
generateCreateSQL(AmberTable table)
Generates the insert sql.
|
void |
generateDumpRelationships(JavaWriter out,
int updateIndex)
Checks entity-relationships from an object.
|
java.lang.String |
generateFullLoadSelect(java.lang.String id)
Generates the select clause for a load.
|
java.lang.String |
generateIdSelect(java.lang.String id)
Generates the select clause for a load.
|
protected void |
generateInsertColumns(AmberTable table,
java.util.ArrayList<java.lang.String> columns) |
void |
generateInsertSet(JavaWriter out,
AmberTable table,
java.lang.String pstmt,
java.lang.String query,
java.lang.String obj)
Generates the update sql.
|
java.lang.String |
generateKeyLoadSelect(java.lang.String id)
Generates the select clause for a load.
|
int |
generateLoad(JavaWriter out,
java.lang.String rs,
java.lang.String indexVar,
int index)
Generates a string to load the field.
|
void |
generateLoadFromObject(JavaWriter out,
java.lang.String obj)
Loads from an object.
|
void |
generateLoadNative(JavaWriter out)
Generates the load code for native fields
|
java.lang.String |
generateLoadSelect(AmberTable table,
java.lang.String id)
Generates the select clause for a load.
|
java.lang.String |
generateLoadSelect(java.lang.String id)
Generates the select clause for a load.
|
void |
generateLoadSelect(java.lang.StringBuilder sb,
AmberTable table,
java.lang.String id,
int loadGroup)
Generates the select clause for a load.
|
void |
generateMergeFrom(JavaWriter out,
java.lang.String dst,
java.lang.String src)
Copy from an object.
|
void |
generateNativeColumnNames(java.util.ArrayList<java.lang.String> names)
Generates the load code for native fields
|
void |
generatePostDelete(JavaWriter out)
Generates code after the remove.
|
int |
generatePostLoadSelect(JavaWriter out,
int index,
int loadGroupIndex)
Generates loading code after the basic fields.
|
void |
generatePreDelete(JavaWriter out)
Generates code after the remove.
|
void |
generateSet(JavaWriter out,
java.lang.String pstmt,
java.lang.String index,
java.lang.String value)
Generates a string to set the field.
|
java.lang.String |
generateUpdateSQL(long mask)
Generates the update sql.
|
boolean |
generateUpdateSQLComponent(CharBuffer sql,
int group,
long mask,
boolean isFirst)
Generates the update sql.
|
void |
generateUpdateSQLPrefix(CharBuffer sql)
Generates the update sql.
|
void |
generateUpdateSQLSuffix(CharBuffer sql)
Generates the update sql.
|
long |
getCacheTimeout()
Returns the cache timeout.
|
java.util.ArrayList<AmberColumn> |
getColumns()
Returns the columns.
|
ClassComponent |
getComponentGenerator()
Gets a component generator.
|
java.lang.String |
getComponentInterfaceName()
Returns the component interface name.
|
int |
getDefaultLoadGroupIndex()
Returns the current load group.
|
int |
getDirtyIndex()
Returns the current dirty group.
|
java.lang.String |
getDiscriminatorValue()
Sets the discriminator value.
|
java.util.HashSet<java.lang.String> |
getEagerFieldNames()
Gets the EAGER field names.
|
boolean |
getExcludeDefaultListeners()
Gets the exclude default listeners flag.
|
boolean |
getExcludeSuperclassListeners()
Gets the exclude superclass listeners flag.
|
AmberField |
getField(java.lang.String name)
Returns the field with a given name.
|
java.util.ArrayList<AmberField> |
getFields()
returns the merged fields
|
int |
getFlushPriority()
Returns the flush priority.
|
java.lang.String |
getForeignTypeName()
Returns the java type.
|
IdGenerator |
getGenerator(java.lang.String name)
Sets the named generator.
|
boolean |
getHasLoadCallback()
True if the load lifecycle callback should be generated.
|
AmberEntityHome |
getHome()
Returns the home.
|
Id |
getId()
Returns the id.
|
java.lang.Class |
getInstanceClass()
Gets the instance class.
|
java.util.ArrayList<ListenerType> |
getListeners()
Gets the entity listeners.
|
int |
getLoadGroupIndex()
Returns the current load group.
|
java.lang.Object |
getLoadObject(AmberConnection aConn,
java.sql.ResultSet rs,
int index)
Gets the value.
|
AmberField |
getMappedSuperclassField(java.lang.String name)
Returns the mapped superclass field with a given name.
|
java.util.ArrayList<AmberField> |
getMappedSuperclassFields()
Returns the mapped superclass fields.
|
protected java.util.ArrayList<AmberField> |
getMergedFields() |
int |
getMinDirtyIndex()
Returns the min dirty group.
|
java.lang.Object |
getObject(AmberConnection aConn,
java.sql.ResultSet rs,
int index)
Gets the value.
|
EntityType |
getParentType()
Returns the parent type.
|
java.lang.Class |
getProxyClass()
Gets the proxy class.
|
java.lang.String |
getRootTableName()
Returns the root table name.
|
EntityType |
getRootType()
Returns the root type.
|
AmberTable |
getSecondaryTable(java.lang.String name)
Gets a secondary table.
|
java.util.ArrayList<AmberTable> |
getSecondaryTables()
Gets the secondary tables.
|
EntityType |
getSubClass(java.lang.String discriminator)
Gets a sub-class.
|
AmberTable |
getTable()
Returns the table.
|
VersionField |
getVersionField()
Returns the version field.
|
boolean |
hasDependent()
Returns true if and only if it has a
many-to-one, one-to-one or embedded field/property.
|
boolean |
hasLoadGroup(int loadGroupIndex)
Returns true if there's a field with the matching load group.
|
void |
init()
Initialize the entity.
|
protected void |
initId() |
boolean |
isAbstractClass()
Returns true if the corresponding class is abstract.
|
boolean |
isDirtyIndexOwnedByType(int i)
Returns true if the load group is owned by this type (not a subtype).
|
boolean |
isEJBProxy(java.lang.String typeName)
XXX: temp hack.
|
boolean |
isEntity()
returns true for a loadable entity
|
boolean |
isIdentityGenerator()
Returns true for sequence generator
|
boolean |
isJoinedSubClass()
Set true for joined-subclass
|
boolean |
isLoadGroupOwnedByType(int i)
Returns true if the load group is owned by this type (not a subtype).
|
boolean |
isReadOnly()
Returns true if read-only
|
boolean |
isSequenceGenerator()
Returns true for sequence generator
|
void |
nextDefaultLoadGroupIndex()
Sets the next default loadGroupIndex
|
int |
nextDirtyIndex()
Returns the next dirty index
|
long |
nextGeneratorId(AmberConnection aConn,
java.lang.String name)
Gets the named generator.
|
int |
nextLoadGroupIndex()
Returns the next load group.
|
void |
postLoad(Entity entity)
Callbacks after an entity is loaded
|
void |
postPersist(Entity entity)
Callbacks after an entity is persisted
|
void |
postRemove(Entity entity)
Callbacks after an entity is removeed
|
void |
postUpdate(Entity entity)
Callbacks after an entity is updated
|
void |
prePersist(Entity entity)
Callbacks before an entity is persisted
|
void |
preRemove(Entity entity)
Callbacks before an entity is removeed
|
void |
preUpdate(Entity entity)
Callbacks before an entity is updateed
|
void |
setCacheTimeout(long timeout)
Sets the cache timeout.
|
void |
setDiscriminatorValue(java.lang.String value)
Sets the discriminator value.
|
void |
setExcludeDefaultListeners(boolean b)
Sets the exclude default listeners flag.
|
void |
setExcludeSuperclassListeners(boolean b)
Sets the exclude superclass listeners flag.
|
void |
setGenerator(java.lang.String name,
IdGenerator gen)
Sets the named generator.
|
void |
setHasDependent(boolean hasDependent)
Sets true if and only if it has a
many-to-one, one-to-one or embedded field/property.
|
void |
setHasLoadCallback(boolean hasCallback)
True if the load lifecycle callback should be generated.
|
void |
setId(Id id)
Sets the id.
|
void |
setJoinedSubClass(boolean isJoinedSubClass)
Set true for joined-subclass
|
void |
setParentType(EntityType parentType)
Returns the parent type.
|
void |
setProxyClass(java.lang.Class proxyClass)
Gets the proxy class.
|
void |
setReadOnly(boolean isReadOnly)
Sets true if read-only
|
void |
setRootTableName(java.lang.String rootTableName)
Sets the root table name.
|
void |
setTable(AmberTable table)
Sets the table.
|
void |
setVersionField(VersionField versionField)
Sets the version field.
|
void |
start()
Start the entry.
|
void |
update(Entity entity)
Deletes by the primary key.
|
int |
updateFlushPriority(java.util.ArrayList<EntityType> updatingEntities)
Updates global (persistence unit) entity priorities
for flushing.
|
addCompletionField, addDependency, addDependency, containsCompletionField, generateCastFromObject, generateExpire, generateInvalidateForeign, generateLoad, generateLoadSelect, generatePrePersist, getCreateLoadMask, getDependencies, getDiscriminator, getField, getGetter, getGetter, getJavaTypeName, getSelfFields, getSetter, isEmbeddable, isFieldAccess, removeAllCompletionFields, setBeanClass, setDiscriminator, setFieldAccess, startConfigure
addCallback, addPostLoadCallback, addPostPersistCallback, addPostRemoveCallback, addPostUpdateCallback, addPrePersistCallback, addPreRemoveCallback, addPreUpdateCallback, addStubMethod, getBeanClass, getCallbacks, getClassName, getConfigException, getInstance, getInstanceClass, getInstanceClassName, getJavaBeanClass, getMethods, getName, getPersistenceUnit, getPostLoadCallbacks, getPostPersistCallbacks, getPostRemoveCallbacks, getPostUpdateCallbacks, getPrePersistCallbacks, getPreRemoveCallbacks, getPreUpdateCallbacks, isEnhanced, isGenerated, isIdClass, isInit, setConfigException, setEnhanced, setGenerated, setIdClass, setInstance, setInstanceClassLoader, setInstanceClassName, setName, toString
fromObject, generateCreateColumnSQL, generateEquals, generateIncrementVersion, generateIsNull, generateLoad, generateLoadForeign, generateLoadNative, generateNull, generateSetNull, generateSetVersion, getColumnCount, getForeignType, getObject, isAssignableTo, isAutoIncrement, isBoolean, isNumeric, setParameter, toObject, toObject
protected int _defaultLoadGroupIndex
protected int _loadGroupIndex
protected int _minDirtyIndex
protected int _dirtyIndex
protected boolean _hasLoadCallback
public EntityType(AmberPersistenceUnit amberPersistenceUnit)
public boolean isEntity()
isEntity
in class AmberBeanType
public void setTable(AmberTable table)
public AmberTable getTable()
public java.lang.Class getInstanceClass()
getInstanceClass
in class AbstractEnhancedType
public java.lang.String getComponentInterfaceName()
getComponentInterfaceName
in class AbstractEnhancedType
public ClassComponent getComponentGenerator()
getComponentGenerator
in class AbstractEnhancedType
public int getFlushPriority()
public void addMappedSuperclassField(AmberField field)
public java.util.ArrayList<AmberField> getMappedSuperclassFields()
public AmberField getMappedSuperclassField(java.lang.String name)
public java.util.ArrayList<AmberField> getFields()
getFields
in class AmberBeanType
public java.lang.String getRootTableName()
public void setRootTableName(java.lang.String rootTableName)
public VersionField getVersionField()
public void setVersionField(VersionField versionField)
public void addSecondaryTable(AmberTable table)
public java.util.ArrayList<AmberTable> getSecondaryTables()
public void addListener(ListenerType listener)
public java.util.ArrayList<ListenerType> getListeners()
public AmberTable getSecondaryTable(java.lang.String name)
public boolean hasDependent()
public void setHasDependent(boolean hasDependent)
public java.lang.String getForeignTypeName()
getForeignTypeName
in class AmberType
public java.lang.Class getProxyClass()
public void setProxyClass(java.lang.Class proxyClass)
public boolean isAbstractClass()
public void setId(Id id)
public Id getId()
public void setJoinedSubClass(boolean isJoinedSubClass)
public boolean isJoinedSubClass()
public java.lang.String getDiscriminatorValue()
public void setDiscriminatorValue(java.lang.String value)
public boolean isReadOnly()
public void setReadOnly(boolean isReadOnly)
public long getCacheTimeout()
public void setCacheTimeout(long timeout)
public void addField(AmberField field)
addField
in class AmberBeanType
public java.util.HashSet<java.lang.String> getEagerFieldNames()
public AmberField getField(java.lang.String name)
getField
in class AmberBeanType
public java.util.ArrayList<AmberColumn> getColumns()
public boolean getExcludeDefaultListeners()
public void setExcludeDefaultListeners(boolean b)
public boolean getExcludeSuperclassListeners()
public void setExcludeSuperclassListeners(boolean b)
public void setHasLoadCallback(boolean hasCallback)
public boolean getHasLoadCallback()
public EntityType getRootType()
public EntityType getParentType()
public void setParentType(EntityType parentType)
public void addSubClass(EntityType type)
public EntityType getSubClass(java.lang.String discriminator)
public Entity createBean()
public AmberEntityHome getHome()
public int nextLoadGroupIndex()
public int getLoadGroupIndex()
public void nextDefaultLoadGroupIndex()
public int getDefaultLoadGroupIndex()
public boolean isLoadGroupOwnedByType(int i)
public int nextDirtyIndex()
public int getDirtyIndex()
public int getMinDirtyIndex()
public boolean isDirtyIndexOwnedByType(int i)
public void init() throws ConfigException
init
in class AmberBeanType
ConfigException
protected void initId()
protected java.util.ArrayList<AmberField> getMergedFields()
public void start() throws ConfigException
ConfigException
public int generateLoad(JavaWriter out, java.lang.String rs, java.lang.String indexVar, int index) throws java.io.IOException
generateLoad
in class AmberType
java.io.IOException
public boolean hasLoadGroup(int loadGroupIndex)
public int generatePostLoadSelect(JavaWriter out, int index, int loadGroupIndex) throws java.io.IOException
java.io.IOException
public void generateLoadNative(JavaWriter out) throws java.io.IOException
java.io.IOException
public void generateNativeColumnNames(java.util.ArrayList<java.lang.String> names) throws java.io.IOException
java.io.IOException
public void generateSet(JavaWriter out, java.lang.String pstmt, java.lang.String index, java.lang.String value) throws java.io.IOException
generateSet
in class AmberType
java.io.IOException
public java.lang.Object getObject(AmberConnection aConn, java.sql.ResultSet rs, int index) throws java.sql.SQLException
public EntityItem findItem(AmberConnection aConn, java.sql.ResultSet rs, int index) throws java.sql.SQLException
public java.lang.Object getLoadObject(AmberConnection aConn, java.sql.ResultSet rs, int index) throws java.sql.SQLException
java.sql.SQLException
public boolean isSequenceGenerator()
public boolean isIdentityGenerator()
public void setGenerator(java.lang.String name, IdGenerator gen)
public IdGenerator getGenerator(java.lang.String name)
public long nextGeneratorId(AmberConnection aConn, java.lang.String name) throws java.sql.SQLException
java.sql.SQLException
public void generateLoadFromObject(JavaWriter out, java.lang.String obj) throws java.io.IOException
java.io.IOException
public void generateCopyLoadObject(JavaWriter out, java.lang.String dst, java.lang.String src, int loadGroup) throws java.io.IOException
java.io.IOException
public void generateMergeFrom(JavaWriter out, java.lang.String dst, java.lang.String src) throws java.io.IOException
java.io.IOException
public void generateCopyUpdateObject(JavaWriter out, java.lang.String dst, java.lang.String src, int updateIndex) throws java.io.IOException
java.io.IOException
public void generateDumpRelationships(JavaWriter out, int updateIndex) throws java.io.IOException
java.io.IOException
public java.lang.String generateKeyLoadSelect(java.lang.String id)
public java.lang.String generateFullLoadSelect(java.lang.String id)
public java.lang.String generateLoadSelect(java.lang.String id)
public java.lang.String generateLoadSelect(AmberTable table, java.lang.String id)
generateLoadSelect
in class AmberBeanType
public void generateLoadSelect(java.lang.StringBuilder sb, AmberTable table, java.lang.String id, int loadGroup)
generateLoadSelect
in class AmberBeanType
public java.lang.String generateAutoCreateSQL(AmberTable table)
public java.lang.String generateCreateSQL(AmberTable table)
protected void generateInsertColumns(AmberTable table, java.util.ArrayList<java.lang.String> columns)
public void generateInsertSet(JavaWriter out, AmberTable table, java.lang.String pstmt, java.lang.String query, java.lang.String obj) throws java.io.IOException
java.io.IOException
public java.lang.String generateIdSelect(java.lang.String id)
public void generateUpdateSQLPrefix(CharBuffer sql)
public boolean generateUpdateSQLComponent(CharBuffer sql, int group, long mask, boolean isFirst)
sql
- the partially built sqlgroup
- the dirty groupmask
- the group's maskisFirst
- marks the first set grouppublic void generateUpdateSQLSuffix(CharBuffer sql)
public java.lang.String generateUpdateSQL(long mask)
public void generatePreDelete(JavaWriter out) throws java.io.IOException
java.io.IOException
public void generatePostDelete(JavaWriter out) throws java.io.IOException
java.io.IOException
public void delete(AmberConnection aConn, java.lang.Object key) throws java.sql.SQLException
java.sql.SQLException
public void update(Entity entity) throws java.sql.SQLException
java.sql.SQLException
public int updateFlushPriority(java.util.ArrayList<EntityType> updatingEntities)
public AmberCompletion createManyToOneCompletion(java.lang.String name, Entity source, java.lang.Object newTarget)
public boolean isEJBProxy(java.lang.String typeName)
public void prePersist(Entity entity)
public void postPersist(Entity entity)
public void preUpdate(Entity entity)
public void postUpdate(Entity entity)
public void preRemove(Entity entity)
public void postRemove(Entity entity)
public void postLoad(Entity entity)