org.h2.schema
Class TriggerObject

java.lang.Object
  extended by org.h2.engine.DbObjectBase
      extended by org.h2.schema.SchemaObjectBase
          extended by org.h2.schema.TriggerObject
All Implemented Interfaces:
DbObject, SchemaObject

public class TriggerObject
extends SchemaObjectBase

A trigger is created using the statement CREATE TRIGGER


Field Summary
static int DEFAULT_QUEUE_SIZE
          The default queue size.
 
Fields inherited from class org.h2.engine.DbObjectBase
comment, database, trace
 
Fields inherited from interface org.h2.engine.DbObject
AGGREGATE, COMMENT, CONSTANT, CONSTRAINT, FUNCTION_ALIAS, INDEX, RIGHT, ROLE, SCHEMA, SEQUENCE, SETTING, TABLE_OR_VIEW, TRIGGER, USER, USER_DATATYPE
 
Constructor Summary
TriggerObject(Schema schema, int id, java.lang.String name, Table table)
           
 
Method Summary
 void checkRename()
          Check if this object can be renamed.
 void close()
          Close the trigger.
 void fire(Session session, boolean beforeAction)
          Call the trigger class if required.
 void fireRow(Session session, Row oldRow, Row newRow, boolean beforeAction)
          Call the fire method of the user-defined trigger class if required.
 java.lang.String getCreateSQL()
          Build a SQL statement to re-create this object.
 java.lang.String getCreateSQLForCopy(Table table, java.lang.String quotedName)
          Build a SQL statement to re-create the object, or to create a copy of the object with a different name or referencing a different table
 java.lang.String getDropSQL()
          Build a SQL statement to drop this object.
 int getQueueSize()
           
 Table getTable()
          Get the table of this trigger.
 java.lang.String getTriggerClassName()
          Get the trigger class name.
 int getType()
          Get the object type.
 java.lang.String getTypeNameList()
           
 boolean isBefore()
          Check if this is a before trigger.
 boolean isNoWait()
           
 void removeChildrenAndResources(Session session)
          Remove all dependent objects and free all resources (files, blocks in files) of this object.
 void setBefore(boolean before)
           
 void setNoWait(boolean noWait)
           
 void setQueueSize(int size)
           
 void setRowBased(boolean rowBased)
           
 void setTriggerClassName(Session session, java.lang.String triggerClassName, boolean force)
          Set the trigger class name and load the class if possible.
 void setTypeMask(int typeMask)
          Set the trigger type.
 
Methods inherited from class org.h2.schema.SchemaObjectBase
getSchema, getSQL, initSchemaObjectBase
 
Methods inherited from class org.h2.engine.DbObjectBase
getChildren, getComment, getDatabase, getHeadPos, getId, getModificationId, getName, initDbObjectBase, invalidate, isTemporary, rename, setComment, setModified, setObjectName, setTemporary, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.h2.engine.DbObject
getChildren, getComment, getDatabase, getHeadPos, getId, getModificationId, getName, isTemporary, rename, setComment, setModified, setTemporary
 

Field Detail

DEFAULT_QUEUE_SIZE

public static final int DEFAULT_QUEUE_SIZE
The default queue size.

See Also:
Constant Field Values
Constructor Detail

TriggerObject

public TriggerObject(Schema schema,
                     int id,
                     java.lang.String name,
                     Table table)
Method Detail

setBefore

public void setBefore(boolean before)

setTriggerClassName

public void setTriggerClassName(Session session,
                                java.lang.String triggerClassName,
                                boolean force)
                         throws java.sql.SQLException
Set the trigger class name and load the class if possible.

Parameters:
session - the session
triggerClassName - the name of the trigger class
force - whether exceptions (due to missing class or access rights) should be ignored
Throws:
java.sql.SQLException

fire

public void fire(Session session,
                 boolean beforeAction)
          throws java.sql.SQLException
Call the trigger class if required. This method does nothing if the trigger is not defined for the given action. This method is called before or after any rows have been processed, once for each statement.

Parameters:
session - the session
beforeAction - if this method is called before applying the changes
Throws:
java.sql.SQLException

fireRow

public void fireRow(Session session,
                    Row oldRow,
                    Row newRow,
                    boolean beforeAction)
             throws java.sql.SQLException
Call the fire method of the user-defined trigger class if required. This method does nothing if the trigger is not defined for the given action. This method is called before or after a row is processed, possibly many times for each statement.

Parameters:
session - the session
oldRow - the old row
newRow - the new row
beforeAction - true if this method is called before the operation is applied
Throws:
java.sql.SQLException

setTypeMask

public void setTypeMask(int typeMask)
Set the trigger type.

Parameters:
typeMask - the type

setRowBased

public void setRowBased(boolean rowBased)

setQueueSize

public void setQueueSize(int size)

getQueueSize

public int getQueueSize()

setNoWait

public void setNoWait(boolean noWait)

isNoWait

public boolean isNoWait()

getDropSQL

public java.lang.String getDropSQL()
Description copied from class: DbObjectBase
Build a SQL statement to drop this object.

Specified by:
getDropSQL in interface DbObject
Specified by:
getDropSQL in class DbObjectBase
Returns:
the SQL statement

getCreateSQLForCopy

public java.lang.String getCreateSQLForCopy(Table table,
                                            java.lang.String quotedName)
Description copied from class: DbObjectBase
Build a SQL statement to re-create the object, or to create a copy of the object with a different name or referencing a different table

Specified by:
getCreateSQLForCopy in interface DbObject
Specified by:
getCreateSQLForCopy in class DbObjectBase
Parameters:
table - the new table name
quotedName - the new quoted name
Returns:
the SQL statement

getTypeNameList

public java.lang.String getTypeNameList()

getCreateSQL

public java.lang.String getCreateSQL()
Description copied from class: DbObjectBase
Build a SQL statement to re-create this object.

Specified by:
getCreateSQL in interface DbObject
Specified by:
getCreateSQL in class DbObjectBase
Returns:
the SQL statement

getType

public int getType()
Description copied from class: DbObjectBase
Get the object type.

Specified by:
getType in interface DbObject
Specified by:
getType in class DbObjectBase
Returns:
the object type

removeChildrenAndResources

public void removeChildrenAndResources(Session session)
                                throws java.sql.SQLException
Description copied from class: DbObjectBase
Remove all dependent objects and free all resources (files, blocks in files) of this object.

Specified by:
removeChildrenAndResources in interface DbObject
Specified by:
removeChildrenAndResources in class DbObjectBase
Parameters:
session - the session
Throws:
java.sql.SQLException

checkRename

public void checkRename()
Description copied from class: DbObjectBase
Check if this object can be renamed. System objects may not be renamed.

Specified by:
checkRename in interface DbObject
Specified by:
checkRename in class DbObjectBase

getTable

public Table getTable()
Get the table of this trigger.

Returns:
the table

isBefore

public boolean isBefore()
Check if this is a before trigger.

Returns:
true if it is

getTriggerClassName

public java.lang.String getTriggerClassName()
Get the trigger class name.

Returns:
the class name

close

public void close()
           throws java.sql.SQLException
Close the trigger.

Throws:
java.sql.SQLException