Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add options member to elements which result in DDL generation #485

Merged
merged 1 commit into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion api/src/main/java/jakarta/persistence/CheckConstraint.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
public @interface CheckConstraint {

/**
* (Optional) The name of the constraint; defaults to a provider-generated name.
* (Optional) The name of the constraint.
* <p> Defaults to a provider-generated name.
*/
String name() default "";

Expand All @@ -43,4 +44,11 @@
*/
String constraint();

/**
* (Optional) A SQL fragment appended to the generated DDL
* which creates this constraint.
*
* @since 3.2
*/
String options() default "";
}
9 changes: 9 additions & 0 deletions api/src/main/java/jakarta/persistence/CollectionTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,13 @@
* @since 2.1
*/
Index[] indexes() default {};

/**
* (Optional) A SQL fragment appended to the generated DDL
* statement which creates this table. This is only used if
* table generation is in effect.
*
* @since 3.2
*/
String options() default "";
}
9 changes: 9 additions & 0 deletions api/src/main/java/jakarta/persistence/Column.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,15 @@
*/
String columnDefinition() default "";

/**
* (Optional) A SQL fragment appended to the generated DDL
* which declares this column. May not be used in
* conjunction with {@link #columnDefinition()}.
*
* @since 3.2
*/
String options() default "";

/**
* (Optional) The name of the table that contains the column.
* If absent the column is assumed to be in the primary table.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@
*/
String columnDefinition() default "";

/**
* (Optional) A SQL fragment appended to the generated DDL
* which declares this column. May not be used in
* conjunction with {@link #columnDefinition()}.
*
* @since 3.2
*/
String options() default "";

/**
* (Optional) The column length for String-based discriminator types.
* Ignored for other discriminator types.
Expand Down
45 changes: 27 additions & 18 deletions api/src/main/java/jakarta/persistence/ForeignKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,33 +63,42 @@
public @interface ForeignKey {

/**
* (Optional) The name of the foreign key constraint. If this
* is not specified, it defaults to a provider-generated name.
* (Optional) The name of the foreign key constraint.
* <p> Defaults to a provider-generated name.
*/
String name() default "";

/**
* (Optional) Used to specify whether a foreign key constraint should be
* generated when schema generation is in effect.
* <p>
* A value of <code>CONSTRAINT</code> will cause the persistence
* provider to generate a foreign key constraint. If the
* <code>foreignKeyDefinition</code> element is not specified, the
* provider will generate a constraint whose update
* and delete actions it determines most appropriate for the
* join column(s) to which the foreign key annotation is applied.
* <p>
* A value of <code>NO_CONSTRAINT</code> will result in no
* constraint being generated.
* <p>
* A value of <code>PROVIDER_DEFAULT</code> will result in the
* provider's default behavior (which may or may not result
* in the generation of a constraint for the given join column(s).
* (Optional) Used to specify whether a foreign key constraint
* should be generated when schema generation is in effect.
* <ul>
* <li><code>CONSTRAINT</code> specifies that the persistence
* provider must generate a foreign key constraint. If the
* <code>foreignKeyDefinition</code> element is not specified,
* the provider will generate a constraint whose update and
* delete actions it determines most appropriate for the join
* column or columns to which the foreign key annotation is
* applied.
* <li><code>NO_CONSTRAINT</code> specifies that no constraint
* should be generated.
* <li><code>PROVIDER_DEFAULT</code> selects the default
* behavior of the provider, which may or may not result in
* generation of a constraint.
* </ul>
*/
ConstraintMode value() default CONSTRAINT;

/**
* (Optional) The foreign key constraint definition.
*/
String foreignKeyDefinition() default "";

/**
* (Optional) A SQL fragment appended to the generated DDL
* which creates this foreign key. May not be used in
* conjunction with {@link #foreignKeyDefinition()}.
*
* @since 3.2
*/
String options() default "";
}
12 changes: 10 additions & 2 deletions api/src/main/java/jakarta/persistence/Index.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,13 @@
public @interface Index {

/**
* (Optional) The name of the index; defaults to a provider-generated name.
* (Optional) The name of the index.
* <p> Defaults to a provider-generated name.
*/
String name() default "";

/**
* (Required) The names of the columns to be included in the index,
* (Required) The names of the columns included in the index,
* in order.
*/
String columnList();
Expand All @@ -66,4 +67,11 @@
*/
boolean unique() default false;

/**
* (Optional) A SQL fragment appended to the generated DDL
* which creates this index.
*
* @since 3.2
*/
String options() default "";
}
9 changes: 9 additions & 0 deletions api/src/main/java/jakarta/persistence/JoinColumn.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,15 @@
*/
String columnDefinition() default "";

/**
* (Optional) A SQL fragment appended to the generated DDL
* which declares this column. May not be used in
* conjunction with {@link #columnDefinition()}.
*
* @since 3.2
*/
String options() default "";

/**
* (Optional) The name of the table that contains
* the column. If a table is not specified, the column
Expand Down
9 changes: 9 additions & 0 deletions api/src/main/java/jakarta/persistence/JoinTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,13 @@
* @since 3.2
*/
String comment() default "";

/**
* (Optional) A SQL fragment appended to the generated DDL
* statement which creates this table. This is only used if
* table generation is in effect.
*
* @since 3.2
*/
String options() default "";
}
169 changes: 88 additions & 81 deletions api/src/main/java/jakarta/persistence/MapKeyColumn.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,85 +50,92 @@
@Retention(RUNTIME)
public @interface MapKeyColumn {

/**
* (Optional) The name of the map key column. The table in which it is found
* depends upon the context. If the map key is for an element collection,
* the map key column is in the collection table for the map value. If the
* map key is for a ManyToMany entity relationship or for a OneToMany entity
* relationship using a join table, the map key column is in a join table.
* If the map key is for a OneToMany entity relationship using a foreign key
* mapping strategy, the map key column is in the table of the entity that
* is the value of the map.
* <p> Defaults to the concatenation of the following: the name of
* the referencing relationship field or property; "_"; "<code>KEY</code>".
*/
String name() default "";

/**
* (Optional) Whether the column is a unique key. This is a
* shortcut for the <code>UniqueConstraint</code> annotation
* at the table level and is useful for when the unique key
* constraint corresponds to only a single column. This
* constraint applies in addition to any constraint entailed
* by primary key mapping and to constraints specified at the
* table level.
*/
boolean unique() default false;

/** (Optional) Whether the database column is nullable. */
boolean nullable() default false;

/**
* (Optional) Whether the column is included in SQL INSERT statements
* generated by the persistence provider.
*/
boolean insertable() default true;

/**
* (Optional) Whether the column is included in SQL UPDATE statements
* generated by the persistence provider.
*/
boolean updatable() default true;

/**
* (Optional) The SQL fragment that is used when generating the DDL for the
* column.
* <p> Defaults to the generated SQL to create a
* column of the inferred type.
*
*/
String columnDefinition() default "";

/** (Optional) The name of the table that contains the column.
*
* <p> Defaults: If the map key is for an element collection,
* the name of the collection table for the map value. If the
* map key is for a OneToMany or ManyToMany entity
* relationship using a join table, the name of the join table
* for the map. If the map key is for a OneToMany entity
* relationship using a foreign key mapping strategy, the name
* of the primary table of the entity that is the value of the
* map.
*/
String table() default "";

/**
* (Optional) The column length. (Applies only if a string-valued column is
* used.)
*/
int length() default 255;

/**
* (Optional) The precision for a decimal (exact numeric) column. (Applies
* only if a decimal column is used.)
*
*<p> Default: 0. (The value must be set by the developer.)
*/
int precision() default 0; // decimal precision

/**
* (Optional) The scale for a decimal (exact numeric) column. (Applies only
* if a decimal column is used.)
*/
int scale() default 0; // decimal scale
/**
* (Optional) The name of the map key column. The table in which it is found
* depends upon the context. If the map key is for an element collection,
* the map key column is in the collection table for the map value. If the
* map key is for a ManyToMany entity relationship or for a OneToMany entity
* relationship using a join table, the map key column is in a join table.
* If the map key is for a OneToMany entity relationship using a foreign key
* mapping strategy, the map key column is in the table of the entity that
* is the value of the map.
* <p> Defaults to the concatenation of the following: the name of
* the referencing relationship field or property; "_"; "<code>KEY</code>".
*/
String name() default "";

/**
* (Optional) Whether the column is a unique key. This is a
* shortcut for the <code>UniqueConstraint</code> annotation
* at the table level and is useful for when the unique key
* constraint corresponds to only a single column. This
* constraint applies in addition to any constraint entailed
* by primary key mapping and to constraints specified at the
* table level.
*/
boolean unique() default false;

/** (Optional) Whether the database column is nullable. */
boolean nullable() default false;

/**
* (Optional) Whether the column is included in SQL INSERT statements
* generated by the persistence provider.
*/
boolean insertable() default true;

/**
* (Optional) Whether the column is included in SQL UPDATE statements
* generated by the persistence provider.
*/
boolean updatable() default true;

/**
* (Optional) The SQL fragment that is used when generating the DDL for the
* column.
* <p> Defaults to the generated SQL to create a
* column of the inferred type.
*/
String columnDefinition() default "";

/**
* (Optional) A SQL fragment appended to the generated DDL
* which declares this column. May not be used in
* conjunction with {@link #columnDefinition()}.
*
* @since 3.2
*/
String options() default "";

/** (Optional) The name of the table that contains the column.
* <p> Defaults: If the map key is for an element collection,
* the name of the collection table for the map value. If the
* map key is for a OneToMany or ManyToMany entity
* relationship using a join table, the name of the join table
* for the map. If the map key is for a OneToMany entity
* relationship using a foreign key mapping strategy, the name
* of the primary table of the entity that is the value of the
* map.
*/
String table() default "";

/**
* (Optional) The column length. (Applies only if a string-valued column is
* used.)
*/
int length() default 255;

/**
* (Optional) The precision for a decimal (exact numeric) column. (Applies
* only if a decimal column is used.)
*
*<p> Default: 0. (The value must be set by the developer.)
*/
int precision() default 0; // decimal precision

/**
* (Optional) The scale for a decimal (exact numeric) column. (Applies only
* if a decimal column is used.)
*/
int scale() default 0; // decimal scale
}
Loading