Skip to content

Commit

Permalink
add check and comment to @column and @table
Browse files Browse the repository at this point in the history
rough draft only
  • Loading branch information
gavinking committed Sep 8, 2022
1 parent 31d2cf0 commit 4a1718a
Show file tree
Hide file tree
Showing 6 changed files with 150 additions and 0 deletions.
16 changes: 16 additions & 0 deletions api/src/main/java/jakarta/persistence/Column.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,20 @@
* (Applies only if a decimal column is used.)
*/
int scale() default 0;

/**
* (Optional) A check constraint to be applied to the column.
* This is only used if table generation is in effect.
*
* @since 3.2
*/
String check() default "";

/**
* (Optional) A comment to be applied to the column.
* This is only used if table generation is in effect.
*
* @since 3.2
*/
String comment() default "";
}
16 changes: 16 additions & 0 deletions api/src/main/java/jakarta/persistence/JoinColumn.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,20 @@
* @since 2.1
*/
ForeignKey foreignKey() default @ForeignKey(PROVIDER_DEFAULT);

/**
* (Optional) A check constraint to be applied to the column.
* This is only used if table generation is in effect.
*
* @since 3.2
*/
String check() default "";

/**
* (Optional) A comment to be applied to the column.
* This is only used if table generation is in effect.
*
* @since 3.2
*/
String comment() default "";
}
16 changes: 16 additions & 0 deletions api/src/main/java/jakarta/persistence/JoinTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,20 @@
* @since 2.1
*/
Index[] indexes() default {};

/**
* (Optional) A check constraint to be applied to the table.
* This is only used if table generation is in effect.
*
* @since 3.2
*/
String check() default "";

/**
* (Optional) A comment to be applied to the table.
* This is only used if table generation is in effect.
*
* @since 3.2
*/
String comment() default "";
}
16 changes: 16 additions & 0 deletions api/src/main/java/jakarta/persistence/SecondaryTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,20 @@
* @since 2.1
*/
Index[] indexes() default {};

/**
* (Optional) A check constraint to be applied to the table.
* This is only used if table generation is in effect.
*
* @since 3.2
*/
String check() default "";

/**
* (Optional) A comment to be applied to the table.
* This is only used if table generation is in effect.
*
* @since 3.2
*/
String comment() default "";
}
16 changes: 16 additions & 0 deletions api/src/main/java/jakarta/persistence/Table.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,20 @@
* @since 2.1
*/
Index[] indexes() default {};

/**
* (Optional) A check constraint to be applied to the table.
* This is only used if table generation is in effect.
*
* @since 3.2
*/
String check() default "";

/**
* (Optional) A comment to be applied to the table.
* This is only used if table generation is in effect.
*
* @since 3.2
*/
String comment() default "";
}
70 changes: 70 additions & 0 deletions spec/src/main/asciidoc/ch11-metadata-for-or-mapping.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,8 @@ public @interface Column {
int length() default 255;
int precision() default 0; // decimal precision
int scale() default 0; // decimal scale
String check() default "";
String comment() default "";
}
----

Expand Down Expand Up @@ -925,6 +927,18 @@ if a string-valued column is used.)
|(Optional) The scale for a decimal (exact
numeric) column. (Applies only if a decimal column is used.)
|0

|String
|check
|(Optional) Check constraint for the column. This is
only used if table generation is in effect.
|No check constraint

|String
|comment
|(Optional) Comment for the column. This is
only used if table generation is in effect.
|No comment
|===

*Example 1:*
Expand Down Expand Up @@ -2178,6 +2192,8 @@ public @interface JoinColumn {
String columnDefinition() default "";
String table() default "";
ForeignKey foreignKey() default @ForeignKey(PROVIDER_DEFAULT);
String check() default "";
String comment() default "";
}
----

Expand Down Expand Up @@ -2272,6 +2288,18 @@ join is for an element collection, the name of the collection table.
|(Optional) The foreign key constraint for
the join column. This is used only if table generation is in effect.
|Provider's default

|String
|check
|(Optional) Check constraint for the column. This is
only used if table generation is in effect.
|No check constraint

|String
|comment
|(Optional) Comment for the column. This is
only used if table generation is in effect.
|No comment
|===

*Example 1:*
Expand Down Expand Up @@ -2407,6 +2435,8 @@ public @interface JoinTable {
ForeignKey inverseForeignKey() default @ForeignKey(PROVIDER_DEFAULT);
UniqueConstraint[] uniqueConstraints() default {};
Index[] indexes() default {};
String check() default "";
String comment() default "";
}
----

Expand Down Expand Up @@ -2471,6 +2501,18 @@ effect.
|(Optional) Indexes for the table. These are
only used if table generation is in effect.
|No additional indexes

|String
|check
|(Optional) Check constraint for the table. This is
only used if table generation is in effect.
|No check constraint

|String
|comment
|(Optional) Comment for the table. This is
only used if table generation is in effect.
|No comment
|===

*Example:*
Expand Down Expand Up @@ -4541,6 +4583,8 @@ public @interface SecondaryTable {
ForeignKey foreignKey() default @ForeignKey(PROVIDER_DEFAULT);
UniqueConstraint[] uniqueConstraints() default {};
Index[] indexes() default {};
String check() default "";
String comment() default "";
}
----

Expand Down Expand Up @@ -4589,6 +4633,18 @@ entailed by primary key mappings.
|(Optional) Indexes for the table. These are
only used if table generation is in effect.
|No additional indexes

|String
|check
|(Optional) Check constraint for the table. This is
only used if table generation is in effect.
|No check constraint

|String
|comment
|(Optional) Comment for the table. This is
only used if table generation is in effect.
|No comment
|===

*Example 1:* Single secondary table with a single primary key column.
Expand Down Expand Up @@ -4806,6 +4862,8 @@ public @interface Table {
String schema() default "";
UniqueConstraint[] uniqueConstraints() default {};
Index[] indexes() default {};
String check() default "";
String comment() default "";
}
----

Expand Down Expand Up @@ -4844,6 +4902,18 @@ constraints
|(Optional) Indexes for the table. These are
only used if table generation is in effect.
|No additional indexes

|String
|check
|(Optional) Check constraint for the table. This is
only used if table generation is in effect.
|No check constraint

|String
|comment
|(Optional) Comment for the table. This is
only used if table generation is in effect.
|No comment
|===

*Example:*
Expand Down

0 comments on commit 4a1718a

Please sign in to comment.