Top Description Fields Constructors Methods
org.h2.engine

public abstract Class DbObject

extends Object
implements HasSQL
Class Inheritance
All Implemented Interfaces
org.h2.util.HasSQL
Known Direct Subclasses
org.h2.engine.Right, org.h2.engine.RightOwner, org.h2.engine.Setting, org.h2.schema.Schema, org.h2.schema.SchemaObject, org.h2.engine.Comment
Imports
java.util.ArrayList, org.h2.command.ParserBase, org.h2.message.DbException, .Trace, org.h2.table.Table, org.h2.util.HasSQL, .ParserUtil

A database object such as a table, an index, or a user.

Field Summary

Modifier and TypeField and Description
public static final int
AGGREGATE

This object is a user-defined aggregate function.

public static final int
COMMENT

This object is a comment.

protected String
comment

The comment (if set).

public static final int
CONSTANT

This object is a constant.

public static final int
CONSTRAINT

This object is a constraint (check constraint, unique constraint, or referential constraint).

protected Database
database

The database.

public static final int
DOMAIN

This object is a domain.

public static final int
FUNCTION_ALIAS

This object is an alias for a Java function.

private int
public static final int
INDEX

This object is an index.

private long
private String
public static final int
RIGHT

This object is a right.

public static final int
ROLE

This object is a role.

public static final int
SCHEMA

This object is a schema.

public static final int
SEQUENCE

This object is a sequence.

public static final int
SETTING

This object is a setting.

public static final int
SYNONYM

This object is a synonym.

public static final int
TABLE_OR_VIEW

The object is of the type table or view.

private boolean
protected Trace
trace

The trace module.

public static final int
TRIGGER

This object is a trigger.

public static final int
USER

This object is a user.

Constructor Summary

AccessConstructor and Description
protected
DbObject(Database
the database
db
,
int
the object id
objectId
,
String
the name
name
,
int
the trace module id
traceModuleId
)

Initialize some attributes of this object.

Method Summary

Modifier and TypeMethod and Description
public void
checkRename()

Check if renaming is allowed.

public ArrayList<DbObject>

Returns:

the list of children, or null
getChildren
()

Get the list of dependent children (for tables, this includes indexes and so on).

public String

Returns:

the comment, or null if not set
getComment
()

Get the current comment of this object.

public abstract String

Returns:

the SQL statement
getCreateSQL
()

Construct the CREATE ...

public String

Returns:

the SQL statement
getCreateSQLForCopy
(Table
the new table
table
,
String
the quoted name
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

public String

Returns:

the SQL statement
getCreateSQLForMeta
()

Construct the CREATE ...

public final Database

Returns:

the database
getDatabase
()

Get the database.

public String

Returns:

the SQL statement
getDropSQL
()

Construct a DROP ...

public final int

Returns:

the object id
getId
()

Get the unique object id.

public final long
public final String

Returns:

the name
getName
()

Get the name.

public String
getSQL(int
formatting flags
sqlFlags
)

Overrides default org.h2.util.HasSQL.getSQL.

Get the SQL statement of this expression.

public StringBuilder
getSQL(StringBuilder
string builder
builder
,
int
formatting flags
sqlFlags
)

Implements org.h2.util.HasSQL.getSQL.

Appends the SQL statement of this object to the specified builder.

public abstract int

Returns:

the object type
getType
()

Get the object type.

protected void
invalidate()

Set the main attributes to null to make sure the object is no longer used.

public boolean

Returns:

true if is temporary
isTemporary
()

Check if this object is temporary (for example, a temporary table).

public final boolean
public abstract void
removeChildrenAndResources(SessionLocal
the session
session
)

Delete all dependent children objects and resources of this object.

public void
rename(String
the new name
newName
)

Rename the object.

public void
setComment(String
the new comment, or null for no comment
comment
)

Change the comment of this object.

public final void
setModified()

Tell the object that is was modified.

protected final void
public void
setTemporary(boolean
the new value
temporary
)

Tell this object that it is temporary or not.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

AGGREGATEback to summary
public static final int AGGREGATE

This object is a user-defined aggregate function.

COMMENTback to summary
public static final int COMMENT

This object is a comment.

commentback to summary
protected String comment

The comment (if set).

CONSTANTback to summary
public static final int CONSTANT

This object is a constant.

CONSTRAINTback to summary
public static final int CONSTRAINT

This object is a constraint (check constraint, unique constraint, or referential constraint).

databaseback to summary
protected Database database

The database.

DOMAINback to summary
public static final int DOMAIN

This object is a domain.

FUNCTION_ALIASback to summary
public static final int FUNCTION_ALIAS

This object is an alias for a Java function.

idback to summary
private int id
INDEXback to summary
public static final int INDEX

This object is an index.

modificationIdback to summary
private long modificationId
objectNameback to summary
private String objectName
ROLEback to summary
public static final int ROLE

This object is a role.

SCHEMAback to summary
public static final int SCHEMA

This object is a schema.

SEQUENCEback to summary
public static final int SEQUENCE

This object is a sequence.

SETTINGback to summary
public static final int SETTING

This object is a setting.

SYNONYMback to summary
public static final int SYNONYM

This object is a synonym.

TABLE_OR_VIEWback to summary
public static final int TABLE_OR_VIEW

The object is of the type table or view.

temporaryback to summary
private boolean temporary
traceback to summary
protected Trace trace

The trace module.

TRIGGERback to summary
public static final int TRIGGER

This object is a trigger.

USERback to summary
public static final int USER

This object is a user.

Constructor Detail

DbObjectback to summary
protected DbObject(Database db, int objectId, String name, int traceModuleId)

Initialize some attributes of this object.

Parameters
db:Database

the database

objectId:int

the object id

name:String

the name

traceModuleId:int

the trace module id

Method Detail

checkRenameback to summary
public void checkRename()

Check if renaming is allowed. Does nothing when allowed.

getChildrenback to summary
public ArrayList<DbObject> getChildren()

Get the list of dependent children (for tables, this includes indexes and so on).

Returns:ArrayList<DbObject>

the list of children, or null

getCommentback to summary
public String getComment()

Get the current comment of this object.

Returns:String

the comment, or null if not set

getCreateSQLback to summary
public abstract String getCreateSQL()

Construct the CREATE ... SQL statement for this object.

Returns:String

the SQL statement

getCreateSQLForCopyback to summary
public String getCreateSQLForCopy(Table table, 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:Table

the new table

quotedName:String

the quoted name

Returns:String

the SQL statement

getCreateSQLForMetaback to summary
public String getCreateSQLForMeta()

Construct the CREATE ... SQL statement for this object for meta table.

Returns:String

the SQL statement

getDatabaseback to summary
public final Database getDatabase()

Get the database.

Returns:Database

the database

getDropSQLback to summary
public String getDropSQL()

Construct a DROP ... SQL statement for this object.

Returns:String

the SQL statement

getIdback to summary
public final int getId()

Get the unique object id.

Returns:int

the object id

getModificationIdback to summary
public final long getModificationId()
getNameback to summary
public final String getName()

Get the name.

Returns:String

the name

getSQLback to summary
public String getSQL(int sqlFlags)

Overrides default org.h2.util.HasSQL.getSQL.

Doc from org.h2.util.HasSQL.getSQL.

Get the SQL statement of this expression. This may not always be the original SQL statement, specially after optimization.

Parameters
sqlFlags:int

formatting flags

Returns:String

the SQL statement

Annotations
@Override
getSQLback to summary
public StringBuilder getSQL(StringBuilder builder, int sqlFlags)

Implements org.h2.util.HasSQL.getSQL.

Doc from org.h2.util.HasSQL.getSQL.

Appends the SQL statement of this object to the specified builder.

Parameters
builder:StringBuilder

string builder

sqlFlags:int

formatting flags

Returns:StringBuilder

the specified string builder

Annotations
@Override
getTypeback to summary
public abstract int getType()

Get the object type.

Returns:int

the object type

invalidateback to summary
protected void invalidate()

Set the main attributes to null to make sure the object is no longer used.

isTemporaryback to summary
public boolean isTemporary()

Check if this object is temporary (for example, a temporary table).

Returns:boolean

true if is temporary

isValidback to summary
public final boolean isValid()
removeChildrenAndResourcesback to summary
public abstract void removeChildrenAndResources(SessionLocal session)

Delete all dependent children objects and resources of this object.

Parameters
session:SessionLocal

the session

renameback to summary
public void rename(String newName)

Rename the object.

Parameters
newName:String

the new name

setCommentback to summary
public void setComment(String comment)

Change the comment of this object.

Parameters
comment:String

the new comment, or null for no comment

setModifiedback to summary
public final void setModified()

Tell the object that is was modified.

setObjectNameback to summary
protected final void setObjectName(String name)
setTemporaryback to summary
public void setTemporary(boolean temporary)

Tell this object that it is temporary or not.

Parameters
temporary:boolean

the new value

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override