com.caucho.amber.field
Class OneToManyField

java.lang.Object
  extended by com.caucho.amber.field.AbstractField
      extended by com.caucho.amber.field.CascadableField
          extended by com.caucho.amber.field.CollectionField
              extended by com.caucho.amber.field.OneToManyField
All Implemented Interfaces:
AmberField

public class OneToManyField
extends CollectionField

Represents a field to a collection of objects where the target hold a back-link to the source entity.


Constructor Summary
OneToManyField(EntityType entityType)
           
OneToManyField(EntityType entityType, java.lang.String name)
           
OneToManyField(EntityType entityType, java.lang.String name, CascadeType[] cascadeTypes)
           
 
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 loadIndex)
          Updates from the cached copy.
 void generateExpire(JavaWriter out)
          Generates the expire code ejb/06hi
 void generateGetterMethod(JavaWriter out)
          Generates the set property.
protected  void generateInternalCascade(JavaWriter out, java.lang.String aConn, CascadeType cascadeType)
           
 void generateInvalidateForeign(JavaWriter out)
          Generates code for foreign entity create/delete
 java.lang.String generateLoadSelect(java.lang.String id)
          Generates the select clause.
 void generatePostCascade(JavaWriter out, java.lang.String aConn, CascadeType cascadeType)
          Generates the (post) cascade operation from parent to this child.
 int generatePostLoadSelect(JavaWriter out, int index)
          Generates loading code after the basic fields.
 void generatePreCascade(JavaWriter out, java.lang.String aConn, CascadeType cascadeType)
          Generates the (pre) cascade operation from parent to this child.
 void generateSetterMethod(JavaWriter out)
          Generates the set property.
 void generateStatementSet(JavaWriter out, java.lang.String pstmt, java.lang.String obj, java.lang.String index)
          Generates the set clause.
 java.lang.String generateTargetSelect(java.lang.String id)
          Generates the target select.
 EntityType getEntitySourceType()
          Returns the source type as entity or mapped-superclass.
 EntityType getEntityTargetType()
          Returns the target type as entity or mapped-superclass.
 LinkColumns getLinkColumns()
          Returns the link.
 java.lang.String getMapKey()
          Gets the map key.
 ManyToOneField getSourceField()
          Gets the source field.
 AmberType getTargetType()
          Returns the target type as entity.
 void init()
          Initialize.
 void setMapKey(java.lang.String mapKey)
          Sets the map key.
 void setOrderBy(java.util.ArrayList<java.lang.String> orderByFields, java.util.ArrayList<java.lang.Boolean> orderByAscending)
          Sets the order by.
 void setSourceField(ManyToOneField sourceField)
          Sets the source field.
 
Methods inherited from class com.caucho.amber.field.CollectionField
generateCopyUpdateObject, generateJoin, generateUpdate, getSourceColumn, getTableName, setLinkColumns, setTable, setType
 
Methods inherited from class com.caucho.amber.field.CascadableField
generateFlushCheck, getCascadeType, isCascadable, isCascade, setCascadeType
 
Methods inherited from class com.caucho.amber.field.AbstractField
childDelete, generateCastFromObject, generateCreateTableSQL, generateDetach, generateDumpRelationships, generateEquals, generateGet, generateGet, generateInsert, generateInsertColumns, generateInsertSet, generateJavaSelect, generateLoad, generateLoadFromObject, generateLoadNative, generateLoadSelect, generateMergeFrom, generateNativeColumnNames, generateNull, generatePostConstructor, generatePostDelete, generatePreDelete, generatePrePersist, generatePrologue, generateSelect, generateSet, generateSet, generateStatementSet, generateSuperGetter, generateSuperGetterMethod, generateSuperSetter, generateSuperSetterMethod, generateUpdate, generateUpdateFromObject, generateUpdateSet, generateWhere, getBeanClass, getColumn, getCreateLoadMask, getFieldName, getGetterMethod, getGetterName, getIndex, getJavaClass, getJavaType, getJavaTypeName, getLoadGroupIndex, getName, getPersistenceUnit, getSetterMethod, getSetterName, getSourceType, getTable, hasLoadGroup, isAbstract, isFieldAccess, isKey, isLazy, isOverride, isUpdateable, link, override, 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

OneToManyField

public OneToManyField(EntityType entityType,
                      java.lang.String name,
                      CascadeType[] cascadeTypes)
               throws ConfigException
Throws:
ConfigException

OneToManyField

public OneToManyField(EntityType entityType,
                      java.lang.String name)
               throws ConfigException
Throws:
ConfigException

OneToManyField

public OneToManyField(EntityType entityType)
Method Detail

setOrderBy

public void setOrderBy(java.util.ArrayList<java.lang.String> orderByFields,
                       java.util.ArrayList<java.lang.Boolean> orderByAscending)
Sets the order by.


getEntitySourceType

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

Overrides:
getEntitySourceType in class AbstractField

getEntityTargetType

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


getTargetType

public AmberType getTargetType()
Returns the target type as entity.

Overrides:
getTargetType in class CollectionField

getSourceField

public ManyToOneField getSourceField()
Gets the source field.


setSourceField

public void setSourceField(ManyToOneField sourceField)
Sets the source field.


getLinkColumns

public LinkColumns getLinkColumns()
Returns the link.

Overrides:
getLinkColumns in class CollectionField

getMapKey

public java.lang.String getMapKey()
Gets the map key.


setMapKey

public void setMapKey(java.lang.String mapKey)
Sets the map key.


init

public void init()
Initialize.

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

createExpr

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

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

generatePreCascade

public void generatePreCascade(JavaWriter out,
                               java.lang.String aConn,
                               CascadeType cascadeType)
                        throws java.io.IOException
Generates the (pre) cascade operation from parent to this child. This field will only be cascaded first if the operation can be performed with no risk to break FK constraints.

Overrides:
generatePreCascade in class CollectionField
Throws:
java.io.IOException

generatePostCascade

public void generatePostCascade(JavaWriter out,
                                java.lang.String aConn,
                                CascadeType cascadeType)
                         throws java.io.IOException
Generates the (post) cascade operation from parent to this child. This field will only be cascaded first if the operation can be performed with no risk to break FK constraints.

Overrides:
generatePostCascade in class CollectionField
Throws:
java.io.IOException

generateInternalCascade

protected void generateInternalCascade(JavaWriter out,
                                       java.lang.String aConn,
                                       CascadeType cascadeType)
                                throws java.io.IOException
Overrides:
generateInternalCascade in class CascadableField
Throws:
java.io.IOException

generateStatementSet

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

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

generateLoadSelect

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

Overrides:
generateLoadSelect in class CollectionField

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

generateCopyLoadObject

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

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

generateTargetSelect

public java.lang.String generateTargetSelect(java.lang.String id)
Generates the target select.

Overrides:
generateTargetSelect in class CollectionField

generateGetterMethod

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

Specified by:
generateGetterMethod in interface AmberField
Overrides:
generateGetterMethod in class AbstractField
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

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

generateExpire

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

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