HHH-18185 finally remove @ForeignKey (yay!)

Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
Gavin King 2024-06-15 11:41:38 +02:00 committed by Steve Ebersole
parent 58db271c13
commit cc4656d8f1
23 changed files with 185 additions and 316 deletions

View File

@ -248,7 +248,7 @@ The `@SecondaryTable` annotation is even more interesting:
| `uniqueConstraints` | One or more `@UniqueConstraint` annotations declaring multi-column unique constraints
| `indexes` | One or more `@Index` annotations each declaring an index
| `pkJoinColumns` | One or more `@PrimaryKeyJoinColumn` annotations, specifying <<primary-key-column-mappings,primary key column mappings>>
| `foreignKey` | An `@ForeignKey` annotation specifying the name of the `FOREIGN KEY` constraint on the ``@PrimaryKeyJoinColumn``s
| `foreignKey` | A `@ForeignKey` annotation specifying the name of the `FOREIGN KEY` constraint on the ``@PrimaryKeyJoinColumn``s
|===
[TIP]
@ -322,8 +322,8 @@ Here, there should be a `UNIQUE` constraint on _both_ columns of the association
| `indexes` | One or more `@Index` annotations each declaring an index
| `joinColumns` | One or more `@JoinColumn` annotations, specifying <<join-column-mappings,foreign key column mappings>> to the table of the owning side
| `inverseJoinColumns` | One or more `@JoinColumn` annotations, specifying <<join-column-mappings,foreign key column mappings>> to the table of the unowned side
| `foreignKey` | An `@ForeignKey` annotation specifying the name of the `FOREIGN KEY` constraint on the ``joinColumns``s
| `inverseForeignKey` | An `@ForeignKey` annotation specifying the name of the `FOREIGN KEY` constraint on the ``inverseJoinColumns``s
| `foreignKey` | A `@ForeignKey` annotation specifying the name of the `FOREIGN KEY` constraint on the ``joinColumns``s
| `inverseForeignKey` | A `@ForeignKey` annotation specifying the name of the `FOREIGN KEY` constraint on the ``inverseJoinColumns``s
|===
To better understand these annotations, we must first discuss column mappings in general.

View File

@ -1,41 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.annotations;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* Specifies a foreign key name.
*
* @deprecated use the JPA 2.1 {@link jakarta.persistence.ForeignKey} annotation
*/
@Target({FIELD, METHOD, TYPE})
@Retention(RUNTIME)
@Deprecated( forRemoval = true )
public @interface ForeignKey {
/**
* Name of the foreign key of a {@code OneToMany}, {@code ManyToOne}, or
* {@code OneToOne} association. May also be applied to the owning side a
* {@code ManyToMany} association.
*/
String name();
/**
* Used for the non-owning side of a {@code ManyToMany} association.
* Ignored for other association cardinalities.
*
* @deprecated this member is currently ignored and has no effect
*/
@Deprecated
String inverseName() default "";
}

View File

@ -2108,11 +2108,6 @@ public abstract class CollectionBinder {
collection.setKey( key );
if ( property != null ) {
final org.hibernate.annotations.ForeignKey fk = property.getDirectAnnotationUsage( org.hibernate.annotations.ForeignKey.class );
if ( fk != null && !fk.name().isEmpty() ) {
key.setForeignKeyName( fk.name() );
}
else {
final CollectionTable collectionTableAnn = property.getDirectAnnotationUsage( CollectionTable.class );
if ( collectionTableAnn != null ) {
final ForeignKey foreignKey = collectionTableAnn.foreignKey();
@ -2189,7 +2184,6 @@ public abstract class CollectionBinder {
}
}
}
}
return key;
}
@ -2467,11 +2461,6 @@ public abstract class CollectionBinder {
collection.setManyToManyOrdering( buildOrderByClauseFromHql( hqlOrderBy, collectionEntity ) );
}
final org.hibernate.annotations.ForeignKey fk = property.getDirectAnnotationUsage( org.hibernate.annotations.ForeignKey.class );
if ( fk != null && !fk.name().isEmpty() ) {
element.setForeignKeyName( fk.name() );
}
else {
final JoinTable joinTableAnn = property.getDirectAnnotationUsage( JoinTable.class );
if ( joinTableAnn != null ) {
final ForeignKey inverseForeignKey = joinTableAnn.inverseForeignKey();
@ -2499,7 +2488,6 @@ public abstract class CollectionBinder {
element.setForeignKeyDefinition( nullIfEmpty( foreignKeyDefinition ) );
}
}
}
return element;
}

View File

@ -902,11 +902,6 @@ public class EntityBinder {
|| pkJoinColumns != null && noConstraint( pkJoinColumns.foreignKey(), noConstraintByDefault ) ) {
key.disableForeignKey();
}
else {
final org.hibernate.annotations.ForeignKey fk = clazzToProcess.getDirectAnnotationUsage( org.hibernate.annotations.ForeignKey.class);
if ( fk != null && isNotEmpty( fk.name() ) ) {
key.setForeignKeyName( fk.name() );
}
else {
final ForeignKey foreignKey = clazzToProcess.getDirectAnnotationUsage( ForeignKey.class );
if ( noConstraint( foreignKey, noConstraintByDefault ) ) {
@ -931,7 +926,6 @@ public class EntityBinder {
}
}
}
}
private void bindDiscriminatorColumnToRootPersistentClass(
RootClass rootClass,

View File

@ -621,12 +621,6 @@ public class ToOneBinder {
|| joinColumns != null && noConstraint( joinColumns.foreignKey(), noConstraintByDefault ) ) {
value.disableForeignKey();
}
else {
final org.hibernate.annotations.ForeignKey fk =
property.getDirectAnnotationUsage( org.hibernate.annotations.ForeignKey.class );
if ( fk != null && isNotEmpty( fk.name() ) ) {
value.setForeignKeyName( fk.name() );
}
else {
if ( noConstraint( foreignKey, noConstraintByDefault ) ) {
value.disableForeignKey();
@ -651,7 +645,6 @@ public class ToOneBinder {
}
}
}
}
public static String getReferenceEntityName(PropertyData propertyData, ClassDetails targetEntity) {
return isDefault( targetEntity )

View File

@ -605,7 +605,7 @@ public class ModelBinder {
}
);
keyBinding.sortProperties();
keyBinding.setForeignKeyName( entitySource.getExplicitForeignKeyName() );
setForeignKeyName( keyBinding, entitySource.getExplicitForeignKeyName() );
// model.getKey().setType( new Type( model.getIdentifier() ) );
entityDescriptor.createPrimaryKey();
entityDescriptor.createForeignKey();
@ -1685,7 +1685,7 @@ public class ModelBinder {
);
keyBinding.sortProperties();
keyBinding.setForeignKeyName( secondaryTableSource.getExplicitForeignKeyName() );
setForeignKeyName( keyBinding, secondaryTableSource.getExplicitForeignKeyName() );
// skip creating primary and foreign keys for a subselect.
if ( secondaryTable.getSubselect() == null ) {
@ -2018,7 +2018,7 @@ public class ModelBinder {
}
if ( isNotEmpty( oneToOneSource.getExplicitForeignKeyName() ) ) {
oneToOneBinding.setForeignKeyName( oneToOneSource.getExplicitForeignKeyName() );
setForeignKeyName( oneToOneBinding, oneToOneSource.getExplicitForeignKeyName() );
}
oneToOneBinding.setCascadeDeleteEnabled( oneToOneSource.isCascadeDeleteEnabled() );
@ -2136,9 +2136,7 @@ public class ModelBinder {
manyToOneBinding.setIgnoreNotFound( manyToOneSource.isIgnoreNotFound() );
if ( isNotEmpty( manyToOneSource.getExplicitForeignKeyName() ) ) {
manyToOneBinding.setForeignKeyName( manyToOneSource.getExplicitForeignKeyName() );
}
setForeignKeyName( manyToOneBinding, manyToOneSource.getExplicitForeignKeyName() );
final ManyToOneColumnBinder columnBinder = new ManyToOneColumnBinder(
sourceDocument,
@ -2175,6 +2173,17 @@ public class ModelBinder {
manyToOneBinding.setCascadeDeleteEnabled( manyToOneSource.isCascadeDeleteEnabled() );
}
private static void setForeignKeyName(SimpleValue manyToOneBinding, String foreignKeyName) {
if ( isNotEmpty( foreignKeyName ) ) {
if ( "none".equals( foreignKeyName ) ) {
manyToOneBinding.disableForeignKey();
}
else {
manyToOneBinding.setForeignKeyName( foreignKeyName );
}
}
}
private Property createAnyAssociationAttribute(
MappingDocument sourceDocument,
SingularAttributeSourceAny anyMapping,
@ -3248,7 +3257,7 @@ public class ModelBinder {
getCollectionBinding().getCollectionTable(),
keyVal
);
key.setForeignKeyName( keySource.getExplicitForeignKeyName() );
setForeignKeyName( key, keySource.getExplicitForeignKeyName() );
key.setCascadeDeleteEnabled( getPluralAttributeSource().getKeySource().isCascadeDeleteEnabled() );
//
// final ImplicitJoinColumnNameSource.Nature implicitNamingNature;
@ -3434,7 +3443,7 @@ public class ModelBinder {
: FetchMode.JOIN
);
elementBinding.setForeignKeyName( elementSource.getExplicitForeignKeyName() );
setForeignKeyName( elementBinding, elementSource.getExplicitForeignKeyName() );
elementBinding.setReferencedEntityName( elementSource.getReferencedEntityName() );
if ( isNotEmpty( elementSource.getReferencedEntityAttributeName() ) ) {

View File

@ -278,10 +278,6 @@ public interface HibernateAnnotations {
FilterJoinTableAnnotation.class,
FILTER_JOIN_TABLES
);
OrmAnnotationDescriptor<ForeignKey, ForeignKeyAnnotation> FOREIGN_KEY = new OrmAnnotationDescriptor<>(
ForeignKey.class,
ForeignKeyAnnotation.class
);
OrmAnnotationDescriptor<Formula,FormulaAnnotation> FORMULA = new OrmAnnotationDescriptor<>(
Formula.class,
FormulaAnnotation.class

View File

@ -1,63 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.boot.models.annotations.internal;
import java.lang.annotation.Annotation;
import org.hibernate.boot.models.HibernateAnnotations;
import org.hibernate.models.spi.SourceModelBuildingContext;
import org.jboss.jandex.AnnotationInstance;
import org.hibernate.annotations.ForeignKey;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJandexValue;
@SuppressWarnings({ "ClassExplicitlyAnnotation", "unused" })
@jakarta.annotation.Generated("org.hibernate.orm.build.annotations.ClassGeneratorProcessor")
public class ForeignKeyAnnotation implements ForeignKey {
private String name;
private String inverseName;
public ForeignKeyAnnotation(SourceModelBuildingContext modelContext) {
this.name = "";
this.inverseName = "";
}
public ForeignKeyAnnotation(ForeignKey annotation, SourceModelBuildingContext modelContext) {
name( annotation.name() );
inverseName( annotation.inverseName() );
}
public ForeignKeyAnnotation(AnnotationInstance annotation, SourceModelBuildingContext modelContext) {
name( extractJandexValue( annotation, HibernateAnnotations.FOREIGN_KEY, "name", modelContext ) );
inverseName( extractJandexValue( annotation, HibernateAnnotations.FOREIGN_KEY, "inverseName", modelContext ) );
}
@Override
public Class<? extends Annotation> annotationType() {
return ForeignKey.class;
}
@Override
public String name() {
return name;
}
public void name(String value) {
this.name = value;
}
@Override
public String inverseName() {
return inverseName;
}
public void inverseName(String value) {
this.inverseName = value;
}
}

View File

@ -11,7 +11,6 @@ import java.lang.annotation.Annotation;
import java.sql.Types;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@ -429,11 +428,6 @@ public abstract class SimpleValue implements KeyValue {
}
public void setForeignKeyName(String foreignKeyName) {
// the FK name "none" was a magic value in the hbm.xml
// mapping language that indicated to not create a FK
if ( "none".equals( foreignKeyName ) ) {
foreignKeyEnabled = false;
}
this.foreignKeyName = foreignKeyName;
}

View File

@ -13,14 +13,13 @@ import java.util.Set;
import jakarta.persistence.Column;
import jakarta.persistence.ElementCollection;
import jakarta.persistence.Entity;
import jakarta.persistence.ForeignKey;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.JoinTable;
import jakarta.persistence.Table;
import org.hibernate.annotations.ForeignKey;
@Entity
@Table(name = "CODED_PAIR_SET_HOLDER")
class CodedPairSetHolder implements Serializable {
@ -36,8 +35,10 @@ class CodedPairSetHolder implements Serializable {
private String code;
@ElementCollection
@JoinTable(name = "CODED_PAIR_HOLDER_PAIR_SET", joinColumns = @JoinColumn(name = "CODED_PAIR_HOLDER_ID"))
@ForeignKey(name = "FK_PAIR_SET")
@JoinTable(name = "CODED_PAIR_HOLDER_PAIR_SET",
joinColumns = @JoinColumn(name = "CODED_PAIR_HOLDER_ID"),
foreignKey = @ForeignKey(name = "FK_PAIR_SET"))
private final Set<PersonPair> pairs = new HashSet<PersonPair>(0);
CodedPairSetHolder() {

View File

@ -10,24 +10,23 @@ import java.io.Serializable;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Embeddable;
import jakarta.persistence.FetchType;
import jakarta.persistence.ForeignKey;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import org.hibernate.annotations.ForeignKey;
@Embeddable
class PersonPair implements Serializable {
private static final long serialVersionUID = 4543565503074112720L;
@ManyToOne(optional = false, fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH })
@JoinColumn(name = "LEFT_PERSON_ID", nullable = false, updatable = false)
@ForeignKey(name = "FK_LEFT_PERSON")
@JoinColumn(name = "LEFT_PERSON_ID", nullable = false, updatable = false,
foreignKey = @ForeignKey(name = "FK_LEFT_PERSON"))
private Person left;
@ManyToOne(optional = false, fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH })
@JoinColumn(name = "RIGHT_PERSON_ID", nullable = false, updatable = false)
@ForeignKey(name = "FK_RIGHT_PERSON")
@JoinColumn(name = "RIGHT_PERSON_ID", nullable = false, updatable = false,
foreignKey = @ForeignKey(name = "FK_RIGHT_PERSON"))
private Person right;
PersonPair() {

View File

@ -10,14 +10,14 @@ package org.hibernate.orm.test.annotations.inheritance.joined;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import org.hibernate.annotations.ForeignKey;
import jakarta.persistence.ForeignKey;
import jakarta.persistence.PrimaryKeyJoinColumn;
/**
* @author Emmanuel Bernard
*/
@Entity
@ForeignKey(name = "FK_DOCU_FILE")
@PrimaryKeyJoinColumn(foreignKey = @ForeignKey(name = "FK_DOCU_FILE"))
public class Document extends File {
@Column(nullable = false, name="xsize")
private int size;

View File

@ -11,13 +11,12 @@ import java.io.Serializable;
import java.util.Set;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Entity;
import jakarta.persistence.ForeignKey;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.JoinTable;
import jakarta.persistence.ManyToMany;
import org.hibernate.annotations.ForeignKey;
/**
* Woman knowing several mens
*
@ -50,9 +49,9 @@ public class Woman implements Serializable {
@JoinColumn(name = "manIsElder", referencedColumnName = "elder"),
@JoinColumn(name = "manLastName", referencedColumnName = "lastName"),
@JoinColumn(name = "manFirstName", referencedColumnName = "firstName")
}
)
@ForeignKey(name = "WM_W_FK", inverseName = "WM_M_FK")
},
foreignKey = @ForeignKey(name = "WM_W_FK")
)
public Set<Man> getMens() {
return mens;
}

View File

@ -9,12 +9,12 @@
package org.hibernate.orm.test.annotations.manytoone;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.ForeignKey;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import org.hibernate.annotations.ForeignKey;
/**
* Many to one sample using default mapping values
*
@ -37,7 +37,7 @@ public class Car {
}
@ManyToOne(fetch = FetchType.EAGER)
@ForeignKey(name="BODY_COLOR_FK")
@JoinColumn(foreignKey = @ForeignKey(name="BODY_COLOR_FK"))
public Color getBodyColor() {
return bodyColor;
}

View File

@ -9,6 +9,7 @@
package org.hibernate.orm.test.annotations.manytoone;
import java.util.Set;
import jakarta.persistence.Entity;
import jakarta.persistence.ForeignKey;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
@ -16,8 +17,6 @@ import jakarta.persistence.JoinTable;
import jakarta.persistence.OneToMany;
import jakarta.persistence.OneToOne;
import org.hibernate.annotations.ForeignKey;
/**
* @author Emmanuel Bernard
*/
@ -31,10 +30,9 @@ public class ForestType {
@OneToOne
@JoinTable(name="BiggestRepPerForestType",
joinColumns = @JoinColumn(name="forest_type"),
inverseJoinColumns = @JoinColumn(name="forest")
)
@ForeignKey(name="A_TYP_FK",
inverseName = "A_FOR_FK" //inverse fail cause it involves a Join
inverseJoinColumns = @JoinColumn(name="forest"),
foreignKey = @ForeignKey(name="A_TYP_FK"),
inverseForeignKey = @ForeignKey(name="A_FOR_FK") //inverse fail cause it involves a Join
)
public BiggestForest getBiggestRepresentative() {
return biggestRepresentative;

View File

@ -10,13 +10,13 @@ package org.hibernate.orm.test.annotations.onetomany;
import java.util.ArrayList;
import java.util.List;
import jakarta.persistence.Entity;
import jakarta.persistence.ForeignKey;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.OneToMany;
import jakarta.persistence.OrderBy;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.Immutable;
/**
@ -58,8 +58,8 @@ class City {
}
@OneToMany
@JoinColumn(name = "mainstreetcity_id")
@ForeignKey(name = "CITYSTR_FK")
@JoinColumn(name = "mainstreetcity_id",
foreignKey = @ForeignKey(name = "CITYSTR_FK"))
@OrderBy
@Immutable
public List<Street> getMainStreets() {

View File

@ -15,8 +15,6 @@ import jakarta.persistence.JoinColumn;
import jakarta.persistence.JoinTable;
import jakarta.persistence.OneToMany;
import org.hibernate.annotations.ForeignKey;
/**
* Unidirectional one to many sample
*

View File

@ -139,8 +139,8 @@ public class ConstraintTest extends BaseNonConfigCoreFunctionalTestCase {
public DataPoint dp;
@OneToOne
@org.hibernate.annotations.ForeignKey(name = EXPLICIT_FK_NAME_NATIVE)
@JoinColumn(name = "explicit_native")
@JoinColumn(name = "explicit_native",
foreignKey = @jakarta.persistence.ForeignKey(name = EXPLICIT_FK_NAME_NATIVE))
public DataPoint explicit_native;
@OneToOne

View File

@ -8,6 +8,7 @@ package org.hibernate.orm.test.event.collection.detached;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.ForeignKey;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
@ -26,8 +27,8 @@ public class MultipleCollectionRefEntity1 implements org.hibernate.orm.test.even
private String text;
@ManyToOne
@JoinColumn(name = "MCE_ID", nullable = false, insertable = false, updatable = false)
@org.hibernate.annotations.ForeignKey(name = "FK_RE1_MCE")
@JoinColumn(name = "MCE_ID", nullable = false, insertable = false, updatable = false,
foreignKey = @ForeignKey(name = "FK_RE1_MCE"))
private MultipleCollectionEntity multipleCollectionEntity;
@Column(name = "MCE_ID", insertable = false, updatable = false)

View File

@ -8,6 +8,7 @@ package org.hibernate.orm.test.event.collection.detached;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.ForeignKey;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
@ -26,8 +27,8 @@ public class MultipleCollectionRefEntity2 implements org.hibernate.orm.test.even
private String text;
@ManyToOne
@JoinColumn(name = "MCE_ID", nullable = false, insertable = false, updatable = false)
@org.hibernate.annotations.ForeignKey(name = "FK_RE2_MCE")
@JoinColumn(name = "MCE_ID", nullable = false, insertable = false, updatable = false,
foreignKey = @ForeignKey(name = "FK_RE2_MCE"))
private MultipleCollectionEntity multipleCollectionEntity;
@Column(name = "MCE_ID", insertable = false, updatable = false)

View File

@ -12,10 +12,11 @@ import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import jakarta.persistence.EmbeddedId;
import jakarta.persistence.Entity;
import jakarta.persistence.ForeignKey;
import jakarta.persistence.JoinColumns;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
@ -27,6 +28,7 @@ import org.junit.Test;
import org.jboss.logging.Logger;
import static jakarta.persistence.ConstraintMode.NO_CONSTRAINT;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@ -120,11 +122,10 @@ public class ImplicitCompositeKeyJoinTest {
@Table(name = "Employee")
public class Employee {
@EmbeddedId
@ForeignKey(name = "none")
private EmployeeId id;
@ManyToOne(optional = true)
@ForeignKey(name = "none")
@ManyToOne
@JoinColumns(value = {}, foreignKey = @ForeignKey(NO_CONSTRAINT))
private Employee manager;
}

View File

@ -8,14 +8,15 @@ package org.hibernate.orm.test.envers.entities.collection;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.ForeignKey;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import jakarta.persistence.Version;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.envers.Audited;
import org.hibernate.envers.NotAudited;
@ -35,8 +36,8 @@ public class MultipleCollectionRefEntity1 {
private String text;
@ManyToOne
@JoinColumn(name = "MCE_ID", nullable = false, insertable = false, updatable = false)
@ForeignKey(name = "FK_RE1_MCE")
@JoinColumn(name = "MCE_ID", nullable = false, insertable = false, updatable = false,
foreignKey = @ForeignKey(name = "FK_RE1_MCE"))
@NotAudited
private MultipleCollectionEntity multipleCollectionEntity;

View File

@ -8,6 +8,7 @@ package org.hibernate.orm.test.envers.entities.collection;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.ForeignKey;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
@ -15,7 +16,6 @@ import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Version;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.envers.Audited;
import org.hibernate.envers.NotAudited;
@ -35,8 +35,8 @@ public class MultipleCollectionRefEntity2 {
private String text;
@ManyToOne
@JoinColumn(name = "MCE_ID", nullable = false, insertable = false, updatable = false)
@ForeignKey(name = "FK_RE2_MCE")
@JoinColumn(name = "MCE_ID", nullable = false, insertable = false, updatable = false,
foreignKey = @ForeignKey(name = "FK_RE2_MCE"))
@NotAudited
private MultipleCollectionEntity multipleCollectionEntity;