com.caucho.amber.table
Class LinkColumns

java.lang.Object
  extended by com.caucho.amber.table.LinkColumns

public class LinkColumns
extends java.lang.Object

Represents a many-to-one link from one table to another.


Constructor Summary
LinkColumns(AmberTable sourceTable, AmberTable targetTable, java.util.ArrayList<ForeignColumn> columns)
          Creates the table link.
 
Method Summary
 void afterSourceDelete(AmberConnection aConn, Entity entity)
          Cleans up any fields from a delete.
 void beforeTargetDelete(AmberConnection aConn, Entity entity)
          Cleans up any fields from a delete.
 void generateInsert(java.util.ArrayList<java.lang.String> columns)
          Generates SQL insert.
 java.lang.String generateJoin(LinkColumns manyToOneJoin, java.lang.String sourceTable1, java.lang.String sourceTable2)
          Generates the many-to-many linking.
 java.lang.String generateJoin(java.lang.String sourceTable, java.lang.String targetTable)
          Generates the linking for a join
 java.lang.String generateJoin(java.lang.String sourceTable, java.lang.String targetTable, boolean isArg)
          Generates the linking for a join
 java.lang.String generateMatchArgSQL(java.lang.String table)
          Generates SQL match.
 java.lang.String generateSelectSQL(java.lang.String table)
          Generates SQL select.
 java.lang.String generateUpdateSQL()
          Generates SQL select.
 java.lang.String generateWhere(java.lang.String sourceTable, java.lang.String targetTable)
          Generates the linking for a where clause
 java.util.ArrayList<ForeignColumn> getColumns()
          Returns the component list.
 ForeignColumn getSourceColumn(AmberColumn targetKey)
          Generates the linking for a link
 AmberTable getSourceTable()
          Returns the source table.
 AmberTable getTargetTable()
          Returns the target table.
 boolean isSourceCascadeDelete()
          Return true if the source is deleted when the target is deleted.
 boolean isTargetCascadeDelete()
          Return true if the source is deleted when the target is deleted.
 void setSourceCascadeDelete(boolean isCascadeDelete)
          Sets the cascade-delete of the source when the target is deleted, i.e.
 void setTargetCascadeDelete(boolean isCascadeDelete)
          Sets the cascade-delete of the target when the source is deleted.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LinkColumns

public LinkColumns(AmberTable sourceTable,
                   AmberTable targetTable,
                   java.util.ArrayList<ForeignColumn> columns)
Creates the table link.

Method Detail

setSourceCascadeDelete

public void setSourceCascadeDelete(boolean isCascadeDelete)
Sets the cascade-delete of the source when the target is deleted, i.e. a one-to-many cascaded delete like an identifying relation.


setTargetCascadeDelete

public void setTargetCascadeDelete(boolean isCascadeDelete)
Sets the cascade-delete of the target when the source is deleted.


isSourceCascadeDelete

public boolean isSourceCascadeDelete()
Return true if the source is deleted when the target is deleted.


isTargetCascadeDelete

public boolean isTargetCascadeDelete()
Return true if the source is deleted when the target is deleted.


getSourceTable

public AmberTable getSourceTable()
Returns the source table.


getTargetTable

public AmberTable getTargetTable()
Returns the target table.


getColumns

public java.util.ArrayList<ForeignColumn> getColumns()
Returns the component list.


getSourceColumn

public ForeignColumn getSourceColumn(AmberColumn targetKey)
Generates the linking for a link


generateSelectSQL

public java.lang.String generateSelectSQL(java.lang.String table)
Generates SQL select.


generateInsert

public void generateInsert(java.util.ArrayList<java.lang.String> columns)
Generates SQL insert.


generateUpdateSQL

public java.lang.String generateUpdateSQL()
Generates SQL select.


generateMatchArgSQL

public java.lang.String generateMatchArgSQL(java.lang.String table)
Generates SQL match.


generateJoin

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

Parameters:
sourceTable - the SQL table name for the source
targetTable - the SQL table name for the target

generateJoin

public java.lang.String generateJoin(java.lang.String sourceTable,
                                     java.lang.String targetTable,
                                     boolean isArg)
Generates the linking for a join

Parameters:
sourceTable - the SQL table name for the source
targetTable - the SQL table name for the target
isArg - true if targetTable is an argument "?"

generateJoin

public java.lang.String generateJoin(LinkColumns manyToOneJoin,
                                     java.lang.String sourceTable1,
                                     java.lang.String sourceTable2)
Generates the many-to-many linking. This join is the one-to-many join and the other join is passed in as an argument used to link the two source tables that are pointing to the same target table.

Parameters:
join - the many-to-one join
sourceTable1 - the SQL table name for the 1st source
sourceTable2 - the SQL table name for the 2nd source

generateWhere

public java.lang.String generateWhere(java.lang.String sourceTable,
                                      java.lang.String targetTable)
Generates the linking for a where clause

Parameters:
sourceTable - the SQL table name for the source
targetTable - the SQL table name for the target

beforeTargetDelete

public void beforeTargetDelete(AmberConnection aConn,
                               Entity entity)
                        throws java.sql.SQLException
Cleans up any fields from a delete.

Throws:
java.sql.SQLException

afterSourceDelete

public void afterSourceDelete(AmberConnection aConn,
                              Entity entity)
                       throws java.sql.SQLException
Cleans up any fields from a delete.

Throws:
java.sql.SQLException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object