com.caucho.amber.field
Class KeyManyToOneField

java.lang.Object
  extended by com.caucho.amber.field.AbstractField
      extended by com.caucho.amber.field.CascadableField
          extended by com.caucho.amber.field.ManyToOneField
              extended by com.caucho.amber.field.KeyManyToOneField
All Implemented Interfaces:
AmberField, IdField

public class KeyManyToOneField
extends ManyToOneField
implements IdField

Configuration for a bean's field


Field Summary
protected static java.util.logging.Logger log
           
 
Constructor Summary
KeyManyToOneField(EntityType entityType, java.lang.String name)
           
KeyManyToOneField(EntityType entityType, java.lang.String name, LinkColumns columns)
           
 
Method Summary
 AmberExpr createExpr(QueryParser parser, PathExpr parent)
          Creates the expression for the field.
 void generateCheckCreateKey(JavaWriter out)
          Generates the set clause.
 void generateCopy(JavaWriter out, java.lang.String dest, java.lang.String source)
          Generates code to copy to an object.
 java.lang.String generateGetKeyProperty(java.lang.String key)
          Generates the getter for a key property
 java.lang.String generateGetProxyProperty(java.lang.String value)
          Generates the property getter for an EJB proxy
 java.lang.String generateIsNull(java.lang.String value)
          Returns a test for null.
 void generateJoin(CharBuffer cb, java.lang.String table1, java.lang.String table2)
          Generates the linking for a join
 int generateLoadForeign(JavaWriter out, java.lang.String rs, java.lang.String indexVar, int index)
          Returns the foreign type.
 int generateLoadForeign(JavaWriter out, java.lang.String rs, java.lang.String indexVar, int index, java.lang.String name)
          Returns the foreign type.
 java.lang.String generateMatchArgWhere(java.lang.String id)
          Returns the where code
 void generatePrologue(JavaWriter out, java.util.HashSet<java.lang.Object> completedSet)
          Generates any prologue.
 java.lang.String generateRawWhere(java.lang.String id)
          Returns the where code
 void generateSetGeneratedKeys(JavaWriter out, java.lang.String pstmt)
          Generates the set clause.
 void generateSetInsert(JavaWriter out, java.lang.String pstmt, java.lang.String index)
          Generates the set clause.
 java.lang.String generateSetKeyProperty(java.lang.String key, java.lang.String value)
          Generates the setter for a key property
 void generateStatementSet(JavaWriter out, java.lang.String pstmt, java.lang.String index)
          Generates the set clause.
 void generateStatementSet(JavaWriter out, java.lang.String pstmt, java.lang.String index, java.lang.String value)
          Generates the set clause.
 java.lang.String generateSuperGetter(java.lang.String objThis)
          Returns the actual data.
 java.lang.String generateSuperSetter(java.lang.String objThis, java.lang.String value)
          Sets the actual data.
 AmberColumn getColumn()
          Returns the column for the field
 ForeignColumn getColumn(AmberColumn key)
          Gets the column corresponding to the target field.
 java.util.ArrayList<AmberColumn> getColumns()
          Returns columns
 int getComponentCount()
          Returns the component count.
 EntityType getEntityType()
          Returns the target type as entity (ejb 2.1) See com.caucho.ejb.ql.Expr
 java.lang.String getForeignTypeName()
          Returns the foreign type name.
 java.lang.String getGenerator()
          Gets the generator.
 KeyPropertyField getIdField(IdField field)
          Returns the identifying field matching the target's id.
 AmberType getType()
          Returns type
 void init()
          Initialize the field.
 boolean isAutoGenerate()
          Returns true for a generator.
 boolean isSourceCascadeDelete()
          Set true if deletes cascade to the source.
 boolean isTargetCascadeDelete()
          Set true if deletes cascade to the target.
 void setKeyField(boolean isKeyField)
          Set true if key fields are accessed through fields.
 java.lang.String toValue(java.lang.String value)
          Converts from an object.
 
Methods inherited from class com.caucho.amber.field.ManyToOneField
generateCopyLoadObject, generateCopyUpdateObject, generateGetterMethod, generateInsertColumns, generateInvalidateForeign, generateLoad, generateLoadProperty, generateLoadSelect, generateMergeFrom, generatePostConstructor, generatePostDelete, generatePostLoadSelect, generatePreDelete, generatePrePersist, generateSelect, generateSetterMethod, generateUpdate, generateUpdateFromObject, getEntityTargetType, getJoinColumnMap, getJoinColumns, getLinkColumns, getRelatedType, init, isAnnotatedManyToOne, override, setAliasField, setJoinColumnMap, setJoinColumns, setLinkColumns, setSourceCascadeDelete, setTargetCascadeDelete, setTargetField, setType
 
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, generateSuperGetterMethod, generateSuperSetterMethod, generateUpdate, generateUpdateSet, generateWhere, getBeanClass, 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
 
Methods inherited from interface com.caucho.amber.field.IdField
getJavaTypeName
 
Methods inherited from interface com.caucho.amber.field.AmberField
childDelete, generateCastFromObject, generateCopyLoadObject, generateCopyUpdateObject, generateCreateTableSQL, generateDetach, generateDumpRelationships, generateEquals, generateExpire, generateGet, generateGet, generateGetterMethod, generateInsertColumns, generateInsertSet, generateInvalidateForeign, generateJavaSelect, generateLoad, generateLoadFromObject, generateLoadNative, generateLoadSelect, generateMergeFrom, generateNativeColumnNames, generatePostConstructor, generatePostDelete, generatePostLoadSelect, generatePreDelete, generatePrePersist, generateSelect, generateSet, generateSet, generateSetterMethod, generateSuperGetterMethod, generateSuperSetterMethod, generateUpdate, generateUpdate, generateUpdateFromObject, generateUpdateSet, generateWhere, getCreateLoadMask, getGetterMethod, getGetterName, getIndex, getJavaClass, getJavaType, getLoadGroupIndex, getName, getSetterMethod, getSetterName, getSourceType, getTable, hasLoadGroup, isAbstract, isCascadable, isLazy, isUpdateable, link, override, setIndex, toObject
 

Field Detail

log

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

KeyManyToOneField

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

KeyManyToOneField

public KeyManyToOneField(EntityType entityType,
                         java.lang.String name,
                         LinkColumns columns)
                  throws ConfigException
Throws:
ConfigException
Method Detail

getGenerator

public java.lang.String getGenerator()
Gets the generator.

Specified by:
getGenerator in interface IdField

getEntityType

public EntityType getEntityType()
Returns the target type as entity (ejb 2.1) See com.caucho.ejb.ql.Expr


getType

public AmberType getType()
Description copied from interface: IdField
Returns type

Specified by:
getType in interface IdField

getColumn

public AmberColumn getColumn()
Description copied from class: AbstractField
Returns the column for the field

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

isAutoGenerate

public boolean isAutoGenerate()
Returns true for a generator.

Specified by:
isAutoGenerate in interface IdField

setKeyField

public void setKeyField(boolean isKeyField)
Set true if key fields are accessed through fields.

Specified by:
setKeyField in interface IdField

getForeignTypeName

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

Specified by:
getForeignTypeName in interface IdField
Overrides:
getForeignTypeName in class ManyToOneField

isTargetCascadeDelete

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

Overrides:
isTargetCascadeDelete in class ManyToOneField

isSourceCascadeDelete

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

Overrides:
isSourceCascadeDelete in class ManyToOneField

init

public void init()
          throws ConfigException
Initialize the field.

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

getComponentCount

public int getComponentCount()
Returns the component count.

Specified by:
getComponentCount in interface IdField

getColumns

public java.util.ArrayList<AmberColumn> getColumns()
Returns columns

Specified by:
getColumns in interface IdField

getIdField

public KeyPropertyField getIdField(IdField field)
Returns the identifying field matching the target's id.


createExpr

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

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

generateMatchArgWhere

public java.lang.String generateMatchArgWhere(java.lang.String id)
Returns the where code

Specified by:
generateMatchArgWhere in interface IdField

generateRawWhere

public java.lang.String generateRawWhere(java.lang.String id)
Returns the where code

Specified by:
generateRawWhere in interface IdField

generateGetProxyProperty

public java.lang.String generateGetProxyProperty(java.lang.String value)
Generates the property getter for an EJB proxy

Specified by:
generateGetProxyProperty in interface IdField
Parameters:
value - the non-null value

generateJoin

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

Overrides:
generateJoin in class ManyToOneField

getColumn

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

Overrides:
getColumn in class ManyToOneField

generateLoadForeign

public int generateLoadForeign(JavaWriter out,
                               java.lang.String rs,
                               java.lang.String indexVar,
                               int index)
                        throws java.io.IOException
Returns the foreign type.

Specified by:
generateLoadForeign in interface IdField
Throws:
java.io.IOException

generateSuperGetter

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

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

generateSuperSetter

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

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

generateCopy

public void generateCopy(JavaWriter out,
                         java.lang.String dest,
                         java.lang.String source)
                  throws java.io.IOException
Generates code to copy to an object.

Specified by:
generateCopy in interface IdField
Throws:
java.io.IOException

generateLoadForeign

public int generateLoadForeign(JavaWriter out,
                               java.lang.String rs,
                               java.lang.String indexVar,
                               int index,
                               java.lang.String name)
                        throws java.io.IOException
Returns the foreign type.

Specified by:
generateLoadForeign in interface IdField
Throws:
java.io.IOException

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 ManyToOneField
Throws:
java.io.IOException

generateStatementSet

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

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

generateSetInsert

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

Specified by:
generateSetInsert in interface IdField
Throws:
java.io.IOException

generateSetKeyProperty

public java.lang.String generateSetKeyProperty(java.lang.String key,
                                               java.lang.String value)
                                        throws java.io.IOException
Generates the setter for a key property

Specified by:
generateSetKeyProperty in interface IdField
Throws:
java.io.IOException

generateGetKeyProperty

public java.lang.String generateGetKeyProperty(java.lang.String key)
                                        throws java.io.IOException
Generates the getter for a key property

Specified by:
generateGetKeyProperty in interface IdField
Throws:
java.io.IOException

generateSetGeneratedKeys

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

Specified by:
generateSetGeneratedKeys in interface IdField
Throws:
java.io.IOException

generateCheckCreateKey

public void generateCheckCreateKey(JavaWriter out)
                            throws java.io.IOException
Generates the set clause.

Specified by:
generateCheckCreateKey in interface IdField
Throws:
java.io.IOException

generateIsNull

public java.lang.String generateIsNull(java.lang.String value)
Returns a test for null.

Specified by:
generateIsNull in interface IdField

toValue

public java.lang.String toValue(java.lang.String value)
Converts from an object.

Specified by:
toValue in interface IdField