com.caucho.amber.field
Class DependentEntityOneToOneField

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

public class DependentEntityOneToOneField
extends CascadableField

Represents the dependent side of a one-to-one bidirectional link.


Constructor Summary
DependentEntityOneToOneField(EntityType relatedType, java.lang.String name)
           
DependentEntityOneToOneField(EntityType relatedType, java.lang.String name, CascadeType[] cascadeTypes)
           
 
Method Summary
 AmberExpr createExpr(QueryParser parser, PathExpr parent)
          Creates the expression for the field.
 void generateCopyUpdateObject(JavaWriter out, java.lang.String dst, java.lang.String src, int updateIndex)
          Updates the cached copy.
 void generateGetterMethod(JavaWriter out)
          Generates the set property.
 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
 void generateLoadProperty(JavaWriter out, java.lang.String index, java.lang.String session)
          Generates the set property.
 void generateMergeFrom(JavaWriter out, java.lang.String dst, java.lang.String src)
          Updates the cached copy.
 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 generatePrologue(JavaWriter out, java.util.HashSet<java.lang.Object> completedSet)
          Generates any prologue.
 void generateSetterMethod(JavaWriter out)
          Generates the set property.
 void generateStatementSet(JavaWriter out, java.lang.String pstmt, java.lang.String index)
          Generates the set clause.
 void generateUpdateFromObject(JavaWriter out, java.lang.String obj)
          Generates loading cache
 ForeignColumn getColumn(IdField targetField)
          Gets the column corresponding to the target field.
 EntityType getEntitySourceType()
          Returns the source type as entity or mapped-superclass.
 EntityType getEntityTargetType()
          Returns the target type as entity or mapped-superclass.
 java.lang.String getForeignTypeName()
          Returns the foreign type.
 ManyToOneField getTargetField()
          Sets the target field.
 long getTargetLoadIndex()
          Gets the target load index.
 AmberType getType()
          Returns the target type.
 void init()
          Initialize the field.
 boolean isCascadeDelete()
          Returns the cascade-delete property.
 void setCascadeDelete(boolean isCascadeDelete)
          Sets the cascade-delete property.
 void setColumn(AmberColumn column)
          Sets the column.
 void setTargetField(ManyToOneField targetField)
          Sets the target field.
 
Methods inherited from class com.caucho.amber.field.CascadableField
generateFlushCheck, generateInternalCascade, getCascadeType, isCascadable, isCascade, setCascadeType
 
Methods inherited from class com.caucho.amber.field.AbstractField
childDelete, generateCastFromObject, generateCopyLoadObject, generateCreateTableSQL, generateDetach, generateDumpRelationships, generateEquals, generateExpire, generateGet, generateGet, generateInsert, generateInsertColumns, generateInsertSet, generateJavaSelect, generateLoadFromObject, generateLoadNative, generateLoadSelect, generateNativeColumnNames, generateNull, generatePostConstructor, generatePostDelete, generatePreDelete, generatePrePersist, generateSelect, generateSet, generateSet, generateStatementSet, generateSuperGetter, generateSuperGetterMethod, generateSuperSetter, generateSuperSetterMethod, generateUpdate, generateUpdate, 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, 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

DependentEntityOneToOneField

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

DependentEntityOneToOneField

public DependentEntityOneToOneField(EntityType relatedType,
                                    java.lang.String name,
                                    CascadeType[] cascadeTypes)
                             throws ConfigException
Throws:
ConfigException
Method Detail

setTargetField

public void setTargetField(ManyToOneField targetField)
Sets the target field.


getTargetField

public ManyToOneField getTargetField()
Sets the target field.


getTargetLoadIndex

public long getTargetLoadIndex()
Gets the target load index.


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.


getType

public AmberType getType()
Returns the target type.


getForeignTypeName

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


setColumn

public void setColumn(AmberColumn column)
Sets the column.

Overrides:
setColumn in class AbstractField

setCascadeDelete

public void setCascadeDelete(boolean isCascadeDelete)
Sets the cascade-delete property.


isCascadeDelete

public boolean isCascadeDelete()
Returns the cascade-delete property.


init

public void init()
          throws ConfigException
Description copied from class: AbstractField
Initialize the field.

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

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(IdField targetField)
Gets the column corresponding to the target field.


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 set property.

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

generateLoadProperty

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

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

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

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

generateStatementSet

public void generateStatementSet(JavaWriter out,
                                 java.lang.String pstmt,
                                 java.lang.String index)
                          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

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

generatePreCascade

public void generatePreCascade(JavaWriter out,
                               java.lang.String aConn,
                               CascadeType cascadeType)
                        throws java.io.IOException
Description copied from class: CascadableField
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. Default is to pre-cascade the persist() operation only. Check subclasses for one-to-one, many-to-one, one-to-many and many-to-many relationships.

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

generatePostCascade

public void generatePostCascade(JavaWriter out,
                                java.lang.String aConn,
                                CascadeType cascadeType)
                         throws java.io.IOException
Description copied from class: CascadableField
Generates the (post) cascade operation from parent to this child. This field will be (post) cascaded if the operation on the parent is required to be performed first to avoid breaking FK constraints. Default is to post-cascade all operations, except the persist() operation. Check subclasses for one-to-one, many-to-one, one-to-many and many-to-many relationships.

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