Package com.exedio.cope
Class SchemaInfo
java.lang.Object
com.exedio.cope.SchemaInfo
Returns information about the database schema accessed by cope
- use with care!
This information is needed only, if you want to access the database without cope. In this case you should really know, what you are doing. Any INSERT/UPDATE/DELETE on the database bypassing cope may lead to inconsistent caches. Please note, that the results of all methods may vary, if a cope model is configured for different databases. BEWARE: This class is not part of the stable API of cope. It may change its syntax and/or semantics in the future.
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
getColumnName
(Field<?> field) Returns the name of database column for the field.static <E extends Enum<E>>
intgetColumnValue
(EnumField<E> field, E value) Deprecated.static int
getColumnValue
(Enum<?> value) Returns the value of database column for the field and the given enum value.static String
getConstraintName
(UniqueConstraint constraint) static String
Returns the name of the sequence for generating values for thedefaultToNext
mechanism of the field.static String
getForeignKeyConstraintName
(ItemField<?> field) static String
getModificationCounterColumnName
(Type<?> type) Deprecated.UsegetUpdateCounterColumnName(Type)
insteadstatic String
getPrimaryKeyColumnName
(Type<?> type) Returns the name of primary key column in the database for the type.static int
getPrimaryKeyColumnValue
(Item item) Deprecated.UsegetPrimaryKeyColumnValueL(Item)
instead.static long
Returns the value of primary key column in the database for the item.static String
getPrimaryKeySequenceName
(Type<?> type) Returns the name of the sequence for generating values for theprimary key column
of the type.static String
getSequenceName
(Sequence sequence) Returns the name of the sequence for generating values viaSequence.next()
.static String
getTableName
(Type<?> type) Returns the name of database table for the type.static String
getTypeColumnName
(ItemField<?> field) Returns the name of type column in the database for the field.static String
getTypeColumnName
(Type<?> type) Returns the name of type column in the database for the type.static String
getTypeColumnValue
(Type<?> type) Returns the value to be put into a type column for the type.static String
getUpdateCounterColumnName
(Type<?> type) Returns the name of update counter column in the database for the type.static boolean
Deprecated.UseisUpdateCounterEnabled(Model)
insteadstatic boolean
isUpdateCounterEnabled
(Model model) Deprecated.always returns truestatic Connection
newConnection
(Model model) Its your responsibility to close the returned connection.static String
Quotes a database name.static String
static boolean
supportsCheckConstraints
(Model model) static boolean
supportsNativeDate
(Model model) static boolean
supportsNotNull
(Model model) Deprecated.Always returns true, because all databases are required to support not-null columns.static boolean
supportsSequences
(Model model) Deprecated.Always returns true, because all databases are required to support sequences.static boolean
supportsUniqueViolation
(Model model) Returns whether detectingUniqueViolationException
s fromSQLException
s is supported.static String
-
Method Details
-
newConnection
Its your responsibility to close the returned connection.- Throws:
SQLException
- See Also:
-
quoteName
Quotes a database name. This prevents the name from being interpreted as a SQL keyword. -
supportsCheckConstraints
-
supportsNativeDate
-
supportsUniqueViolation
Returns whether detectingUniqueViolationException
s fromSQLException
s is supported. If not, then cope must issue explicit searches before any insert/update covering a unique constraint. -
getTableName
Returns the name of database table for the type. If not configured otherwise or trimmed to fit into name length restrictions, the name equals theid
of the type. -
getPrimaryKeyColumnName
Returns the name of primary key column in the database for the type. If not configured otherwise the name equals "this". -
getPrimaryKeyColumnValue
Deprecated.UsegetPrimaryKeyColumnValueL(Item)
instead.Returns the value of primary key column in the database for the item. -
getPrimaryKeyColumnValueL
Returns the value of primary key column in the database for the item. -
getPrimaryKeySequenceName
Returns the name of the sequence for generating values for theprimary key column
of the type.- Throws:
IllegalArgumentException
- if there is no such sequence for this type, because primary keys are generated otherwise.
-
getTypeColumnName
Returns the name of type column in the database for the type. If not configured otherwise the name equals "class". Values suitable for this column can be retrieved bygetTypeColumnValue(Type)
.- Throws:
IllegalArgumentException
- if there is no type column for this type, because
contains one type only.Type.getTypesOfInstances()
-
getTypeColumnValue
Returns the value to be put into a type column for the type. Defaults toType.getID()
, but can be overridden byCopeSchemaName
. -
getUpdateCounterColumnName
Returns the name of update counter column in the database for the type. If not configured otherwise the name equals "catch".- Throws:
IllegalArgumentException
- if there is no update counter column for this type, because there are no modifiable (non-final
) fields on the type or its subtypes.
-
getColumnName
Returns the name of database column for the field. If not configured otherwise or trimmed to fit into name length restrictions, the name equals thename
of the field. -
getTypeColumnName
Returns the name of type column in the database for the field. If not configured otherwise or trimmed to fit into name length restrictions, the name equals thename
of the field plus the appendix "Type". Values suitable for this column can be retrieved bygetTypeColumnValue(Type)
.- Throws:
IllegalArgumentException
- if there is no type column for this ItemField, because
contains one type only.getValueType()
.getTypesOfInstances()
-
getForeignKeyConstraintName
-
getColumnValue
Returns the value of database column for the field and the given enum value. Defaults to 10 * (Enum.ordinal()
+ 1 ), but can be overridden byCopeSchemaValue
. -
getDefaultToNextSequenceName
Returns the name of the sequence for generating values for thedefaultToNext
mechanism of the field.- Throws:
IllegalArgumentException
- if there is no such sequence for this field, because values are generated otherwise.
-
getSequenceName
Returns the name of the sequence for generating values viaSequence.next()
. -
getConstraintName
-
search
-
total
-
getColumnValue
Deprecated.UsegetColumnValue(Enum)
instead. -
isUpdateCounterEnabled
Deprecated.always returns true- See Also:
-
isConcurrentModificationDetectionEnabled
Deprecated.UseisUpdateCounterEnabled(Model)
instead -
getModificationCounterColumnName
Deprecated.UsegetUpdateCounterColumnName(Type)
instead -
supportsSequences
Deprecated.Always returns true, because all databases are required to support sequences.- Parameters:
model
- is ignored
-
supportsNotNull
Deprecated.Always returns true, because all databases are required to support not-null columns.
-
getColumnValue(Enum)
instead.