Package org.h2.engine
Class DbObject
- java.lang.Object
-
- org.h2.engine.DbObject
-
- All Implemented Interfaces:
HasSQL
- Direct Known Subclasses:
Comment,Right,RightOwner,Schema,SchemaObject,Setting
public abstract class DbObject extends java.lang.Object implements HasSQL
A database object such as a table, an index, or a user.
-
-
Field Summary
Fields Modifier and Type Field Description static intAGGREGATEThis object is a user-defined aggregate function.protected java.lang.StringcommentThe comment (if set).static intCOMMENTThis object is a comment.static intCONSTANTThis object is a constant.static intCONSTRAINTThis object is a constraint (check constraint, unique constraint, or referential constraint).protected DatabasedatabaseThe database.static intDOMAINThis object is a domain.static intFUNCTION_ALIASThis object is an alias for a Java function.private intidstatic intINDEXThis object is an index.private longmodificationIdprivate java.lang.StringobjectNamestatic intRIGHTThis object is a right.static intROLEThis object is a role.static intSCHEMAThis object is a schema.static intSEQUENCEThis object is a sequence.static intSETTINGThis object is a setting.static intSYNONYMThis object is a synonym.static intTABLE_OR_VIEWThe object is of the type table or view.private booleantemporaryprotected TracetraceThe trace module.static intTRIGGERThis object is a trigger.static intUSERThis object is a user.-
Fields inherited from interface org.h2.util.HasSQL
ADD_PLAN_INFORMATION, DEFAULT_SQL_FLAGS, NO_CASTS, QUOTE_ONLY_WHEN_REQUIRED, REPLACE_LOBS_FOR_TRACE, TRACE_SQL_FLAGS
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidcheckRename()Check if renaming is allowed.java.util.ArrayList<DbObject>getChildren()Get the list of dependent children (for tables, this includes indexes and so on).java.lang.StringgetComment()Get the current comment of this object.abstract java.lang.StringgetCreateSQL()Construct the CREATE ...abstract java.lang.StringgetCreateSQLForCopy(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 tablejava.lang.StringgetCreateSQLForMeta()Construct the CREATE ...DatabasegetDatabase()Get the database.java.lang.StringgetDropSQL()Construct a DROP ...intgetId()Get the unique object id.longgetModificationId()java.lang.StringgetName()Get the name.java.lang.StringgetSQL(int sqlFlags)Get the SQL statement of this expression.java.lang.StringBuildergetSQL(java.lang.StringBuilder builder, int sqlFlags)Appends the SQL statement of this object to the specified builder.abstract intgetType()Get the object type.protected voidinvalidate()Set the main attributes to null to make sure the object is no longer used.booleanisTemporary()Check if this object is temporary (for example, a temporary table).booleanisValid()abstract voidremoveChildrenAndResources(SessionLocal session)Delete all dependent children objects and resources of this object.voidrename(java.lang.String newName)Rename the object.voidsetComment(java.lang.String comment)Change the comment of this object.voidsetModified()Tell the object that is was modified.protected voidsetObjectName(java.lang.String name)voidsetTemporary(boolean temporary)Tell this object that it is temporary or not.java.lang.StringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.h2.util.HasSQL
getTraceSQL
-
-
-
-
Field Detail
-
TABLE_OR_VIEW
public static final int TABLE_OR_VIEW
The object is of the type table or view.- See Also:
- Constant Field Values
-
INDEX
public static final int INDEX
This object is an index.- See Also:
- Constant Field Values
-
USER
public static final int USER
This object is a user.- See Also:
- Constant Field Values
-
SEQUENCE
public static final int SEQUENCE
This object is a sequence.- See Also:
- Constant Field Values
-
TRIGGER
public static final int TRIGGER
This object is a trigger.- See Also:
- Constant Field Values
-
CONSTRAINT
public static final int CONSTRAINT
This object is a constraint (check constraint, unique constraint, or referential constraint).- See Also:
- Constant Field Values
-
SETTING
public static final int SETTING
This object is a setting.- See Also:
- Constant Field Values
-
ROLE
public static final int ROLE
This object is a role.- See Also:
- Constant Field Values
-
RIGHT
public static final int RIGHT
This object is a right.- See Also:
- Constant Field Values
-
FUNCTION_ALIAS
public static final int FUNCTION_ALIAS
This object is an alias for a Java function.- See Also:
- Constant Field Values
-
SCHEMA
public static final int SCHEMA
This object is a schema.- See Also:
- Constant Field Values
-
CONSTANT
public static final int CONSTANT
This object is a constant.- See Also:
- Constant Field Values
-
DOMAIN
public static final int DOMAIN
This object is a domain.- See Also:
- Constant Field Values
-
COMMENT
public static final int COMMENT
This object is a comment.- See Also:
- Constant Field Values
-
AGGREGATE
public static final int AGGREGATE
This object is a user-defined aggregate function.- See Also:
- Constant Field Values
-
SYNONYM
public static final int SYNONYM
This object is a synonym.- See Also:
- Constant Field Values
-
database
protected Database database
The database.
-
trace
protected Trace trace
The trace module.
-
comment
protected java.lang.String comment
The comment (if set).
-
id
private int id
-
objectName
private java.lang.String objectName
-
modificationId
private long modificationId
-
temporary
private boolean temporary
-
-
Constructor Detail
-
DbObject
protected DbObject(Database db, int objectId, java.lang.String name, int traceModuleId)
Initialize some attributes of this object.- Parameters:
db- the databaseobjectId- the object idname- the nametraceModuleId- the trace module id
-
-
Method Detail
-
setModified
public final void setModified()
Tell the object that is was modified.
-
getModificationId
public final long getModificationId()
-
setObjectName
protected final void setObjectName(java.lang.String name)
-
getSQL
public java.lang.String getSQL(int sqlFlags)
Description copied from interface:HasSQLGet the SQL statement of this expression. This may not always be the original SQL statement, specially after optimization.
-
getSQL
public java.lang.StringBuilder getSQL(java.lang.StringBuilder builder, int sqlFlags)Description copied from interface:HasSQLAppends the SQL statement of this object to the specified builder.
-
getChildren
public java.util.ArrayList<DbObject> getChildren()
Get the list of dependent children (for tables, this includes indexes and so on).- Returns:
- the list of children, or
null
-
getDatabase
public final Database getDatabase()
Get the database.- Returns:
- the database
-
getId
public final int getId()
Get the unique object id.- Returns:
- the object id
-
getName
public final java.lang.String getName()
Get the name.- Returns:
- the name
-
invalidate
protected void invalidate()
Set the main attributes to null to make sure the object is no longer used.
-
isValid
public final boolean isValid()
-
getCreateSQLForCopy
public abstract 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- Parameters:
table- the new tablequotedName- the quoted name- Returns:
- the SQL statement
-
getCreateSQLForMeta
public java.lang.String getCreateSQLForMeta()
Construct the CREATE ... SQL statement for this object for meta table.- Returns:
- the SQL statement
-
getCreateSQL
public abstract java.lang.String getCreateSQL()
Construct the CREATE ... SQL statement for this object.- Returns:
- the SQL statement
-
getDropSQL
public java.lang.String getDropSQL()
Construct a DROP ... SQL statement for this object.- Returns:
- the SQL statement
-
getType
public abstract int getType()
Get the object type.- Returns:
- the object type
-
removeChildrenAndResources
public abstract void removeChildrenAndResources(SessionLocal session)
Delete all dependent children objects and resources of this object.- Parameters:
session- the session
-
checkRename
public void checkRename()
Check if renaming is allowed. Does nothing when allowed.
-
rename
public void rename(java.lang.String newName)
Rename the object.- Parameters:
newName- the new name
-
isTemporary
public boolean isTemporary()
Check if this object is temporary (for example, a temporary table).- Returns:
- true if is temporary
-
setTemporary
public void setTemporary(boolean temporary)
Tell this object that it is temporary or not.- Parameters:
temporary- the new value
-
setComment
public void setComment(java.lang.String comment)
Change the comment of this object.- Parameters:
comment- the new comment, or null for no comment
-
getComment
public java.lang.String getComment()
Get the current comment of this object.- Returns:
- the comment, or null if not set
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-