com.caucho.amber.field
Class EmbeddedSubField

java.lang.Object
  extended by com.caucho.amber.field.EmbeddedSubField
All Implemented Interfaces:
AmberField
Direct Known Subclasses:
KeyEmbeddedSubField

public class EmbeddedSubField
extends java.lang.Object
implements AmberField

Represents the sub-field of an embedded type.


Field Summary
protected static java.util.logging.Logger log
           
 
Constructor Summary
EmbeddedSubField(EntityEmbeddedField embeddedField, AmberField embeddableField, int index)
           
 
Method Summary
 void childDelete(AmberConnection aConn, java.io.Serializable primaryKey)
          Deletes the children
 AmberExpr createExpr(QueryParser parser, PathExpr parent)
          Creates the expression for the field.
 java.lang.String generateCastFromObject(java.lang.String value)
          Generates code to convert to the type from the object.
 void generateCopyLoadObject(JavaWriter out, java.lang.String dst, java.lang.String src, int loadIndex)
          Updates the cached copy.
 void generateCopyUpdateObject(JavaWriter out, java.lang.String dst, java.lang.String src, int updateIndex)
          Updates the cached copy.
 java.lang.String generateCreateTableSQL(AmberPersistenceUnit manager)
          Generates the table create.
 void generateDetach(JavaWriter out)
          Generates any code needed for detachment
 void generateDumpRelationships(JavaWriter out, int updateIndex)
          Checks entity-relationships from an object.
 java.lang.String generateEquals(java.lang.String leftBase, java.lang.String value)
          Generates code to test the equals.
 void generateExpire(JavaWriter out)
          Generates the expire code.
 void generateGet(JavaWriter out, java.lang.String value)
          Generates the field getter.
 java.lang.String generateGet(java.lang.String objThis)
          Generates the field getter.
 void generateGetterMethod(JavaWriter out)
          Generates the get property.
 void generateInsertColumns(java.util.ArrayList<java.lang.String> columns)
          Generates the insert.
 void generateInsertSet(JavaWriter out, java.lang.String pstmt, java.lang.String index, java.lang.String obj)
          Generates the set clause for the insert clause.
 void generateInvalidateForeign(JavaWriter out)
          Generates code for foreign entity create/delete
 java.lang.String generateJavaSelect(java.lang.String id)
          Generates the JPA QL select clause.
 int generateLoad(JavaWriter out, java.lang.String rs, java.lang.String indexVar, int loadGroupIndex)
          Generates loading code
 void generateLoadFromObject(JavaWriter out, java.lang.String obj)
          Generates loading cache
 int generateLoadNative(JavaWriter out, int index)
          Generates loading for a native query
 java.lang.String generateLoadSelect(AmberTable table, java.lang.String id)
          Generates the select clause for an entity load.
 void generateMergeFrom(JavaWriter out, java.lang.String dst, java.lang.String src)
          Updates the cached copy.
 void generateNativeColumnNames(java.util.ArrayList<java.lang.String> names)
          Generates loading for a native query
 void generatePostConstructor(JavaWriter out)
          Generates the post constructor fixup
 void generatePostDelete(JavaWriter out)
          Generates the delete foreign
 int generatePostLoadSelect(JavaWriter out, int index)
          Generates loading code after the basic fields.
 void generatePreDelete(JavaWriter out)
          Generates the delete foreign
 void generatePrePersist(JavaWriter out)
          Generates any code needed before a persist occurs
 void generatePrologue(JavaWriter out, java.util.HashSet<java.lang.Object> completedSet)
          Generates any prologue.
 java.lang.String generateSelect(java.lang.String id)
          Generates the select clause.
 void generateSet(JavaWriter out, java.lang.String objThis, java.lang.String value)
          Generates loading cache
 java.lang.String generateSet(java.lang.String obj, java.lang.String value)
          Generates the field setter.
 void generateSetterMethod(JavaWriter out)
          Generates the set property.
 void generateStatementSet(JavaWriter out, java.lang.String pstmt, java.lang.String index)
          Generates the JDBC preparedStatement set clause.
 void generateStatementSet(JavaWriter out, java.lang.String pstmt, java.lang.String index, java.lang.String obj)
          Generates the set clause.
 java.lang.String generateSuperGetter(java.lang.String objThis)
          Returns the actual data.
 void generateSuperGetterMethod(JavaWriter out)
          Generates the get property.
 java.lang.String generateSuperSetter(java.lang.String objThis, java.lang.String value)
          Sets the actual data.
 void generateSuperSetterMethod(JavaWriter out)
          Generates the get property.
 void generateUpdate(CharBuffer sql)
          Generates the where clause.
 void generateUpdate(JavaWriter out, java.lang.String mask, java.lang.String pstmt, java.lang.String index)
          Generates loading cache
 void generateUpdateFromObject(JavaWriter out, java.lang.String obj)
          Generates loading cache
 void generateUpdateSet(JavaWriter out, java.lang.String pstmt, java.lang.String index, java.lang.String obj)
          Generates the set clause for the insert clause.
 java.lang.String generateWhere(java.lang.String id)
          Generates the where clause.
 AmberColumn getColumn()
          Returns the column for the field.
 long getCreateLoadMask(int group)
          Returns the load group mask.
 java.lang.reflect.Method getGetterMethod()
          Returns the getter method.
 java.lang.String getGetterName()
          Returns the getter name.
 int getIndex()
          Returns the property index.
 java.lang.Class getJavaClass()
          Returns the type of the field
 JType getJavaType()
          Returns the type of the field
 java.lang.String getJavaTypeName()
          Returns the name of the java type.
 int getLoadGroupIndex()
          Returns the property's group index.
 java.lang.String getName()
          Returns the field name.
 java.lang.reflect.Method getSetterMethod()
          Returns the setter method.
 java.lang.String getSetterName()
          Returns the setter name.
 AmberBeanType getSourceType()
          Returns the owning entity class.
 AmberTable getTable()
          Returns the table containing the value (or null)
 boolean hasLoadGroup(int index)
          Generates loading code
 void init()
          Links to the target.
 boolean isAbstract()
          Returns true if the methods are abstract.
 boolean isCascadable()
          Returns true if the field is cascadable.
 boolean isLazy()
          Returns true if and only if this is a LAZY field.
 boolean isUpdateable()
          Returns true for an updateable field.
 void link()
          Links to the target.
 AmberField override(AmberBeanType entityType)
          Override the field
 void setIndex(int index)
          Links to the target.
 java.lang.String toObject(java.lang.String value)
          Converts to an object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final java.util.logging.Logger log
Constructor Detail

EmbeddedSubField

public EmbeddedSubField(EntityEmbeddedField embeddedField,
                        AmberField embeddableField,
                        int index)
                 throws ConfigException
Throws:
ConfigException
Method Detail

getSourceType

public AmberBeanType getSourceType()
Returns the owning entity class.

Specified by:
getSourceType in interface AmberField

isLazy

public boolean isLazy()
Returns true if and only if this is a LAZY field.

Specified by:
isLazy in interface AmberField

getName

public java.lang.String getName()
Returns the field name.

Specified by:
getName in interface AmberField

getTable

public AmberTable getTable()
Returns the table containing the value (or null)

Specified by:
getTable in interface AmberField

getColumn

public AmberColumn getColumn()
Description copied from interface: AmberField
Returns the column for the field.

Specified by:
getColumn in interface AmberField

getIndex

public int getIndex()
Returns the property index.

Specified by:
getIndex in interface AmberField

getLoadGroupIndex

public int getLoadGroupIndex()
Returns the property's group index.

Specified by:
getLoadGroupIndex in interface AmberField

getCreateLoadMask

public long getCreateLoadMask(int group)
Returns the load group mask.

Specified by:
getCreateLoadMask in interface AmberField

getJavaType

public JType getJavaType()
Returns the type of the field

Specified by:
getJavaType in interface AmberField

getJavaClass

public java.lang.Class getJavaClass()
Returns the type of the field

Specified by:
getJavaClass in interface AmberField

getJavaTypeName

public java.lang.String getJavaTypeName()
Returns the name of the java type.

Specified by:
getJavaTypeName in interface AmberField

isAbstract

public boolean isAbstract()
Returns true if the methods are abstract.

Specified by:
isAbstract in interface AmberField

isCascadable

public boolean isCascadable()
Returns true if the field is cascadable.

Specified by:
isCascadable in interface AmberField

isUpdateable

public boolean isUpdateable()
Returns true for an updateable field.

Specified by:
isUpdateable in interface AmberField

setIndex

public void setIndex(int index)
Links to the target.

Specified by:
setIndex in interface AmberField

getGetterMethod

public java.lang.reflect.Method getGetterMethod()
Returns the getter method.

Specified by:
getGetterMethod in interface AmberField

getGetterName

public java.lang.String getGetterName()
Returns the getter name.

Specified by:
getGetterName in interface AmberField

getSetterMethod

public java.lang.reflect.Method getSetterMethod()
Returns the setter method.

Specified by:
getSetterMethod in interface AmberField

getSetterName

public java.lang.String getSetterName()
Returns the setter name.

Specified by:
getSetterName in interface AmberField

generateSuperGetter

public java.lang.String generateSuperGetter(java.lang.String objThis)
Returns the actual data.

Specified by:
generateSuperGetter in interface AmberField

generateSuperSetter

public java.lang.String generateSuperSetter(java.lang.String objThis,
                                            java.lang.String value)
Sets the actual data.

Specified by:
generateSuperSetter in interface AmberField

generateSet

public void generateSet(JavaWriter out,
                        java.lang.String objThis,
                        java.lang.String value)
                 throws java.io.IOException
Generates loading cache

Specified by:
generateSet in interface AmberField
Throws:
java.io.IOException

init

public void init()
          throws ConfigException
Links to the target.

Specified by:
init in interface AmberField
Throws:
ConfigException

generatePrologue

public void generatePrologue(JavaWriter out,
                             java.util.HashSet<java.lang.Object> completedSet)
                      throws java.io.IOException
Generates any prologue.

Specified by:
generatePrologue in interface AmberField
Throws:
java.io.IOException

generatePostConstructor

public void generatePostConstructor(JavaWriter out)
                             throws java.io.IOException
Generates the post constructor fixup

Specified by:
generatePostConstructor in interface AmberField
Throws:
java.io.IOException

generateUpdate

public void generateUpdate(JavaWriter out,
                           java.lang.String mask,
                           java.lang.String pstmt,
                           java.lang.String index)
                    throws java.io.IOException
Generates loading cache

Specified by:
generateUpdate in interface AmberField
Throws:
java.io.IOException

hasLoadGroup

public boolean hasLoadGroup(int index)
Generates loading code

Specified by:
hasLoadGroup in interface AmberField

generateLoad

public int generateLoad(JavaWriter out,
                        java.lang.String rs,
                        java.lang.String indexVar,
                        int loadGroupIndex)
                 throws java.io.IOException
Generates loading code

Specified by:
generateLoad in interface AmberField
Throws:
java.io.IOException

generatePostLoadSelect

public int generatePostLoadSelect(JavaWriter out,
                                  int index)
                           throws java.io.IOException
Generates loading code after the basic fields.

Specified by:
generatePostLoadSelect in interface AmberField
Throws:
java.io.IOException

generateLoadNative

public int generateLoadNative(JavaWriter out,
                              int index)
                       throws java.io.IOException
Generates loading for a native query

Specified by:
generateLoadNative in interface AmberField
Throws:
java.io.IOException

generateNativeColumnNames

public void generateNativeColumnNames(java.util.ArrayList<java.lang.String> names)
Generates loading for a native query

Specified by:
generateNativeColumnNames in interface AmberField

generateLoadFromObject

public void generateLoadFromObject(JavaWriter out,
                                   java.lang.String obj)
                            throws java.io.IOException
Generates loading cache

Specified by:
generateLoadFromObject in interface AmberField
Throws:
java.io.IOException

generateUpdateFromObject

public void generateUpdateFromObject(JavaWriter out,
                                     java.lang.String obj)
                              throws java.io.IOException
Generates loading cache

Specified by:
generateUpdateFromObject in interface AmberField
Throws:
java.io.IOException

generateGet

public void generateGet(JavaWriter out,
                        java.lang.String value)
                 throws java.io.IOException
Generates the field getter.

Specified by:
generateGet in interface AmberField
Parameters:
value - the non-null value
Throws:
java.io.IOException

generateGet

public java.lang.String generateGet(java.lang.String objThis)
Generates the field getter.

Specified by:
generateGet in interface AmberField
Parameters:
value - the non-null value

generateSet

public java.lang.String generateSet(java.lang.String obj,
                                    java.lang.String value)
Generates the field setter.

Specified by:
generateSet in interface AmberField
Parameters:
value - the non-null value

generateGetterMethod

public void generateGetterMethod(JavaWriter out)
                          throws java.io.IOException
Generates the get property.

Specified by:
generateGetterMethod in interface AmberField
Throws:
java.io.IOException

generateSetterMethod

public void generateSetterMethod(JavaWriter out)
                          throws java.io.IOException
Generates the set property.

Specified by:
generateSetterMethod in interface AmberField
Throws:
java.io.IOException

generateSuperGetterMethod

public void generateSuperGetterMethod(JavaWriter out)
                               throws java.io.IOException
Generates the get property.

Specified by:
generateSuperGetterMethod in interface AmberField
Throws:
java.io.IOException

generateSuperSetterMethod

public void generateSuperSetterMethod(JavaWriter out)
                               throws java.io.IOException
Generates the get property.

Specified by:
generateSuperSetterMethod in interface AmberField
Throws:
java.io.IOException

override

public AmberField override(AmberBeanType entityType)
Override the field

Specified by:
override in interface AmberField

generateCreateTableSQL

public java.lang.String generateCreateTableSQL(AmberPersistenceUnit manager)
Generates the table create.

Specified by:
generateCreateTableSQL in interface AmberField

generateStatementSet

public void generateStatementSet(JavaWriter out,
                                 java.lang.String pstmt,
                                 java.lang.String index)
                          throws java.io.IOException
Generates the JDBC preparedStatement set clause.

Specified by:
generateStatementSet in interface AmberField
Throws:
java.io.IOException

generateInsertSet

public void generateInsertSet(JavaWriter out,
                              java.lang.String pstmt,
                              java.lang.String index,
                              java.lang.String obj)
                       throws java.io.IOException
Generates the set clause for the insert clause.

Specified by:
generateInsertSet in interface AmberField
Throws:
java.io.IOException

generateUpdateSet

public void generateUpdateSet(JavaWriter out,
                              java.lang.String pstmt,
                              java.lang.String index,
                              java.lang.String obj)
                       throws java.io.IOException
Generates the set clause for the insert clause.

Specified by:
generateUpdateSet in interface AmberField
Throws:
java.io.IOException

generateCopyUpdateObject

public void generateCopyUpdateObject(JavaWriter out,
                                     java.lang.String dst,
                                     java.lang.String src,
                                     int updateIndex)
                              throws java.io.IOException
Updates the cached copy.

Specified by:
generateCopyUpdateObject in interface AmberField
Throws:
java.io.IOException

generateCopyLoadObject

public void generateCopyLoadObject(JavaWriter out,
                                   java.lang.String dst,
                                   java.lang.String src,
                                   int loadIndex)
                            throws java.io.IOException
Updates the cached copy.

Specified by:
generateCopyLoadObject in interface AmberField
Throws:
java.io.IOException

generateMergeFrom

public void generateMergeFrom(JavaWriter out,
                              java.lang.String dst,
                              java.lang.String src)
                       throws java.io.IOException
Updates the cached copy.

Specified by:
generateMergeFrom in interface AmberField
Throws:
java.io.IOException

generateDumpRelationships

public void generateDumpRelationships(JavaWriter out,
                                      int updateIndex)
                               throws java.io.IOException
Checks entity-relationships from an object.

Specified by:
generateDumpRelationships in interface AmberField
Throws:
java.io.IOException

generateStatementSet

public void generateStatementSet(JavaWriter out,
                                 java.lang.String pstmt,
                                 java.lang.String index,
                                 java.lang.String obj)
                          throws java.io.IOException
Generates the set clause.

Specified by:
generateStatementSet in interface AmberField
Throws:
java.io.IOException

toObject

public java.lang.String toObject(java.lang.String value)
Converts to an object.

Specified by:
toObject in interface AmberField

link

public void link()
Links to the target.

Specified by:
link in interface AmberField

generatePreDelete

public void generatePreDelete(JavaWriter out)
                       throws java.io.IOException
Generates the delete foreign

Specified by:
generatePreDelete in interface AmberField
Throws:
java.io.IOException

generatePostDelete

public void generatePostDelete(JavaWriter out)
                        throws java.io.IOException
Generates the delete foreign

Specified by:
generatePostDelete in interface AmberField
Throws:
java.io.IOException

generateExpire

public void generateExpire(JavaWriter out)
                    throws java.io.IOException
Generates the expire code.

Specified by:
generateExpire in interface AmberField
Throws:
java.io.IOException

generateInvalidateForeign

public void generateInvalidateForeign(JavaWriter out)
                               throws java.io.IOException
Generates code for foreign entity create/delete

Specified by:
generateInvalidateForeign in interface AmberField
Throws:
java.io.IOException

childDelete

public void childDelete(AmberConnection aConn,
                        java.io.Serializable primaryKey)
                 throws java.sql.SQLException
Deletes the children

Specified by:
childDelete in interface AmberField
Throws:
java.sql.SQLException

generateCastFromObject

public java.lang.String generateCastFromObject(java.lang.String value)
Generates code to convert to the type from the object.

Specified by:
generateCastFromObject in interface AmberField

generateEquals

public java.lang.String generateEquals(java.lang.String leftBase,
                                       java.lang.String value)
Generates code to test the equals.

Specified by:
generateEquals in interface AmberField

generateLoadSelect

public java.lang.String generateLoadSelect(AmberTable table,
                                           java.lang.String id)
Generates the select clause for an entity load.

Specified by:
generateLoadSelect in interface AmberField

generateSelect

public java.lang.String generateSelect(java.lang.String id)
Generates the select clause.

Specified by:
generateSelect in interface AmberField

generateInsertColumns

public void generateInsertColumns(java.util.ArrayList<java.lang.String> columns)
Generates the insert.

Specified by:
generateInsertColumns in interface AmberField

generateJavaSelect

public java.lang.String generateJavaSelect(java.lang.String id)
Generates the JPA QL select clause.

Specified by:
generateJavaSelect in interface AmberField

generateWhere

public java.lang.String generateWhere(java.lang.String id)
Generates the where clause.

Specified by:
generateWhere in interface AmberField

generateUpdate

public void generateUpdate(CharBuffer sql)
Generates the where clause.

Specified by:
generateUpdate in interface AmberField

generatePrePersist

public void generatePrePersist(JavaWriter out)
                        throws java.io.IOException
Generates any code needed before a persist occurs

Specified by:
generatePrePersist in interface AmberField
Throws:
java.io.IOException

generateDetach

public void generateDetach(JavaWriter out)
                    throws java.io.IOException
Generates any code needed for detachment

Specified by:
generateDetach in interface AmberField
Throws:
java.io.IOException

createExpr

public AmberExpr createExpr(QueryParser parser,
                            PathExpr parent)
Creates the expression for the field.

Specified by:
createExpr in interface AmberField