Package io.ebean.annotation
Annotation Type DbForeignKey
-
@Retention(RUNTIME) @Target(FIELD) public @interface DbForeignKey
Specify how a foreign key constraint should be defined.We can specify if a constraint should not be defined at all or control the onDelete and onUpdate modes used.
Example: On delete cascade
{@code
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description booleannoConstraintSet to true when we do not wish any foreign key constraint to be created.booleannoIndexSet to true when we do not wish an index to be created on the foreign key column(s).ConstraintModeonDeleteSpecify the onDelete mode.ConstraintModeonUpdateDo NOT change this - seriously, don't do it.
-
-
-
Element Detail
-
onDelete
ConstraintMode onDelete
Specify the onDelete mode. Typically will default to RESTRICT (aka No Action).- Default:
- io.ebean.annotation.ConstraintMode.RESTRICT
-
-
-
onUpdate
ConstraintMode onUpdate
Do NOT change this - seriously, don't do it.Your primary keys should never change by design. We should orientate the design to support primary keys that change (and instead find better non mutating primary keys). Oracle go to the point of actively not supporting "on update" for this reason.
So yes, we can specify the onUpdate mode but I don't expect anyone to change this.
- Default:
- io.ebean.annotation.ConstraintMode.RESTRICT
-
-
-
noConstraint
boolean noConstraint
Set to true when we do not wish any foreign key constraint to be created. When this is set to true the onDelete and onUpdate have no effect.- Default:
- false
-
-
-
noIndex
boolean noIndex
Set to true when we do not wish an index to be created on the foreign key column(s).- Default:
- false
-
-