注释接口 JoinTable


@Retention(RUNTIME) @Target(allowedTargets=PROPERTY) @Target(METHOD) public @interface JoinTable
This annotation should typically be used with ManyToMany, but it can also be used with ManyToOne or OneToOne.

The annotation cannot be used by the reversed(with `mappedBy`) property

The middle table should only have two columns:

  • one pointing to the foreign key of the entity in which the current property resides
  • and the other pointing to the foreign key of the entity returned by the current property
The two foreign keys are combined to serve as the primary key.
  • For many-to-many associations, if you want to add more business fields to the middle table, this annotation is no longer applicable, please use ManyToManyView
  • For many-to-one associations, unique constraint should be added to the foreign key pointing to the entity in which the current property resides.
  • For one-to-one associations, unique constraint should be added to each foreign key.
  • 元素详细资料

    • name

      String name
      Middle table name.

      If it is not specified, it will be determined by Jimmer. For example, If the current entity is `Book` and the target entity is `Author`, the default middle table name is `BOOK_AUTHOR_MAPPING`

      默认值:
      ""
    • joinColumnName

      String joinColumnName
      The column name of the foreign key of the entity in which the current property resides

      This argument cannot be specified together with joinColumns()

      It is better than joinColumns() when foreign key is real database constraint and has only one column
      默认值:
      ""
    • inverseJoinColumnName

      String inverseJoinColumnName
      The column names of the foreign key of the entity returned by the current property

      This argument cannot be specified together with inverseJoinColumns()

      It is better than inverseJoinColumns() when foreign key is real database constraint and has only one column
      默认值:
      ""
    • joinColumns

      JoinColumn[] joinColumns
      The column name of the foreign key of the entity in which the current property resides

      This argument cannot be specified together with joinColumnName()

      This argument must be configured when foreign key * is not real database constraint or has only more than 1 columns
      默认值:
      {}
    • inverseJoinColumns

      JoinColumn[] inverseJoinColumns
      The column names of the foreign key of the entity returned by the current property

      This argument cannot be specified together with inverseJoinColumnName()

      This argument must be configured when foreign key is not real database constraint or has only more than 1 column
      默认值:
      {}
    • readonly

      boolean readonly
      默认值:
      false
    • preventDeletionBySource

      boolean preventDeletionBySource
      默认值:
      false
    • preventDeletionByTarget

      boolean preventDeletionByTarget
      默认值:
      false
    • cascadeDeletedBySource

      boolean cascadeDeletedBySource
      Should the middle table row be cascade deleted when the source object is deleted.

      This argument cannot be true when `preventDeletionBySource` is true

      This argument is used config the database-level cascade deletion for foreign key in middle table. for foreign key in entity table, please view DissociateAction.LAX

      返回:
      Should the middle table row be cascade deleted when the source object is deleted.
      默认值:
      false
    • cascadeDeletedByTarget

      boolean cascadeDeletedByTarget
      Should the middle table row be cascade deleted when the target object is deleted.

      This argument cannot be true when `preventDeletionByTarget` is true

      This argument is used config the database-level cascade deletion for foreign key in middle table. for foreign key in entity table, please view DissociateAction.LAX

      返回:
      Should the middle table row be cascade deleted when the target object is deleted.
      默认值:
      false
    • deletedWhenEndpointIsLogicallyDeleted

      boolean deletedWhenEndpointIsLogicallyDeleted
      In general, if entities on either side support logical deletion, middle tables should also support logical deletion. Otherwise, error will be raised.

      When entity on either side is logically deleted, the rows of middle tables should be logically deleted too.

      However, if you don't want intermediate table records to support soft deletion, turn this switch on. When an object at either side is logically deleted, the corresponding middle table records will be physically deleted.

      默认值:
      false
    • filter

      默认值:
      @org.babyfish.jimmer.sql.JoinTable.JoinTableFilter(columnName="<illegal-column-name>", values={})
    • logicalDeletedFilter

      JoinTable.LogicalDeletedFilter logicalDeletedFilter
      默认值:
      @org.babyfish.jimmer.sql.JoinTable.LogicalDeletedFilter(columnName="<illegal-column-name>")
    • keyUniqueConstraint

      KeyUniqueConstraint keyUniqueConstraint
      默认值:
      @org.babyfish.jimmer.sql.KeyUniqueConstraint(noMoreUniqueConstraints=true)