com.caucho.amber.field
Class Id

java.lang.Object
  extended by com.caucho.amber.field.Id
Direct Known Subclasses:
CompositeId, SubId

public class Id
extends java.lang.Object

Configuration for a bean's field


Constructor Summary
protected Id(EntityType ownerType)
           
  Id(EntityType ownerType, java.util.ArrayList<IdField> keys)
           
  Id(EntityType ownerType, IdField key)
           
 
Method Summary
protected  void addKey(IdField key)
          Adds a new field to the id.
 java.lang.String generateCastFromObject(java.lang.String value)
          Generates code to convert to the type from the object.
 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 generateCreateTableSQL(AmberPersistenceUnit manager)
          Generates the where clause.
 java.lang.String generateEquals(java.lang.String leftBase, java.lang.String value)
          Generates code to test the equals.
 java.lang.String generateGet(java.lang.String obj)
          Returns the key for the value
 java.lang.String generateGetProxyKey(java.lang.String value)
          Returns the key for the value
 java.lang.String generateJavaSelect(java.lang.String id)
          Generates the JPA QL select clause.
 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.
 void generateLoadFromObject(JavaWriter out, java.lang.String obj)
          Generates loading cache
 java.lang.String generateLoadSelect(java.lang.String id)
          Generates the select clause.
 void generateMatch(JavaWriter out, java.lang.String key)
          Generates code for a match.
 java.lang.String generateMatchArgWhere(java.lang.String id)
          Generates the where clause.
 void generatePrologue(JavaWriter out, java.util.HashSet<java.lang.Object> completedSet)
          Generates any prologue.
 void generatePrologue(JavaWriter out, java.util.HashSet<java.lang.Object> completedSet, java.lang.String name)
          Generates any prologue.
 java.lang.String generateRawWhere(java.lang.String id)
          Generates the where clause.
 java.lang.String generateSelect(java.lang.String id)
          Generates the select clause.
 void generateSet(JavaWriter out, java.lang.String obj, java.lang.String value)
          Generates loading cache
 void generateSet(JavaWriter out, java.lang.String pstmt, java.lang.String index, java.lang.String value)
          Generates the set clause.
 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.
 void generateSetKey(JavaWriter out, java.lang.String pstmt, java.lang.String index, java.lang.String keyObject)
          Generates the set clause.
 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
 java.util.ArrayList<AmberColumn> getColumns()
          Returns all the column.
 EmbeddedIdField getEmbeddedIdField()
          Returns the embedded id field
 java.lang.String getForeignTypeName()
          Returns the foreign type.
 IdField getGeneratedIdField()
           
 IdField getKey()
          Returns the keys.
 int getKeyCount()
          Returns all the keys.
 java.util.ArrayList<IdField> getKeys()
          Returns all the keys.
 java.lang.Object getObject(java.sql.ResultSet rs, int index)
          Generates code to convert to the object.
 EntityType getOwnerType()
          Returns the owner type.
 void init()
          Initialize the id.
 boolean isEmbeddedId()
          Returns true if this is an @EmbeddedId
 boolean isIdentityGenerator()
           
 java.lang.String toObject(java.lang.String value)
          Generates code to convert to the object.
 java.lang.Object toObjectKey(long value)
          Generates code to convert to the object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Id

public Id(EntityType ownerType,
          java.util.ArrayList<IdField> keys)

Id

protected Id(EntityType ownerType)

Id

public Id(EntityType ownerType,
          IdField key)
Method Detail

addKey

protected void addKey(IdField key)
Adds a new field to the id.


getOwnerType

public EntityType getOwnerType()
Returns the owner type.


getColumns

public java.util.ArrayList<AmberColumn> getColumns()
Returns all the column.


getKeys

public java.util.ArrayList<IdField> getKeys()
Returns all the keys.


getKeyCount

public int getKeyCount()
Returns all the keys.


getKey

public IdField getKey()
Returns the keys.


getForeignTypeName

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


isIdentityGenerator

public boolean isIdentityGenerator()

getGeneratedIdField

public IdField getGeneratedIdField()

init

public void init()
          throws ConfigException
Initialize the id.

Throws:
ConfigException

generatePrologue

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

Throws:
java.io.IOException

generatePrologue

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

Throws:
java.io.IOException

generateLoadForeign

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

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.

Throws:
java.io.IOException

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.

Throws:
java.io.IOException

generateSelect

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


generateJavaSelect

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


generateLoadSelect

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


generateGetProxyKey

public java.lang.String generateGetProxyKey(java.lang.String value)
Returns the key for the value


generateLoadFromObject

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

Throws:
java.io.IOException

generateGet

public java.lang.String generateGet(java.lang.String obj)
Returns the key for the value


generateSet

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

Throws:
java.io.IOException

generateUpdateFromObject

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

Throws:
java.io.IOException

generateMatchArgWhere

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


generateRawWhere

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


generateCreateTableSQL

public java.lang.String generateCreateTableSQL(AmberPersistenceUnit manager)
Generates the where clause.


generateSetKey

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

Throws:
java.io.IOException

generateSet

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

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.

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.

Throws:
java.io.IOException

generateCastFromObject

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


generateMatch

public void generateMatch(JavaWriter out,
                          java.lang.String key)
                   throws java.io.IOException
Generates code for a match.

Throws:
java.io.IOException

generateEquals

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


generateCheckCreateKey

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

Throws:
java.io.IOException

generateSetGeneratedKeys

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

Throws:
java.io.IOException

getEmbeddedIdField

public EmbeddedIdField getEmbeddedIdField()
Returns the embedded id field


isEmbeddedId

public boolean isEmbeddedId()
Returns true if this is an @EmbeddedId


toObject

public java.lang.String toObject(java.lang.String value)
Generates code to convert to the object.


toObjectKey

public java.lang.Object toObjectKey(long value)
Generates code to convert to the object.


getObject

public java.lang.Object getObject(java.sql.ResultSet rs,
                                  int index)
                           throws java.sql.SQLException
Generates code to convert to the object.

Throws:
java.sql.SQLException