com.caucho.amber.field
Class ManyToOneField

java.lang.Object
  extended by com.caucho.amber.field.AbstractField
      extended by com.caucho.amber.field.CascadableField
          extended by com.caucho.amber.field.ManyToOneField
All Implemented Interfaces:
AmberField
Direct Known Subclasses:
KeyManyToOneField

public class ManyToOneField
extends CascadableField

Represents a many-to-one link pointing to an entity.


Constructor Summary
ManyToOneField(EntityType relatedType)
           
ManyToOneField(EntityType relatedType, java.lang.String name)
           
ManyToOneField(EntityType relatedType, java.lang.String name, CascadeType[] cascadeType)
           
ManyToOneField(EntityType relatedType, java.lang.String name, CascadeType[] cascadeType, boolean isManyToOne)
           
 
Method Summary
 AmberExpr createExpr(QueryParser parser, PathExpr parent)
          Creates the expression for the field.
 void generateCopyLoadObject(JavaWriter out, java.lang.String dst, java.lang.String src, int updateIndex)
          Updates the cached copy.
 void generateCopyUpdateObject(JavaWriter out, java.lang.String dst, java.lang.String src, int updateIndex)
          Updates the cached copy.
 void generateGetterMethod(JavaWriter out)
          Generates the get property.
 void generateInsertColumns(java.util.ArrayList<java.lang.String> columns)
          Generates the insert.
 void generateInvalidateForeign(JavaWriter out)
          Generates code for foreign entity create/delete
 void generateJoin(CharBuffer cb, java.lang.String sourceTable, java.lang.String targetTable)
          Generates the linking for a join
 int generateLoad(JavaWriter out, java.lang.String rs, java.lang.String indexVar, int index)
          Generates loading code
 java.lang.String generateLoadProperty(JavaWriter out, java.lang.String index, java.lang.String session)
          Generates the set property.
 java.lang.String generateLoadSelect(AmberTable table, java.lang.String id)
          Generates the select clause.
 void generateMergeFrom(JavaWriter out, java.lang.String dst, java.lang.String src)
          Updates the cached copy.
 void generatePostConstructor(JavaWriter out)
          Generates the post constructor initialization.
 void generatePostDelete(JavaWriter out)
          Generates any pre-delete code
 int generatePostLoadSelect(JavaWriter out, int index)
          Generates loading code after the basic fields.
 void generatePreDelete(JavaWriter out)
          Generates any pre-delete code
 void generatePrePersist(JavaWriter out)
          Updates the cached copy.
 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 generateSetterMethod(JavaWriter out)
          Generates the set property.
 void generateStatementSet(JavaWriter out, java.lang.String pstmt, java.lang.String index, java.lang.String source)
          Generates the set clause.
 void generateUpdate(CharBuffer sql)
          Generates the update set clause
 void generateUpdateFromObject(JavaWriter out, java.lang.String obj)
          Generates loading cache
 ForeignColumn getColumn(AmberColumn targetColumn)
          Gets the column corresponding to the target field.
 EntityType getEntityTargetType()
          Returns the target type as entity or mapped-superclass.
 java.lang.String getForeignTypeName()
          Returns the foreign type.
 java.util.HashMap<java.lang.String,JoinColumnConfig> getJoinColumnMap()
          Gets the join column map.
 java.lang.Object[] getJoinColumns()
          Gets the join column annotations.
 LinkColumns getLinkColumns()
          Gets the columns.
 EntityType getRelatedType()
          Returns the source type as entity or mapped-superclass.
 void init()
          Initializes the field.
 void init(EntityType relatedType)
          Initializes the field.
 boolean isAnnotatedManyToOne()
          Returns true if it is annotated as many-to-one.
 boolean isSourceCascadeDelete()
          Set true if deletes cascade to the source.
 boolean isTargetCascadeDelete()
          Set true if deletes cascade to the target.
 AmberField override(AmberBeanType type)
          Creates a copy of the field for a parent
 void setAliasField(AmberField alias)
          Sets any alias field.
 void setJoinColumnMap(java.util.HashMap<java.lang.String,JoinColumnConfig> joinColumnMap)
          Sets the join column map.
 void setJoinColumns(JoinColumn[] joinColumnsAnn)
          Sets the join column annotations.
 void setLinkColumns(LinkColumns linkColumns)
          Sets the join columns.
 void setSourceCascadeDelete(boolean isCascadeDelete)
          Set true if deletes cascade to the source.
 void setTargetCascadeDelete(boolean isCascadeDelete)
          Set true if deletes cascade to the target.
 void setTargetField(DependentEntityOneToOneField field)
          Sets the target field.
 void setType(AmberType targetType)
          Sets the target type.
 
Methods inherited from class com.caucho.amber.field.CascadableField
generateFlushCheck, generateInternalCascade, generatePostCascade, generatePreCascade, getCascadeType, isCascadable, isCascade, setCascadeType
 
Methods inherited from class com.caucho.amber.field.AbstractField
childDelete, generateCastFromObject, generateCreateTableSQL, generateDetach, generateDumpRelationships, generateEquals, generateExpire, generateGet, generateGet, generateInsert, generateInsertSet, generateJavaSelect, generateLoadFromObject, generateLoadNative, generateNativeColumnNames, generateNull, generateSet, generateSet, generateStatementSet, generateSuperGetter, generateSuperGetterMethod, generateSuperSetter, generateSuperSetterMethod, generateUpdate, generateUpdateSet, generateWhere, getBeanClass, getColumn, getCreateLoadMask, getEntitySourceType, getFieldName, getGetterMethod, getGetterName, getIndex, getJavaClass, getJavaType, getJavaTypeName, getLoadGroupIndex, getName, getPersistenceUnit, getSetterMethod, getSetterName, getSourceType, getTable, hasLoadGroup, isAbstract, isFieldAccess, isKey, isLazy, isOverride, isUpdateable, link, setColumn, setIndex, setJavaType, setLazy, setLoadGroupIndex, setName, setOverride, toObject, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ManyToOneField

public ManyToOneField(EntityType relatedType,
                      java.lang.String name,
                      CascadeType[] cascadeType,
                      boolean isManyToOne)
               throws ConfigException
Throws:
ConfigException

ManyToOneField

public ManyToOneField(EntityType relatedType,
                      java.lang.String name,
                      CascadeType[] cascadeType)
               throws ConfigException
Throws:
ConfigException

ManyToOneField

public ManyToOneField(EntityType relatedType,
                      java.lang.String name)
               throws ConfigException
Throws:
ConfigException

ManyToOneField

public ManyToOneField(EntityType relatedType)
Method Detail

setType

public void setType(AmberType targetType)
Sets the target type.


getRelatedType

public EntityType getRelatedType()
Returns the source type as entity or mapped-superclass.


getEntityTargetType

public EntityType getEntityTargetType()
Returns the target type as entity or mapped-superclass.


getForeignTypeName

public java.lang.String getForeignTypeName()
Returns the foreign type.


isAnnotatedManyToOne

public boolean isAnnotatedManyToOne()
Returns true if it is annotated as many-to-one.


setTargetCascadeDelete

public void setTargetCascadeDelete(boolean isCascadeDelete)
Set true if deletes cascade to the target.


setSourceCascadeDelete

public void setSourceCascadeDelete(boolean isCascadeDelete)
Set true if deletes cascade to the source.


isTargetCascadeDelete

public boolean isTargetCascadeDelete()
Set true if deletes cascade to the target.


isSourceCascadeDelete

public boolean isSourceCascadeDelete()
Set true if deletes cascade to the source.


setJoinColumns

public void setJoinColumns(JoinColumn[] joinColumnsAnn)
Sets the join column annotations.


getJoinColumns

public java.lang.Object[] getJoinColumns()
Gets the join column annotations.


setJoinColumnMap

public void setJoinColumnMap(java.util.HashMap<java.lang.String,JoinColumnConfig> joinColumnMap)
Sets the join column map.


getJoinColumnMap

public java.util.HashMap<java.lang.String,JoinColumnConfig> getJoinColumnMap()
Gets the join column map.


setLinkColumns

public void setLinkColumns(LinkColumns linkColumns)
Sets the join columns.


getLinkColumns

public LinkColumns getLinkColumns()
Gets the columns.


setTargetField

public void setTargetField(DependentEntityOneToOneField field)
Sets the target field.


setAliasField

public void setAliasField(AmberField alias)
Sets any alias field.


override

public AmberField override(AmberBeanType type)
Creates a copy of the field for a parent

Specified by:
override in interface AmberField
Overrides:
override in class AbstractField

init

public void init()
          throws ConfigException
Initializes the field.

Specified by:
init in interface AmberField
Overrides:
init in class AbstractField
Throws:
ConfigException

init

public void init(EntityType relatedType)
          throws ConfigException
Initializes the field.

Throws:
ConfigException

generatePostConstructor

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

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

createExpr

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

Specified by:
createExpr in interface AmberField
Overrides:
createExpr in class AbstractField

getColumn

public ForeignColumn getColumn(AmberColumn targetColumn)
Gets the column corresponding to the target field.


generateInsertColumns

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

Specified by:
generateInsertColumns in interface AmberField
Overrides:
generateInsertColumns in class AbstractField

generateLoadSelect

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

Specified by:
generateLoadSelect in interface AmberField
Overrides:
generateLoadSelect in class AbstractField

generateSelect

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

Specified by:
generateSelect in interface AmberField
Overrides:
generateSelect in class AbstractField

generateUpdate

public void generateUpdate(CharBuffer sql)
Generates the update set clause

Specified by:
generateUpdate in interface AmberField
Overrides:
generateUpdate in class AbstractField

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
Overrides:
generatePrologue in class AbstractField
Throws:
java.io.IOException

generateJoin

public void generateJoin(CharBuffer cb,
                         java.lang.String sourceTable,
                         java.lang.String targetTable)
Generates the linking for a join


generateLoad

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

Specified by:
generateLoad in interface AmberField
Overrides:
generateLoad in class AbstractField
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
Overrides:
generatePostLoadSelect in class AbstractField
Throws:
java.io.IOException

generateGetterMethod

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

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

generateLoadProperty

public java.lang.String generateLoadProperty(JavaWriter out,
                                             java.lang.String index,
                                             java.lang.String session)
                                      throws java.io.IOException
Generates the set property.

Throws:
java.io.IOException

generateSetterMethod

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

Specified by:
generateSetterMethod in interface AmberField
Overrides:
generateSetterMethod in class AbstractField
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
Overrides:
generateCopyUpdateObject in class AbstractField
Throws:
java.io.IOException

generateCopyLoadObject

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

Specified by:
generateCopyLoadObject in interface AmberField
Overrides:
generateCopyLoadObject in class AbstractField
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
Overrides:
generateMergeFrom in class AbstractField
Throws:
java.io.IOException

generateStatementSet

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

Specified by:
generateStatementSet in interface AmberField
Overrides:
generateStatementSet in class AbstractField
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
Overrides:
generateUpdateFromObject in class AbstractField
Throws:
java.io.IOException

generatePrePersist

public void generatePrePersist(JavaWriter out)
                        throws java.io.IOException
Updates the cached copy.

Specified by:
generatePrePersist in interface AmberField
Overrides:
generatePrePersist in class AbstractField
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
Overrides:
generateInvalidateForeign in class AbstractField
Throws:
java.io.IOException

generatePreDelete

public void generatePreDelete(JavaWriter out)
                       throws java.io.IOException
Generates any pre-delete code

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

generatePostDelete

public void generatePostDelete(JavaWriter out)
                        throws java.io.IOException
Generates any pre-delete code

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