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 StringgetColumnName(Field<?> field) Returns the name of database column for the field.static <E extends Enum<E>>
intgetColumnValue(EnumField<E> field, E value) Deprecated.static intgetColumnValue(Enum<?> value) Returns the value of database column for the field and the given enum value.static StringgetConstraintName(UniqueConstraint constraint) static StringReturns the name of the sequence for generating values for thedefaultToNextmechanism of the field.static StringgetForeignKeyConstraintName(ItemField<?> field) static StringgetModificationCounterColumnName(Type<?> type) Deprecated.UsegetUpdateCounterColumnName(Type)insteadstatic StringgetPrimaryKeyColumnName(Type<?> type) Returns the name of primary key column in the database for the type.static intgetPrimaryKeyColumnValue(Item item) Deprecated.UsegetPrimaryKeyColumnValueL(Item)instead.static longReturns the value of primary key column in the database for the item.static StringgetPrimaryKeySequenceName(Type<?> type) Returns the name of the sequence for generating values for theprimary key columnof the type.static StringgetSequenceName(Sequence sequence) Returns the name of the sequence for generating values viaSequence.next().static StringgetTableName(Type<?> type) Returns the name of database table for the type.static StringgetTypeColumnName(ItemField<?> field) Returns the name of type column in the database for the field.static StringgetTypeColumnName(Type<?> type) Returns the name of type column in the database for the type.static StringgetTypeColumnValue(Type<?> type) Returns the value to be put into a type column for the type.static StringgetUpdateCounterColumnName(Type<?> type) Returns the name of update counter column in the database for the type.static booleanDeprecated.UseisUpdateCounterEnabled(Model)insteadstatic booleanisUpdateCounterEnabled(Model model) Deprecated.always returns truestatic ConnectionnewConnection(Model model) Its your responsibility to close the returned connection.static StringQuotes a database name.static Stringstatic booleansupportsCheckConstraints(Model model) static booleansupportsNativeDate(Model model) static booleansupportsNotNull(Model model) Deprecated.Always returns true, because all databases are required to support not-null columns.static booleansupportsSequences(Model model) Deprecated.Always returns true, because all databases are required to support sequences.static booleansupportsUniqueViolation(Model model) Returns whether detectingUniqueViolationExceptions fromSQLExceptions 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 detectingUniqueViolationExceptions fromSQLExceptions 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 theidof 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 columnof 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, becausecontains 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 thenameof 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 thenameof 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, becausecontains 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 thedefaultToNextmechanism 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.