.
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg.annotations;
+package org.hibernate.boot.model;
import jakarta.persistence.NamedEntityGraph;
import static org.hibernate.internal.util.StringHelper.isNotEmpty;
/**
- * Models the definition of a {@link NamedEntityGraph} annotation
+ * Models a {@linkplain NamedEntityGraph @NamedEntityGraph}
*
* @author Steve Ebersole
*/
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/TruthValue.java b/hibernate-core/src/main/java/org/hibernate/boot/model/TruthValue.java
index d9bc1707ff..b698d6727e 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/model/TruthValue.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/TruthValue.java
@@ -8,9 +8,10 @@ package org.hibernate.boot.model;
/**
* An enumeration of truth values.
- *
- * Yes this *could* be handled with Boolean, but then you run into potential
- * problems with unwanted auto-unboxing.
+ *
+ * @implNote Yes this *could* be handled with Boolean, but then
+ * you run into potential problems with unwanted auto-unboxing
+ * and {@linkplain NullPointerException NPE}.
*
* @author Steve Ebersole
*/
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/TypeBeanInstanceProducer.java b/hibernate-core/src/main/java/org/hibernate/boot/model/TypeBeanInstanceProducer.java
index 9107cf44be..d40e40ecb9 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/model/TypeBeanInstanceProducer.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/TypeBeanInstanceProducer.java
@@ -17,10 +17,12 @@ import org.hibernate.type.spi.TypeBootstrapContext;
import org.hibernate.type.spi.TypeConfiguration;
/**
+ * BeanInstanceProducer implementation for building beans related with
+ * custom types.
+ *
* @author Christian Beikov
*/
public class TypeBeanInstanceProducer implements BeanInstanceProducer, TypeBootstrapContext {
-
private final TypeConfiguration typeConfiguration;
public TypeBeanInstanceProducer(TypeConfiguration typeConfiguration) {
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/TypeDefinition.java b/hibernate-core/src/main/java/org/hibernate/boot/model/TypeDefinition.java
index 7456daef54..c48d70aa09 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/model/TypeDefinition.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/TypeDefinition.java
@@ -138,7 +138,7 @@ public class TypeDefinition implements Serializable {
MetadataBuildingContext context) {
final BootstrapContext bootstrapContext = context.getBootstrapContext();
final TypeConfiguration typeConfiguration = bootstrapContext.getTypeConfiguration();
- final BeanInstanceProducer instanceProducer = bootstrapContext.getBeanInstanceProducer();
+ final BeanInstanceProducer instanceProducer = bootstrapContext.getCustomTypeProducer();
final boolean isKnownType = Type.class.isAssignableFrom( typeImplementorClass )
|| UserType.class.isAssignableFrom( typeImplementorClass );
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/convert/internal/ConverterHelper.java b/hibernate-core/src/main/java/org/hibernate/boot/model/convert/internal/ConverterHelper.java
index 480a220939..0dab1335f3 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/model/convert/internal/ConverterHelper.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/convert/internal/ConverterHelper.java
@@ -17,8 +17,8 @@ import org.hibernate.HibernateException;
import org.hibernate.annotations.common.reflection.ReflectionManager;
import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.boot.internal.ClassmateContext;
+import org.hibernate.boot.model.internal.HCANNHelper;
import org.hibernate.boot.spi.MetadataBuildingContext;
-import org.hibernate.cfg.annotations.HCANNHelper;
import org.hibernate.internal.util.GenericsHelper;
import org.hibernate.internal.util.type.PrimitiveWrapperHelper;
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/convert/spi/ConverterRegistry.java b/hibernate-core/src/main/java/org/hibernate/boot/model/convert/spi/ConverterRegistry.java
index 33dc6e176e..2b523fe2d2 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/model/convert/spi/ConverterRegistry.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/convert/spi/ConverterRegistry.java
@@ -6,10 +6,13 @@
*/
package org.hibernate.boot.model.convert.spi;
-import jakarta.persistence.AttributeConverter;
import org.hibernate.Incubating;
+import jakarta.persistence.AttributeConverter;
+
/**
+ * AttributeConverter registrations
+ *
* @author Gavin King
*/
@Incubating
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/AbstractPropertyHolder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/AbstractPropertyHolder.java
similarity index 99%
rename from hibernate-core/src/main/java/org/hibernate/cfg/AbstractPropertyHolder.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/AbstractPropertyHolder.java
index 8468e3e26d..113e3f1181 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/AbstractPropertyHolder.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/AbstractPropertyHolder.java
@@ -2,9 +2,9 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
+package org.hibernate.boot.model.internal;
import java.lang.annotation.Annotation;
import java.util.ArrayList;
@@ -12,17 +12,6 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import jakarta.persistence.AssociationOverride;
-import jakarta.persistence.AssociationOverrides;
-import jakarta.persistence.AttributeOverride;
-import jakarta.persistence.AttributeOverrides;
-import jakarta.persistence.Column;
-import jakarta.persistence.Embeddable;
-import jakarta.persistence.Entity;
-import jakarta.persistence.ForeignKey;
-import jakarta.persistence.JoinColumn;
-import jakarta.persistence.JoinTable;
-import jakarta.persistence.MappedSuperclass;
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
@@ -44,7 +33,19 @@ import org.hibernate.usertype.internal.AbstractTimeZoneStorageCompositeUserType;
import org.jboss.logging.Logger;
-import static org.hibernate.cfg.AnnotationBinder.useColumnForTimeZoneStorage;
+import jakarta.persistence.AssociationOverride;
+import jakarta.persistence.AssociationOverrides;
+import jakarta.persistence.AttributeOverride;
+import jakarta.persistence.AttributeOverrides;
+import jakarta.persistence.Column;
+import jakarta.persistence.Embeddable;
+import jakarta.persistence.Entity;
+import jakarta.persistence.ForeignKey;
+import jakarta.persistence.JoinColumn;
+import jakarta.persistence.JoinTable;
+import jakarta.persistence.MappedSuperclass;
+
+import static org.hibernate.boot.model.internal.AnnotationBinder.useColumnForTimeZoneStorage;
/**
* @author Emmanuel Bernard
@@ -331,6 +332,7 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
return override;
}
+ @Override
public ForeignKey getOverriddenForeignKey(String propertyName) {
ForeignKey result = getExactOverriddenForeignKey( propertyName );
if ( result == null && propertyName.contains( ".collection&&element." ) ) {
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/AggregateComponentBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/AggregateComponentBinder.java
similarity index 97%
rename from hibernate-core/src/main/java/org/hibernate/cfg/AggregateComponentBinder.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/AggregateComponentBinder.java
index fb138dd7f1..5b1284ef25 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/AggregateComponentBinder.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/AggregateComponentBinder.java
@@ -2,9 +2,9 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
+package org.hibernate.boot.model.internal;
import java.util.List;
@@ -15,7 +15,7 @@ import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.boot.spi.InFlightMetadataCollector;
import org.hibernate.boot.spi.MetadataBuildingContext;
-import org.hibernate.cfg.annotations.BasicValueBinder;
+import org.hibernate.boot.spi.PropertyData;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.mapping.AggregateColumn;
import org.hibernate.mapping.BasicValue;
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/AggregateComponentSecondPass.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/AggregateComponentSecondPass.java
similarity index 98%
rename from hibernate-core/src/main/java/org/hibernate/cfg/AggregateComponentSecondPass.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/AggregateComponentSecondPass.java
index b1ae22c605..12ff5820b8 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/AggregateComponentSecondPass.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/AggregateComponentSecondPass.java
@@ -2,9 +2,9 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
+package org.hibernate.boot.model.internal;
import java.util.ArrayList;
import java.util.List;
@@ -20,6 +20,7 @@ import org.hibernate.boot.model.relational.Database;
import org.hibernate.boot.model.relational.Namespace;
import org.hibernate.boot.spi.InFlightMetadataCollector;
import org.hibernate.boot.spi.MetadataBuildingContext;
+import org.hibernate.boot.spi.SecondPass;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.aggregate.AggregateSupport;
import org.hibernate.internal.util.ReflectHelper;
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/AnnotatedClassType.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/AnnotatedClassType.java
similarity index 83%
rename from hibernate-core/src/main/java/org/hibernate/cfg/AnnotatedClassType.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/AnnotatedClassType.java
index 0e5cc94469..bcab086191 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/AnnotatedClassType.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/AnnotatedClassType.java
@@ -2,9 +2,9 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
+package org.hibernate.boot.model.internal;
import org.hibernate.annotations.Imported;
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/AnnotatedColumn.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/AnnotatedColumn.java
similarity index 98%
rename from hibernate-core/src/main/java/org/hibernate/cfg/AnnotatedColumn.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/AnnotatedColumn.java
index 8b7dcd88d8..bfaa9420d2 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/AnnotatedColumn.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/AnnotatedColumn.java
@@ -2,9 +2,9 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
+package org.hibernate.boot.model.internal;
import java.util.Map;
@@ -12,10 +12,10 @@ import org.hibernate.AnnotationException;
import org.hibernate.MappingException;
import org.hibernate.annotations.Check;
import org.hibernate.annotations.ColumnDefault;
-import org.hibernate.annotations.GeneratedColumn;
import org.hibernate.annotations.ColumnTransformer;
import org.hibernate.annotations.ColumnTransformers;
import org.hibernate.annotations.Comment;
+import org.hibernate.annotations.GeneratedColumn;
import org.hibernate.annotations.Index;
import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.boot.model.naming.Identifier;
@@ -25,7 +25,7 @@ import org.hibernate.boot.model.naming.ObjectNameNormalizer;
import org.hibernate.boot.model.relational.Database;
import org.hibernate.boot.model.source.spi.AttributePath;
import org.hibernate.boot.spi.MetadataBuildingContext;
-import org.hibernate.cfg.annotations.Nullability;
+import org.hibernate.boot.spi.PropertyData;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.mapping.AggregateColumn;
@@ -38,9 +38,9 @@ import org.hibernate.mapping.Table;
import org.jboss.logging.Logger;
-import static org.hibernate.cfg.BinderHelper.getOverridableAnnotation;
-import static org.hibernate.cfg.BinderHelper.getPath;
-import static org.hibernate.cfg.BinderHelper.getRelativePath;
+import static org.hibernate.boot.model.internal.BinderHelper.getOverridableAnnotation;
+import static org.hibernate.boot.model.internal.BinderHelper.getPath;
+import static org.hibernate.boot.model.internal.BinderHelper.getRelativePath;
import static org.hibernate.internal.util.StringHelper.isEmpty;
import static org.hibernate.internal.util.StringHelper.isNotEmpty;
import static org.hibernate.internal.util.StringHelper.nullIfEmpty;
@@ -414,7 +414,7 @@ public class AnnotatedColumn {
}
else {
final Table table = value.getTable();
- getParent().setTableInternal( table );
+ getParent().setTable( table );
getMappingColumn().setValue( value );
value.addColumn( getMappingColumn(), insertable, updatable );
table.addColumn( getMappingColumn() );
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/AnnotatedColumns.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/AnnotatedColumns.java
new file mode 100644
index 0000000000..96d0e30b2e
--- /dev/null
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/AnnotatedColumns.java
@@ -0,0 +1,178 @@
+/*
+ * 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.model.internal;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import org.hibernate.AnnotationException;
+import org.hibernate.boot.spi.MetadataBuildingContext;
+import org.hibernate.mapping.Join;
+import org.hibernate.mapping.Table;
+
+import static java.util.Collections.unmodifiableList;
+import static org.hibernate.internal.util.StringHelper.isNotEmpty;
+
+/**
+ * A list of columns that are mapped to a single Java property
+ * or field. This is a slightly uncomfortable abstraction here,
+ * because this concept is arguably missing from JPA (where
+ * there's no equivalent of the Hibernate-defined
+ * {@link org.hibernate.annotations.Columns} annotation) and
+ * so JPA lets each {@link jakarta.persistence.Column} specify
+ * its own {@link jakarta.persistence.Column#table table}.
+ * That leaves us having to enforce the requirement that every
+ * column mapped to a given property must belong to the same
+ * table.
+ *
+ * @author Gavin King
+ */
+public class AnnotatedColumns {
+ private final List columns = new ArrayList<>();
+ private Table table;
+ private PropertyHolder propertyHolder;
+ // this is really a .-separated property path
+ private String propertyName;
+ private Map joins = Collections.emptyMap();
+ private MetadataBuildingContext buildingContext;
+
+ public List getColumns() {
+ return unmodifiableList( columns );
+ }
+
+ public PropertyHolder getPropertyHolder() {
+ return propertyHolder;
+ }
+
+ public void setPropertyHolder(PropertyHolder propertyHolder) {
+ this.propertyHolder = propertyHolder;
+ }
+
+ /**
+ * A property path relative to the {@link #getPropertyHolder() PropertyHolder}.
+ */
+ public String getPropertyName() {
+ return propertyName;
+ }
+
+ public void setPropertyName(String propertyName) {
+ this.propertyName = propertyName;
+ }
+
+ public void setBuildingContext(MetadataBuildingContext buildingContext) {
+ this.buildingContext = buildingContext;
+ }
+
+ public MetadataBuildingContext getBuildingContext() {
+ return buildingContext;
+ }
+
+ public void setJoins(Map joins) {
+ this.joins = joins;
+ }
+
+ public Join getJoin() {
+ final AnnotatedColumn firstColumn = columns.get( 0 );
+ final String explicitTableName = firstColumn.getExplicitTableName();
+ //note: checkPropertyConsistency() is responsible for ensuring they all have the same table name
+ Join join = joins.get( explicitTableName );
+ if ( join == null ) {
+ // annotation binding seems to use logical and physical naming somewhat inconsistently...
+ final String physicalTableName = getBuildingContext().getMetadataCollector()
+ .getPhysicalTableName( explicitTableName );
+ if ( physicalTableName != null ) {
+ join = joins.get( physicalTableName );
+ }
+ }
+ if ( join == null ) {
+ throw new AnnotationException(
+ "Secondary table '" + explicitTableName + "' for property '" + getPropertyHolder().getClassName()
+ + "' is not declared (use '@SecondaryTable' to declare the secondary table)"
+ );
+ }
+ else {
+ return join;
+ }
+ }
+
+ public boolean isSecondary() {
+ final AnnotatedColumn firstColumn = columns.get( 0 );
+ final String explicitTableName = firstColumn.getExplicitTableName();
+ //note: checkPropertyConsistency() is responsible for ensuring they all have the same table name
+ return isNotEmpty( explicitTableName )
+ && !getPropertyHolder().getTable().getName().equals( explicitTableName );
+ }
+
+ /**
+ * Find the table to which these columns belong, taking into account secondary tables.
+ *
+ * @return the {@link Table} given in the code by {@link jakarta.persistence.Column#table()}
+ * and held here by {@code explicitTableName}.
+ * @throws AnnotationException if the table named by {@code explicitTableName} is not found
+ * among the secondary tables in {@code joins}.
+ */
+ public Table getTable() {
+ if ( table != null ) {
+ return table;
+ }
+ else {
+ // all the columns have to be mapped to the same table
+ // even though at the annotation level it looks like
+ // they could each specify a different table
+ return isSecondary() ? getJoin().getTable() : getPropertyHolder().getTable();
+ }
+ }
+
+ public void setTable(Table table) {
+ this.table = table;
+ }
+
+ /**
+ * @deprecated Use {@link #setTable(Table)} instead
+ */
+ @Deprecated
+ void setTableInternal(Table table) {
+ this.table = table;
+ }
+
+ public void addColumn(AnnotatedColumn child) {
+ columns.add( child );
+ }
+
+ public void checkPropertyConsistency() {
+ if ( columns.size() > 1 ) {
+ for ( int currentIndex = 1; currentIndex < columns.size(); currentIndex++ ) {
+ final AnnotatedColumn current = columns.get( currentIndex );
+ final AnnotatedColumn previous = columns.get( currentIndex - 1 );
+ if ( !current.isFormula() && !previous.isFormula() ) {
+ if ( current.isNullable() != previous.isNullable() ) {
+ throw new AnnotationException(
+ "Column mappings for property '" + propertyName + "' mix nullable with 'not null'"
+ );
+ }
+ if ( current.isInsertable() != previous.isInsertable() ) {
+ throw new AnnotationException(
+ "Column mappings for property '" + propertyName + "' mix insertable with 'insertable=false'"
+ );
+ }
+ if ( current.isUpdatable() != previous.isUpdatable() ) {
+ throw new AnnotationException(
+ "Column mappings for property '" + propertyName + "' mix updatable with 'updatable=false'"
+ );
+ }
+ if ( !current.getExplicitTableName().equals( previous.getExplicitTableName() ) ) {
+ throw new AnnotationException(
+ "Column mappings for property '" + propertyName + "' mix distinct secondary tables"
+ );
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/AnnotatedDiscriminatorColumn.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/AnnotatedDiscriminatorColumn.java
similarity index 93%
rename from hibernate-core/src/main/java/org/hibernate/cfg/AnnotatedDiscriminatorColumn.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/AnnotatedDiscriminatorColumn.java
index 0c431cceae..49d5d83019 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/AnnotatedDiscriminatorColumn.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/AnnotatedDiscriminatorColumn.java
@@ -2,17 +2,17 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
-
-import jakarta.persistence.DiscriminatorColumn;
-import jakarta.persistence.DiscriminatorType;
+package org.hibernate.boot.model.internal;
import org.hibernate.AssertionFailure;
import org.hibernate.annotations.DiscriminatorFormula;
import org.hibernate.boot.spi.MetadataBuildingContext;
+import jakarta.persistence.DiscriminatorColumn;
+import jakarta.persistence.DiscriminatorType;
+
/**
* A {@link jakarta.persistence.DiscriminatorColumn} annotation
*
@@ -50,8 +50,7 @@ public class AnnotatedDiscriminatorColumn extends AnnotatedColumn {
final AnnotatedColumns parent = new AnnotatedColumns();
parent.setBuildingContext( context );
final AnnotatedDiscriminatorColumn column = new AnnotatedDiscriminatorColumn();
-// column.setContext( context );
- if ( discriminatorFormula != null ) {
+ if ( discriminatorFormula != null ) {
column.setImplicit( false );
column.setFormula( discriminatorFormula.value() );
}
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/AnnotatedJoinColumn.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/AnnotatedJoinColumn.java
similarity index 98%
rename from hibernate-core/src/main/java/org/hibernate/cfg/AnnotatedJoinColumn.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/AnnotatedJoinColumn.java
index f5efd34fb3..b3bc4bfaa6 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/AnnotatedJoinColumn.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/AnnotatedJoinColumn.java
@@ -2,12 +2,9 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
-
-import jakarta.persistence.JoinColumn;
-import jakarta.persistence.PrimaryKeyJoinColumn;
+package org.hibernate.boot.model.internal;
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
@@ -18,12 +15,16 @@ import org.hibernate.boot.model.naming.ObjectNameNormalizer;
import org.hibernate.boot.model.relational.Database;
import org.hibernate.boot.spi.InFlightMetadataCollector;
import org.hibernate.boot.spi.MetadataBuildingContext;
+import org.hibernate.boot.spi.PropertyData;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Value;
-import static org.hibernate.cfg.BinderHelper.getRelativePath;
+import jakarta.persistence.JoinColumn;
+import jakarta.persistence.PrimaryKeyJoinColumn;
+
+import static org.hibernate.boot.model.internal.BinderHelper.getRelativePath;
import static org.hibernate.internal.util.StringHelper.isEmpty;
import static org.hibernate.internal.util.StringHelper.isNotEmpty;
import static org.hibernate.internal.util.StringHelper.isQuoted;
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/AnnotatedJoinColumns.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/AnnotatedJoinColumns.java
new file mode 100644
index 0000000000..49e323f534
--- /dev/null
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/AnnotatedJoinColumns.java
@@ -0,0 +1,634 @@
+/*
+ * 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.model.internal;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import org.hibernate.AnnotationException;
+import org.hibernate.AssertionFailure;
+import org.hibernate.MappingException;
+import org.hibernate.annotations.Comment;
+import org.hibernate.annotations.JoinColumnOrFormula;
+import org.hibernate.annotations.JoinFormula;
+import org.hibernate.boot.model.naming.EntityNaming;
+import org.hibernate.boot.model.naming.Identifier;
+import org.hibernate.boot.model.naming.ImplicitJoinColumnNameSource;
+import org.hibernate.boot.model.naming.ImplicitNamingStrategy;
+import org.hibernate.boot.model.naming.ImplicitPrimaryKeyJoinColumnNameSource;
+import org.hibernate.boot.model.naming.PhysicalNamingStrategy;
+import org.hibernate.boot.model.relational.Database;
+import org.hibernate.boot.model.source.spi.AttributePath;
+import org.hibernate.boot.spi.InFlightMetadataCollector;
+import org.hibernate.boot.spi.MetadataBuildingContext;
+import org.hibernate.boot.spi.MetadataBuildingOptions;
+import org.hibernate.boot.spi.PropertyData;
+import org.hibernate.cfg.RecoverableException;
+import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
+import org.hibernate.mapping.Column;
+import org.hibernate.mapping.Join;
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.mapping.Property;
+import org.hibernate.mapping.Selectable;
+import org.hibernate.mapping.SimpleValue;
+import org.hibernate.mapping.Table;
+
+import jakarta.persistence.JoinColumn;
+
+import static org.hibernate.boot.model.internal.BinderHelper.findReferencedColumnOwner;
+import static org.hibernate.boot.model.internal.BinderHelper.getRelativePath;
+import static org.hibernate.internal.util.StringHelper.isNotEmpty;
+import static org.hibernate.internal.util.StringHelper.isQuoted;
+import static org.hibernate.internal.util.StringHelper.nullIfEmpty;
+import static org.hibernate.internal.util.StringHelper.qualify;
+
+/**
+ * A list of {@link jakarta.persistence.JoinColumn}s that form a single join
+ * condition, similar in concept to {@link jakarta.persistence.JoinColumns},
+ * but not every instance of this class corresponds to an explicit annotation
+ * in the Java code.
+ *
+ * There's no exact analog of this class in the mapping model, so some
+ * information is lost when it's transformed into a list of {@link Column}s.
+ *
+ * @author Gavin King
+ */
+public class AnnotatedJoinColumns extends AnnotatedColumns {
+
+ private final List columns = new ArrayList<>();
+ private String propertyName; // this is really a .-separated property path
+
+ private String mappedBy;
+ //property name on the owning side if any
+ private String mappedByPropertyName;
+ //table name on the mapped by side if any
+ private String mappedByTableName;
+ private String mappedByEntityName;
+ private boolean elementCollection;
+ private String manyToManyOwnerSideEntityName;
+
+ public static AnnotatedJoinColumns buildJoinColumnsOrFormulas(
+ JoinColumnOrFormula[] joinColumnOrFormulas,
+ String mappedBy,
+ Map joins,
+ PropertyHolder propertyHolder,
+ PropertyData inferredData,
+ MetadataBuildingContext context) {
+ final AnnotatedJoinColumns parent = new AnnotatedJoinColumns();
+ parent.setBuildingContext( context );
+ parent.setJoins( joins );
+ parent.setPropertyHolder( propertyHolder );
+ parent.setPropertyName( getRelativePath( propertyHolder, inferredData.getPropertyName() ) );
+ parent.setMappedBy( mappedBy );
+ for ( JoinColumnOrFormula columnOrFormula : joinColumnOrFormulas ) {
+ final JoinFormula formula = columnOrFormula.formula();
+ final JoinColumn column = columnOrFormula.column();
+ final String annotationString = formula.value();
+ if ( isNotEmpty( annotationString ) ) {
+ AnnotatedJoinColumn.buildJoinFormula( formula, parent );
+ }
+ else {
+ AnnotatedJoinColumn.buildJoinColumn( column, mappedBy, parent, propertyHolder, inferredData );
+ }
+ }
+ return parent;
+ }
+
+ static AnnotatedJoinColumns buildJoinColumnsWithFormula(
+ JoinFormula joinFormula,
+ Map secondaryTables,
+ PropertyHolder propertyHolder,
+ PropertyData inferredData,
+ MetadataBuildingContext context) {
+ final AnnotatedJoinColumns joinColumns = new AnnotatedJoinColumns();
+ joinColumns.setBuildingContext( context );
+ joinColumns.setJoins( secondaryTables );
+ joinColumns.setPropertyHolder( propertyHolder );
+ joinColumns.setPropertyName( getRelativePath( propertyHolder, inferredData.getPropertyName() ) );
+ AnnotatedJoinColumn.buildJoinFormula( joinFormula, joinColumns );
+ return joinColumns;
+ }
+
+ public static AnnotatedJoinColumns buildJoinColumns(
+ JoinColumn[] joinColumns,
+ Comment comment,
+ String mappedBy,
+ Map joins,
+ PropertyHolder propertyHolder,
+ PropertyData inferredData,
+ MetadataBuildingContext buildingContext) {
+ return buildJoinColumnsWithDefaultColumnSuffix(
+ joinColumns,
+ comment,
+ mappedBy,
+ joins,
+ propertyHolder,
+ inferredData,
+ "",
+ buildingContext
+ );
+ }
+
+ public static AnnotatedJoinColumns buildJoinColumnsWithDefaultColumnSuffix(
+ JoinColumn[] joinColumns,
+ Comment comment,
+ String mappedBy,
+ Map joins,
+ PropertyHolder propertyHolder,
+ PropertyData inferredData,
+ String defaultColumnSuffix,
+ MetadataBuildingContext context) {
+ assert mappedBy == null || !mappedBy.isEmpty();
+ final String propertyName = inferredData.getPropertyName();
+ final String path = qualify( propertyHolder.getPath(), propertyName );
+ final JoinColumn[] overriddes = propertyHolder.getOverriddenJoinColumn( path );
+ final JoinColumn[] actualColumns = overriddes == null ? joinColumns : overriddes;
+ final AnnotatedJoinColumns parent = new AnnotatedJoinColumns();
+ parent.setBuildingContext( context );
+ parent.setJoins( joins );
+ parent.setPropertyHolder( propertyHolder );
+ parent.setPropertyName( getRelativePath( propertyHolder, propertyName ) );
+ parent.setMappedBy( mappedBy );
+ if ( actualColumns == null || actualColumns.length == 0 ) {
+ AnnotatedJoinColumn.buildJoinColumn(
+ null,
+ comment,
+ mappedBy,
+ parent,
+ propertyHolder,
+ inferredData,
+ defaultColumnSuffix
+ );
+ }
+ else {
+ parent.setMappedBy( mappedBy );
+ for ( JoinColumn actualColumn : actualColumns ) {
+ AnnotatedJoinColumn.buildJoinColumn(
+ actualColumn,
+ comment,
+ mappedBy,
+ parent,
+ propertyHolder,
+ inferredData,
+ defaultColumnSuffix
+ );
+ }
+ }
+ return parent;
+ }
+
+ /**
+ * Called for join tables in {@link jakarta.persistence.ManyToMany} associations.
+ */
+ public static AnnotatedJoinColumns buildJoinTableJoinColumns(
+ JoinColumn[] joinColumns,
+ Map secondaryTables,
+ PropertyHolder propertyHolder,
+ PropertyData inferredData,
+ String mappedBy,
+ MetadataBuildingContext context) {
+ final AnnotatedJoinColumns parent = new AnnotatedJoinColumns();
+ parent.setBuildingContext( context );
+ parent.setJoins( secondaryTables );
+ parent.setPropertyHolder( propertyHolder );
+ parent.setPropertyName( getRelativePath( propertyHolder, inferredData.getPropertyName() ) );
+ parent.setMappedBy( mappedBy );
+ if ( joinColumns == null ) {
+ AnnotatedJoinColumn.buildImplicitJoinTableJoinColumn( parent, propertyHolder, inferredData );
+ }
+ else {
+ for ( JoinColumn joinColumn : joinColumns ) {
+ AnnotatedJoinColumn.buildExplicitJoinTableJoinColumn( parent, propertyHolder, inferredData, joinColumn );
+ }
+ }
+ return parent;
+ }
+
+ public List getJoinColumns() {
+ return columns;
+ }
+
+ @Override
+ public void addColumn(AnnotatedColumn child) {
+ if ( !( child instanceof AnnotatedJoinColumn ) ) {
+ throw new AssertionFailure( "wrong sort of column" );
+ }
+ addColumn( (AnnotatedJoinColumn) child );
+ }
+
+ public void addColumn(AnnotatedJoinColumn child) {
+ super.addColumn( child );
+ columns.add( child );
+ }
+
+ public String getMappedBy() {
+ return mappedBy;
+ }
+
+ public void setMappedBy(String mappedBy) {
+ this.mappedBy = nullIfEmpty( mappedBy );
+ }
+
+ /**
+ * @return true if the association mapping annotation did specify
+ * {@link jakarta.persistence.OneToMany#mappedBy() mappedBy},
+ * meaning that this {@code @JoinColumn} mapping belongs to an
+ * unowned many-valued association.
+ */
+ public boolean hasMappedBy() {
+ return mappedBy != null;
+ }
+
+ public String getMappedByEntityName() {
+ return mappedByEntityName;
+ }
+
+ public String getMappedByPropertyName() {
+ return mappedByPropertyName;
+ }
+
+ public String getMappedByTableName() {
+ return mappedByTableName;
+ }
+
+ public boolean isElementCollection() {
+ return elementCollection;
+ }
+
+ public void setElementCollection(boolean elementCollection) {
+ this.elementCollection = elementCollection;
+ }
+
+ public void setManyToManyOwnerSideEntityName(String entityName) {
+ manyToManyOwnerSideEntityName = entityName;
+ }
+
+ public String getManyToManyOwnerSideEntityName() {
+ return manyToManyOwnerSideEntityName;
+ }
+
+ public void setMappedBy(String entityName, String logicalTableName, String mappedByProperty) {
+ mappedByEntityName = entityName;
+ mappedByTableName = logicalTableName;
+ mappedByPropertyName = mappedByProperty;
+ }
+
+ /**
+ * Determine if the given {@link AnnotatedJoinColumns} represent a reference to
+ * the primary key of the given {@link PersistentClass}, or whether they reference
+ * some other combination of mapped columns.
+ */
+ public ForeignKeyType getReferencedColumnsType(
+ PersistentClass referencedEntity) {
+ if ( columns.isEmpty() ) {
+ return ForeignKeyType.IMPLICIT_PRIMARY_KEY_REFERENCE; //shortcut
+ }
+
+ final AnnotatedJoinColumn firstColumn = columns.get( 0 );
+ final Object columnOwner = findReferencedColumnOwner( referencedEntity, firstColumn, getBuildingContext() );
+ if ( columnOwner == null ) {
+ try {
+ throw new MappingException( "A '@JoinColumn' references a column named '"
+ + firstColumn.getReferencedColumn() + "' but the target entity '"
+ + referencedEntity.getEntityName() + "' has no property which maps to this column" );
+ }
+ catch (MappingException me) {
+ // we throw a recoverable exception here in case this
+ // is merely an ordering issue, so that the SecondPass
+ // will get reprocessed later
+ throw new RecoverableException( me.getMessage(), me );
+ }
+ }
+ final Table table = table( columnOwner );
+ final List keyColumns = referencedEntity.getKey().getSelectables();
+ boolean explicitColumnReference = false;
+ for ( AnnotatedJoinColumn column : columns ) {
+ if ( !column.isReferenceImplicit() ) {
+ explicitColumnReference = true;
+ if ( !keyColumns.contains( column( getBuildingContext(), table, column.getReferencedColumn() ) ) ) {
+ // we have a column which does not belong to the PK
+ return ForeignKeyType.NON_PRIMARY_KEY_REFERENCE;
+ }
+ }
+ }
+ if ( explicitColumnReference ) {
+ // if we got to here, all the columns belong to the PK
+ return keyColumns.size() == columns.size()
+ // we have all the PK columns
+ ? ForeignKeyType.EXPLICIT_PRIMARY_KEY_REFERENCE
+ // we have a subset of the PK columns
+ : ForeignKeyType.NON_PRIMARY_KEY_REFERENCE;
+ }
+ else {
+ // there were no nonempty referencedColumnNames
+ return ForeignKeyType.IMPLICIT_PRIMARY_KEY_REFERENCE;
+ }
+ }
+
+ private static Table table(Object persistentClassOrJoin) {
+ return persistentClassOrJoin instanceof PersistentClass
+ ? ( (PersistentClass) persistentClassOrJoin ).getTable()
+ : ( (Join) persistentClassOrJoin ).getTable();
+ }
+
+ private static Column column(MetadataBuildingContext context, Table table, String logicalReferencedColumnName) {
+ try {
+ return new Column( context.getMetadataCollector()
+ .getPhysicalColumnName( table, logicalReferencedColumnName ) );
+ }
+ catch (MappingException me) {
+ throw new MappingException( "No column with logical name '" + logicalReferencedColumnName
+ + "' in table '" + table.getName() + "'" );
+ }
+ }
+
+ String buildDefaultColumnName(PersistentClass referencedEntity, String logicalReferencedColumn) {
+ final MetadataBuildingOptions options = getBuildingContext().getBuildingOptions();
+ final ImplicitNamingStrategy implicitNamingStrategy = options.getImplicitNamingStrategy();
+ final PhysicalNamingStrategy physicalNamingStrategy = options.getPhysicalNamingStrategy();
+
+ boolean mappedBySide = getMappedByTableName() != null || getMappedByPropertyName() != null;
+ boolean ownerSide = getPropertyName() != null;
+ boolean isRefColumnQuoted = isQuoted( logicalReferencedColumn );
+
+ final InFlightMetadataCollector collector = getBuildingContext().getMetadataCollector();
+ final Database database = collector.getDatabase();
+
+ Identifier columnIdentifier;
+ if ( mappedBySide ) {
+ // NOTE : While it is completely misleading here to allow for the combination
+ // of a "JPA ElementCollection" to be mappedBy, the code that uses this
+ // class relies on this behavior for handling the inverse side of
+ // many-to-many mappings
+ columnIdentifier = implicitNamingStrategy.determineJoinColumnName(
+ new UnownedImplicitJoinColumnNameSource( referencedEntity, logicalReferencedColumn )
+ );
+
+ //one element was quoted so we quote
+ if ( isRefColumnQuoted || isQuoted( getMappedByTableName() ) ) {
+ columnIdentifier = Identifier.quote( columnIdentifier );
+ }
+ }
+ else if ( ownerSide ) {
+ final String logicalTableName = collector.getLogicalTableName( referencedEntity.getTable() );
+
+ columnIdentifier = implicitNamingStrategy.determineJoinColumnName(
+ new OwnedImplicitJoinColumnNameSource( referencedEntity, logicalTableName, logicalReferencedColumn )
+ );
+
+ // HHH-11826 magic. See Ejb3Column and the HHH-6005 comments
+ if ( columnIdentifier.getText().contains( "_collection&&element_" ) ) {
+ columnIdentifier = Identifier.toIdentifier(
+ columnIdentifier.getText().replace( "_collection&&element_", "_" ),
+ columnIdentifier.isQuoted()
+ );
+ }
+
+ //one element was quoted so we quote
+ if ( isRefColumnQuoted || isQuoted( logicalTableName ) ) {
+ columnIdentifier = Identifier.quote( columnIdentifier );
+ }
+ }
+ else {
+ final Identifier logicalTableName = database.toIdentifier(
+ collector.getLogicalTableName( referencedEntity.getTable() )
+ );
+
+ // is an intra-entity hierarchy table join so copy the name by default
+ columnIdentifier = implicitNamingStrategy.determinePrimaryKeyJoinColumnName(
+ new ImplicitPrimaryKeyJoinColumnNameSource() {
+ @Override
+ public MetadataBuildingContext getBuildingContext() {
+ return AnnotatedJoinColumns.this.getBuildingContext();
+ }
+
+ @Override
+ public Identifier getReferencedTableName() {
+ return logicalTableName;
+ }
+
+ @Override
+ public Identifier getReferencedPrimaryKeyColumnName() {
+ return database.toIdentifier( logicalReferencedColumn );
+ }
+ }
+ );
+
+ if ( !columnIdentifier.isQuoted() && ( isRefColumnQuoted || logicalTableName.isQuoted() ) ) {
+ columnIdentifier = Identifier.quote( columnIdentifier );
+ }
+ }
+
+ final JdbcEnvironment jdbcEnvironment = database.getJdbcEnvironment();
+ return physicalNamingStrategy.toPhysicalColumnName( columnIdentifier, jdbcEnvironment )
+ .render( jdbcEnvironment.getDialect() );
+ }
+
+ /**
+ * A property path relative to the {@link #getPropertyHolder() PropertyHolder}.
+ */
+ @Override
+ public String getPropertyName() {
+ return propertyName;
+ }
+
+ @Override
+ public void setPropertyName(String propertyName) {
+ this.propertyName = propertyName;
+ }
+
+ private ImplicitJoinColumnNameSource.Nature getImplicitNature() {
+ if ( getPropertyHolder().isEntity() ) {
+ return ImplicitJoinColumnNameSource.Nature.ENTITY;
+ }
+ else if ( isElementCollection() ) {
+ return ImplicitJoinColumnNameSource.Nature.ELEMENT_COLLECTION;
+ }
+ else {
+ return ImplicitJoinColumnNameSource.Nature.ENTITY_COLLECTION;
+ }
+ }
+
+ private class UnownedImplicitJoinColumnNameSource implements ImplicitJoinColumnNameSource {
+ final AttributePath attributePath;
+ final Nature implicitNamingNature;
+
+ private final EntityNaming entityNaming;
+
+ private final Identifier referencedTableName;
+ private final String logicalReferencedColumn;
+
+ final InFlightMetadataCollector collector = getBuildingContext().getMetadataCollector();
+ final Database database = collector.getDatabase();
+
+ public UnownedImplicitJoinColumnNameSource(PersistentClass referencedEntity, String logicalReferencedColumn) {
+ this.logicalReferencedColumn = logicalReferencedColumn;
+ attributePath = AttributePath.parse( getMappedByPropertyName() );
+ implicitNamingNature = getImplicitNature();
+ entityNaming = new EntityNaming() {
+ @Override
+ public String getClassName() {
+ return referencedEntity.getClassName();
+ }
+
+ @Override
+ public String getEntityName() {
+ return referencedEntity.getEntityName();
+ }
+
+ @Override
+ public String getJpaEntityName() {
+ return referencedEntity.getJpaEntityName();
+ }
+ };
+ referencedTableName = database.toIdentifier( getMappedByTableName() );
+ }
+
+ @Override
+ public Nature getNature() {
+ return implicitNamingNature;
+ }
+
+ @Override
+ public EntityNaming getEntityNaming() {
+ return entityNaming;
+ }
+
+ @Override
+ public AttributePath getAttributePath() {
+ return attributePath;
+ }
+
+ @Override
+ public Identifier getReferencedTableName() {
+ return referencedTableName;
+ }
+
+ @Override
+ public Identifier getReferencedColumnName() {
+ if ( logicalReferencedColumn != null ) {
+ return database.toIdentifier( logicalReferencedColumn );
+ }
+
+ if ( getMappedByEntityName() == null || getMappedByPropertyName() == null ) {
+ return null;
+ }
+
+ final Property mappedByProperty = collector.getEntityBinding( getMappedByEntityName() )
+ .getProperty( getMappedByPropertyName() );
+ final SimpleValue value = (SimpleValue) mappedByProperty.getValue();
+ if ( value.getSelectables().isEmpty() ) {
+ throw new AnnotationException(
+ String.format(
+ Locale.ENGLISH,
+ "Association '%s' is 'mappedBy' a property '%s' of entity '%s' with no columns",
+ getPropertyHolder().getPath(),
+ getMappedByPropertyName(),
+ getMappedByEntityName()
+ )
+ );
+ }
+ final Selectable selectable = value.getSelectables().get( 0 );
+ if ( !( selectable instanceof Column ) ) {
+ throw new AnnotationException(
+ String.format(
+ Locale.ENGLISH,
+ "Association '%s' is 'mappedBy' a property '%s' of entity '%s' which maps to a formula",
+ getPropertyHolder().getPath(),
+ getMappedByPropertyName(),
+ getPropertyHolder().getPath()
+ )
+ );
+ }
+ if ( value.getSelectables().size() > 1 ) {
+ throw new AnnotationException(
+ String.format(
+ Locale.ENGLISH,
+ "Association '%s' is 'mappedBy' a property '%s' of entity '%s' with multiple columns",
+ getPropertyHolder().getPath(),
+ getMappedByPropertyName(),
+ getPropertyHolder().getPath()
+ )
+ );
+ }
+ return database.toIdentifier( ( (Column) selectable ).getQuotedName() );
+ }
+
+ @Override
+ public MetadataBuildingContext getBuildingContext() {
+ return AnnotatedJoinColumns.this.getBuildingContext();
+ }
+ }
+
+ private class OwnedImplicitJoinColumnNameSource implements ImplicitJoinColumnNameSource {
+ final Nature implicitNamingNature;
+
+ private final EntityNaming entityNaming;
+
+ private final AttributePath attributePath;
+ private final Identifier referencedTableName;
+ private final Identifier referencedColumnName;
+
+ final InFlightMetadataCollector collector = getBuildingContext().getMetadataCollector();
+ final Database database = collector.getDatabase();
+
+ public OwnedImplicitJoinColumnNameSource(PersistentClass referencedEntity, String logicalTableName, String logicalReferencedColumn) {
+ implicitNamingNature = getImplicitNature();
+ entityNaming = new EntityNaming() {
+ @Override
+ public String getClassName() {
+ return referencedEntity.getClassName();
+ }
+
+ @Override
+ public String getEntityName() {
+ return referencedEntity.getEntityName();
+ }
+
+ @Override
+ public String getJpaEntityName() {
+ return referencedEntity.getJpaEntityName();
+ }
+ };
+ attributePath = AttributePath.parse( getPropertyName() );
+ referencedTableName = database.toIdentifier( logicalTableName );
+ referencedColumnName = database.toIdentifier( logicalReferencedColumn );
+ }
+
+ @Override
+ public Nature getNature() {
+ return implicitNamingNature;
+ }
+
+ @Override
+ public EntityNaming getEntityNaming() {
+ return entityNaming;
+ }
+
+ @Override
+ public AttributePath getAttributePath() {
+ return attributePath;
+ }
+
+ @Override
+ public Identifier getReferencedTableName() {
+ return referencedTableName;
+ }
+
+ @Override
+ public Identifier getReferencedColumnName() {
+ return referencedColumnName;
+ }
+
+ @Override
+ public MetadataBuildingContext getBuildingContext() {
+ return AnnotatedJoinColumns.this.getBuildingContext();
+ }
+ }
+}
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/AnnotationBinder.java
similarity index 98%
rename from hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/AnnotationBinder.java
index 741cc0e744..22a668ed26 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/AnnotationBinder.java
@@ -2,9 +2,9 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
+package org.hibernate.boot.model.internal;
import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
@@ -73,13 +73,10 @@ import org.hibernate.boot.model.convert.spi.ConverterDescriptor;
import org.hibernate.boot.model.convert.spi.RegisteredConversion;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
+import org.hibernate.boot.spi.AccessType;
import org.hibernate.boot.spi.InFlightMetadataCollector;
import org.hibernate.boot.spi.MetadataBuildingContext;
-import org.hibernate.cfg.annotations.CollectionBinder;
-import org.hibernate.cfg.annotations.EntityBinder;
-import org.hibernate.cfg.annotations.Nullability;
-import org.hibernate.cfg.annotations.PropertyBinder;
-import org.hibernate.cfg.annotations.QueryBinder;
+import org.hibernate.boot.spi.PropertyData;
import org.hibernate.dialect.TimeZoneSupport;
import org.hibernate.engine.OptimisticLockStyle;
import org.hibernate.engine.spi.FilterDefinition;
@@ -151,18 +148,18 @@ import jakarta.persistence.TableGenerator;
import jakarta.persistence.TableGenerators;
import jakarta.persistence.Version;
-import static org.hibernate.cfg.BinderHelper.getMappedSuperclassOrNull;
-import static org.hibernate.cfg.BinderHelper.getOverridableAnnotation;
-import static org.hibernate.cfg.BinderHelper.getPath;
-import static org.hibernate.cfg.BinderHelper.getPropertyOverriddenByMapperOrMapsId;
-import static org.hibernate.cfg.BinderHelper.getRelativePath;
-import static org.hibernate.cfg.BinderHelper.hasToOneAnnotation;
-import static org.hibernate.cfg.BinderHelper.makeIdGenerator;
-import static org.hibernate.cfg.InheritanceState.getInheritanceStateOfSuperEntity;
-import static org.hibernate.cfg.InheritanceState.getSuperclassInheritanceState;
-import static org.hibernate.cfg.PropertyHolderBuilder.buildPropertyHolder;
-import static org.hibernate.cfg.annotations.HCANNHelper.findContainingAnnotation;
-import static org.hibernate.cfg.annotations.PropertyBinder.identifierGeneratorCreator;
+import static org.hibernate.boot.model.internal.BinderHelper.getMappedSuperclassOrNull;
+import static org.hibernate.boot.model.internal.BinderHelper.getOverridableAnnotation;
+import static org.hibernate.boot.model.internal.BinderHelper.getPath;
+import static org.hibernate.boot.model.internal.BinderHelper.getPropertyOverriddenByMapperOrMapsId;
+import static org.hibernate.boot.model.internal.BinderHelper.getRelativePath;
+import static org.hibernate.boot.model.internal.BinderHelper.hasToOneAnnotation;
+import static org.hibernate.boot.model.internal.BinderHelper.makeIdGenerator;
+import static org.hibernate.boot.model.internal.HCANNHelper.findContainingAnnotation;
+import static org.hibernate.boot.model.internal.InheritanceState.getInheritanceStateOfSuperEntity;
+import static org.hibernate.boot.model.internal.InheritanceState.getSuperclassInheritanceState;
+import static org.hibernate.boot.model.internal.PropertyBinder.identifierGeneratorCreator;
+import static org.hibernate.boot.model.internal.PropertyHolderBuilder.buildPropertyHolder;
import static org.hibernate.internal.CoreLogging.messageLogger;
import static org.hibernate.mapping.Constraint.hashedName;
import static org.hibernate.mapping.SimpleValue.DEFAULT_ID_GEN_STRATEGY;
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/ArrayBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ArrayBinder.java
similarity index 88%
rename from hibernate-core/src/main/java/org/hibernate/cfg/annotations/ArrayBinder.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/ArrayBinder.java
index 9193328188..faefe9ff0f 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/ArrayBinder.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ArrayBinder.java
@@ -2,9 +2,9 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg.annotations;
+package org.hibernate.boot.model.internal;
import java.util.function.Supplier;
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/AttributeConversionInfo.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/AttributeConversionInfo.java
similarity index 72%
rename from hibernate-core/src/main/java/org/hibernate/cfg/AttributeConversionInfo.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/AttributeConversionInfo.java
index c04cb413ac..ab1ad392a2 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/AttributeConversionInfo.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/AttributeConversionInfo.java
@@ -2,9 +2,9 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
+package org.hibernate.boot.model.internal;
import org.hibernate.annotations.common.reflection.XAnnotatedElement;
@@ -12,7 +12,10 @@ import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Convert;
/**
- * Describes a {@link jakarta.persistence.Convert} conversion
+ * Describes a {@linkplain AttributeConverter conversion}
+ *
+ * @see AttributeConverter
+ * @see Convert
*
* @author Steve Ebersole
*/
@@ -45,18 +48,32 @@ public class AttributeConversionInfo {
);
}
- public Class extends AttributeConverter,?>> getConverterClass() {
- return converterClass;
- }
-
- public boolean isConversionDisabled() {
- return conversionDisabled;
- }
-
+ /**
+ * The name of the attribute to which the conversion applies.
+ *
+ * @see Convert#attributeName()
+ */
public String getAttributeName() {
return attributeName;
}
+ /**
+ * The {@linkplain AttributeConverter converter} implementation class
+ */
+ public Class extends AttributeConverter,?>> getConverterClass() {
+ return converterClass;
+ }
+
+ /**
+ * Whether conversion is explicitly disabled for this {@linkplain #getAttributeName() attribute}
+ */
+ public boolean isConversionDisabled() {
+ return conversionDisabled;
+ }
+
+ /**
+ * The annotated element
+ */
public XAnnotatedElement getSource() {
return source;
}
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/AttributeConverterDefinitionCollector.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/AttributeConverterDefinitionCollector.java
similarity index 71%
rename from hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/AttributeConverterDefinitionCollector.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/AttributeConverterDefinitionCollector.java
index 2a9c2760dd..ba46fb6bd8 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/AttributeConverterDefinitionCollector.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/AttributeConverterDefinitionCollector.java
@@ -2,9 +2,9 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg.annotations.reflection;
+package org.hibernate.boot.model.internal;
import org.hibernate.Remove;
import org.hibernate.boot.AttributeConverterInfo;
@@ -13,7 +13,7 @@ import org.hibernate.boot.model.convert.spi.ConverterRegistry;
/**
* @author Steve Ebersole
*
- * @deprecated no longer used, use {@link ConverterRegistry}
+ * @deprecated use {@link ConverterRegistry}
*/
@Deprecated(since = "6.2", forRemoval = true) @Remove
public interface AttributeConverterDefinitionCollector extends ConverterRegistry {
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/BagBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/BagBinder.java
similarity index 87%
rename from hibernate-core/src/main/java/org/hibernate/cfg/annotations/BagBinder.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/BagBinder.java
index 60366f937d..689ffb86eb 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/BagBinder.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/BagBinder.java
@@ -2,9 +2,9 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg.annotations;
+package org.hibernate.boot.model.internal;
import java.util.function.Supplier;
@@ -29,6 +29,7 @@ public class BagBinder extends CollectionBinder {
super( customTypeBeanResolver, false, context );
}
+ @Override
protected Collection createCollection(PersistentClass owner) {
return new Bag( getCustomTypeBeanResolver(), owner, getBuildingContext() );
}
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/BasicValueBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/BasicValueBinder.java
similarity index 99%
rename from hibernate-core/src/main/java/org/hibernate/cfg/annotations/BasicValueBinder.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/BasicValueBinder.java
index 1d07361db7..a46e923408 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/BasicValueBinder.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/BasicValueBinder.java
@@ -2,9 +2,9 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg.annotations;
+package org.hibernate.boot.model.internal;
import java.io.Serializable;
import java.lang.reflect.ParameterizedType;
@@ -24,22 +24,21 @@ import org.hibernate.annotations.AnyKeyJavaType;
import org.hibernate.annotations.AnyKeyJdbcType;
import org.hibernate.annotations.AnyKeyJdbcTypeCode;
import org.hibernate.annotations.CollectionId;
-import org.hibernate.annotations.CollectionIdType;
import org.hibernate.annotations.CollectionIdJavaType;
import org.hibernate.annotations.CollectionIdJdbcType;
import org.hibernate.annotations.CollectionIdJdbcTypeCode;
import org.hibernate.annotations.CollectionIdMutability;
-import org.hibernate.annotations.Type;
+import org.hibernate.annotations.CollectionIdType;
import org.hibernate.annotations.Immutable;
import org.hibernate.annotations.JdbcTypeCode;
import org.hibernate.annotations.ListIndexJavaType;
import org.hibernate.annotations.ListIndexJdbcType;
import org.hibernate.annotations.ListIndexJdbcTypeCode;
-import org.hibernate.annotations.MapKeyType;
import org.hibernate.annotations.MapKeyJavaType;
import org.hibernate.annotations.MapKeyJdbcType;
import org.hibernate.annotations.MapKeyJdbcTypeCode;
import org.hibernate.annotations.MapKeyMutability;
+import org.hibernate.annotations.MapKeyType;
import org.hibernate.annotations.Mutability;
import org.hibernate.annotations.Nationalized;
import org.hibernate.annotations.Parameter;
@@ -47,18 +46,14 @@ import org.hibernate.annotations.Target;
import org.hibernate.annotations.TimeZoneColumn;
import org.hibernate.annotations.TimeZoneStorage;
import org.hibernate.annotations.TimeZoneStorageType;
+import org.hibernate.annotations.Type;
import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.boot.model.TypeDefinition;
import org.hibernate.boot.model.convert.spi.ConverterDescriptor;
+import org.hibernate.boot.spi.AccessType;
import org.hibernate.boot.spi.InFlightMetadataCollector;
import org.hibernate.boot.spi.MetadataBuildingContext;
-import org.hibernate.cfg.AccessType;
-import org.hibernate.cfg.AnnotatedColumn;
-import org.hibernate.cfg.AnnotatedColumns;
-import org.hibernate.cfg.AnnotatedJoinColumns;
-import org.hibernate.cfg.PkDrivenByDefaultMapsIdSecondPass;
-import org.hibernate.cfg.SetBasicValueTypeSecondPass;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.NationalizationSupport;
import org.hibernate.engine.jdbc.spi.JdbcServices;
@@ -95,7 +90,7 @@ import jakarta.persistence.Temporal;
import jakarta.persistence.TemporalType;
import jakarta.persistence.Version;
-import static org.hibernate.cfg.annotations.HCANNHelper.findAnnotation;
+import static org.hibernate.boot.model.internal.HCANNHelper.findAnnotation;
/**
* @author Steve Ebersole
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/BinderHelper.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/BinderHelper.java
similarity index 99%
rename from hibernate-core/src/main/java/org/hibernate/cfg/BinderHelper.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/BinderHelper.java
index f9f5fbcb93..08ff3b72cd 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/BinderHelper.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/BinderHelper.java
@@ -2,9 +2,9 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
+package org.hibernate.boot.model.internal;
import java.lang.annotation.Annotation;
import java.lang.annotation.Repeatable;
@@ -22,9 +22,6 @@ import java.util.StringTokenizer;
import java.util.function.Consumer;
import java.util.stream.Stream;
-import jakarta.persistence.FetchType;
-import jakarta.persistence.ManyToOne;
-import jakarta.persistence.OneToOne;
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
import org.hibernate.FetchMode;
@@ -43,9 +40,7 @@ import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.boot.model.IdentifierGeneratorDefinition;
import org.hibernate.boot.spi.InFlightMetadataCollector;
import org.hibernate.boot.spi.MetadataBuildingContext;
-import org.hibernate.cfg.annotations.BasicValueBinder;
-import org.hibernate.cfg.annotations.EntityBinder;
-import org.hibernate.cfg.annotations.Nullability;
+import org.hibernate.boot.spi.PropertyData;
import org.hibernate.dialect.Dialect;
import org.hibernate.id.IdentifierGenerator;
import org.hibernate.id.PersistentIdentifierGenerator;
@@ -69,13 +64,15 @@ import org.hibernate.type.descriptor.java.JavaType;
import org.jboss.logging.Logger;
+import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
+import jakarta.persistence.ManyToOne;
+import jakarta.persistence.OneToOne;
-import static org.hibernate.cfg.AnnotatedColumn.buildColumnOrFormulaFromAnnotation;
+import static org.hibernate.boot.model.internal.AnnotatedColumn.buildColumnOrFormulaFromAnnotation;
import static org.hibernate.internal.util.StringHelper.isEmpty;
import static org.hibernate.internal.util.StringHelper.isNotEmpty;
-
import static org.hibernate.internal.util.StringHelper.qualify;
import static org.hibernate.mapping.SimpleValue.DEFAULT_ID_GEN_STRATEGY;
import static org.hibernate.property.access.spi.BuiltInPropertyAccessStrategies.EMBEDDED;
@@ -1053,7 +1050,8 @@ public class BinderHelper {
return Stream.of( (Annotation[]) value.invoke(annotation) );
}
}
- catch (NoSuchMethodException ignored) {}
+ catch (NoSuchMethodException ignored) {
+ }
catch (Exception e) {
throw new AssertionFailure("could not read @DialectOverride annotation", e);
}
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/CannotForceNonNullableException.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CannotForceNonNullableException.java
similarity index 82%
rename from hibernate-core/src/main/java/org/hibernate/cfg/CannotForceNonNullableException.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/CannotForceNonNullableException.java
index a5726389f4..6f68538244 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/CannotForceNonNullableException.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CannotForceNonNullableException.java
@@ -2,9 +2,9 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
+package org.hibernate.boot.model.internal;
import org.hibernate.AnnotationException;
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/ClassLoaderAccessLazyImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ClassLoaderAccessLazyImpl.java
similarity index 85%
rename from hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/ClassLoaderAccessLazyImpl.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/ClassLoaderAccessLazyImpl.java
index b78aa94b6f..3f690d803d 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/ClassLoaderAccessLazyImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ClassLoaderAccessLazyImpl.java
@@ -2,9 +2,9 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg.annotations.reflection;
+package org.hibernate.boot.model.internal;
import java.net.URL;
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/ClassPropertyHolder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ClassPropertyHolder.java
similarity index 97%
rename from hibernate-core/src/main/java/org/hibernate/cfg/ClassPropertyHolder.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/ClassPropertyHolder.java
index 737ce52662..3396418b1b 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/ClassPropertyHolder.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ClassPropertyHolder.java
@@ -2,23 +2,20 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
+package org.hibernate.boot.model.internal;
import java.util.HashMap;
import java.util.Map;
-import jakarta.persistence.Convert;
-import jakarta.persistence.Converts;
-import jakarta.persistence.JoinTable;
import org.hibernate.AssertionFailure;
import org.hibernate.MappingException;
import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.boot.spi.MetadataBuildingContext;
-import org.hibernate.cfg.annotations.EntityBinder;
-import org.hibernate.internal.util.StringHelper;
+import org.hibernate.boot.spi.PropertyData;
+import org.hibernate.boot.spi.SecondPass;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.mapping.Collection;
import org.hibernate.mapping.Component;
@@ -33,6 +30,10 @@ import org.hibernate.mapping.Table;
import org.hibernate.mapping.ToOne;
import org.hibernate.mapping.Value;
+import jakarta.persistence.Convert;
+import jakarta.persistence.Converts;
+import jakarta.persistence.JoinTable;
+
import static org.hibernate.internal.util.StringHelper.isEmpty;
/**
@@ -179,10 +180,12 @@ public class ClassPropertyHolder extends AbstractPropertyHolder {
return attributeConversionInfoMap.get( path );
}
+ @Override
public String getEntityName() {
return persistentClass.getEntityName();
}
+ @Override
public void addProperty(Property prop, AnnotatedColumns columns, XClass declaringClass) {
//AnnotatedColumn.checkPropertyConsistency( ); //already called earlier
if ( columns != null ) {
@@ -198,6 +201,7 @@ public class ClassPropertyHolder extends AbstractPropertyHolder {
}
}
+ @Override
public void addProperty(Property prop, XClass declaringClass) {
if ( prop.getValue() instanceof Component ) {
//TODO handle quote and non quote table comparison
@@ -215,6 +219,7 @@ public class ClassPropertyHolder extends AbstractPropertyHolder {
}
}
+ @Override
public Join addJoin(JoinTable joinTableAnn, boolean noDelayInPkColumnCreation) {
Join join = entityBinder.addJoin( joinTableAnn, this, noDelayInPkColumnCreation );
this.joins = entityBinder.getSecondaryTables();
@@ -389,34 +394,42 @@ public class ClassPropertyHolder extends AbstractPropertyHolder {
return joinsPerRealTableName;
}
+ @Override
public String getClassName() {
return persistentClass.getClassName();
}
+ @Override
public String getEntityOwnerClassName() {
return getClassName();
}
+ @Override
public Table getTable() {
return persistentClass.getTable();
}
+ @Override
public boolean isComponent() {
return false;
}
+ @Override
public boolean isEntity() {
return true;
}
+ @Override
public PersistentClass getPersistentClass() {
return persistentClass;
}
+ @Override
public KeyValue getIdentifier() {
return persistentClass.getIdentifier();
}
+ @Override
public boolean isOrWithinEmbeddedId() {
return false;
}
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionBinder.java
similarity index 97%
rename from hibernate-core/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionBinder.java
index c4da057afc..8ab93967e5 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionBinder.java
@@ -2,9 +2,9 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg.annotations;
+package org.hibernate.boot.model.internal;
import java.lang.annotation.Annotation;
import java.util.Comparator;
@@ -14,28 +14,6 @@ import java.util.Locale;
import java.util.Map;
import java.util.Properties;
import java.util.function.Supplier;
-import jakarta.persistence.Access;
-import jakarta.persistence.AttributeOverride;
-import jakarta.persistence.AttributeOverrides;
-import jakarta.persistence.CollectionTable;
-import jakarta.persistence.ConstraintMode;
-import jakarta.persistence.ElementCollection;
-import jakarta.persistence.Embedded;
-import jakarta.persistence.FetchType;
-import jakarta.persistence.ForeignKey;
-import jakarta.persistence.Index;
-import jakarta.persistence.JoinColumn;
-import jakarta.persistence.JoinColumns;
-import jakarta.persistence.JoinTable;
-import jakarta.persistence.ManyToMany;
-import jakarta.persistence.MapKey;
-import jakarta.persistence.MapKeyColumn;
-import jakarta.persistence.MapKeyJoinColumn;
-import jakarta.persistence.MapKeyJoinColumns;
-import jakarta.persistence.OneToMany;
-import jakarta.persistence.OrderBy;
-import jakarta.persistence.OrderColumn;
-import jakarta.persistence.UniqueConstraint;
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
@@ -95,29 +73,13 @@ import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.boot.BootLogging;
import org.hibernate.boot.model.IdentifierGeneratorDefinition;
import org.hibernate.boot.model.TypeDefinition;
+import org.hibernate.boot.spi.AccessType;
import org.hibernate.boot.spi.InFlightMetadataCollector;
import org.hibernate.boot.spi.InFlightMetadataCollector.CollectionTypeRegistrationDescriptor;
import org.hibernate.boot.spi.MetadataBuildingContext;
-import org.hibernate.cfg.AccessType;
-import org.hibernate.cfg.AnnotatedClassType;
-import org.hibernate.cfg.AnnotatedColumn;
-import org.hibernate.cfg.AnnotatedColumns;
-import org.hibernate.cfg.AnnotatedJoinColumn;
-import org.hibernate.cfg.AnnotatedJoinColumns;
-import org.hibernate.cfg.AnnotationBinder;
+import org.hibernate.boot.spi.PropertyData;
+import org.hibernate.boot.spi.SecondPass;
import org.hibernate.cfg.AvailableSettings;
-import org.hibernate.cfg.CollectionPropertyHolder;
-import org.hibernate.cfg.CollectionSecondPass;
-import org.hibernate.cfg.ComponentPropertyHolder;
-import org.hibernate.cfg.IndexColumn;
-import org.hibernate.cfg.InheritanceState;
-import org.hibernate.cfg.NotYetImplementedException;
-import org.hibernate.cfg.PropertyData;
-import org.hibernate.cfg.PropertyHolder;
-import org.hibernate.cfg.PropertyInferredData;
-import org.hibernate.cfg.PropertyPreloadedData;
-import org.hibernate.cfg.SecondPass;
-import org.hibernate.cfg.WrappedInferredData;
import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.engine.spi.FilterDefinition;
import org.hibernate.internal.CoreMessageLogger;
@@ -149,26 +111,49 @@ import org.hibernate.usertype.UserCollectionType;
import org.jboss.logging.Logger;
+import jakarta.persistence.Access;
+import jakarta.persistence.AttributeOverride;
+import jakarta.persistence.AttributeOverrides;
+import jakarta.persistence.CollectionTable;
+import jakarta.persistence.ConstraintMode;
+import jakarta.persistence.ElementCollection;
+import jakarta.persistence.Embedded;
+import jakarta.persistence.FetchType;
+import jakarta.persistence.ForeignKey;
+import jakarta.persistence.Index;
+import jakarta.persistence.JoinColumn;
+import jakarta.persistence.JoinColumns;
+import jakarta.persistence.JoinTable;
+import jakarta.persistence.ManyToMany;
+import jakarta.persistence.MapKey;
+import jakarta.persistence.MapKeyColumn;
+import jakarta.persistence.MapKeyJoinColumn;
+import jakarta.persistence.MapKeyJoinColumns;
+import jakarta.persistence.OneToMany;
+import jakarta.persistence.OrderBy;
+import jakarta.persistence.OrderColumn;
+import jakarta.persistence.UniqueConstraint;
+
import static jakarta.persistence.AccessType.PROPERTY;
import static jakarta.persistence.FetchType.EAGER;
import static jakarta.persistence.FetchType.LAZY;
-import static org.hibernate.cfg.AnnotatedColumn.buildColumnFromAnnotation;
-import static org.hibernate.cfg.AnnotatedColumn.buildColumnFromNoAnnotation;
-import static org.hibernate.cfg.AnnotatedColumn.buildColumnsFromAnnotations;
-import static org.hibernate.cfg.AnnotatedColumn.buildFormulaFromAnnotation;
-import static org.hibernate.cfg.AnnotatedJoinColumns.buildJoinColumnsWithDefaultColumnSuffix;
-import static org.hibernate.cfg.AnnotatedJoinColumns.buildJoinTableJoinColumns;
-import static org.hibernate.cfg.AnnotationBinder.fillComponent;
-import static org.hibernate.cfg.BinderHelper.buildAnyValue;
-import static org.hibernate.cfg.BinderHelper.createSyntheticPropertyReference;
-import static org.hibernate.cfg.BinderHelper.getCascadeStrategy;
-import static org.hibernate.cfg.BinderHelper.getFetchMode;
-import static org.hibernate.cfg.BinderHelper.getOverridableAnnotation;
-import static org.hibernate.cfg.BinderHelper.getPath;
-import static org.hibernate.cfg.BinderHelper.isPrimitive;
-import static org.hibernate.cfg.BinderHelper.toAliasEntityMap;
-import static org.hibernate.cfg.BinderHelper.toAliasTableMap;
-import static org.hibernate.cfg.PropertyHolderBuilder.buildPropertyHolder;
+import static org.hibernate.boot.model.internal.AnnotatedColumn.buildColumnFromAnnotation;
+import static org.hibernate.boot.model.internal.AnnotatedColumn.buildColumnFromNoAnnotation;
+import static org.hibernate.boot.model.internal.AnnotatedColumn.buildColumnsFromAnnotations;
+import static org.hibernate.boot.model.internal.AnnotatedColumn.buildFormulaFromAnnotation;
+import static org.hibernate.boot.model.internal.AnnotatedJoinColumns.buildJoinColumnsWithDefaultColumnSuffix;
+import static org.hibernate.boot.model.internal.AnnotatedJoinColumns.buildJoinTableJoinColumns;
+import static org.hibernate.boot.model.internal.AnnotationBinder.fillComponent;
+import static org.hibernate.boot.model.internal.BinderHelper.buildAnyValue;
+import static org.hibernate.boot.model.internal.BinderHelper.createSyntheticPropertyReference;
+import static org.hibernate.boot.model.internal.BinderHelper.getCascadeStrategy;
+import static org.hibernate.boot.model.internal.BinderHelper.getFetchMode;
+import static org.hibernate.boot.model.internal.BinderHelper.getOverridableAnnotation;
+import static org.hibernate.boot.model.internal.BinderHelper.getPath;
+import static org.hibernate.boot.model.internal.BinderHelper.isPrimitive;
+import static org.hibernate.boot.model.internal.BinderHelper.toAliasEntityMap;
+import static org.hibernate.boot.model.internal.BinderHelper.toAliasTableMap;
+import static org.hibernate.boot.model.internal.PropertyHolderBuilder.buildPropertyHolder;
import static org.hibernate.engine.spi.ExecuteUpdateResultCheckStyle.fromResultCheckStyle;
import static org.hibernate.internal.util.StringHelper.getNonEmptyOrConjunctionIfBothNonEmpty;
import static org.hibernate.internal.util.StringHelper.isEmpty;
@@ -465,8 +450,9 @@ public abstract class CollectionBinder {
final ReflectionManager reflectionManager = context.getBootstrapContext().getReflectionManager();
if ( oneToManyAnn != null ) {
if ( joinColumns.isSecondary() ) {
- //TODO: fix the error message
- throw new NotYetImplementedException( "Collections having FK in secondary table" );
+ throw new AssertionFailure(
+ "Collections having FK in secondary table - " + getPath( propertyHolder, inferredData )
+ );
}
collectionBinder.setFkJoinColumns( joinColumns );
mappedBy = nullIfEmpty( oneToManyAnn.mappedBy() );
@@ -479,8 +465,9 @@ public abstract class CollectionBinder {
}
else if ( elementCollectionAnn != null ) {
if ( joinColumns.isSecondary() ) {
- //TODO: fix the error message
- throw new NotYetImplementedException( "Collections having FK in secondary table" );
+ throw new AssertionFailure(
+ "Collections having FK in secondary table - " + getPath( propertyHolder, inferredData )
+ );
}
collectionBinder.setFkJoinColumns( joinColumns );
mappedBy = null;
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/CollectionPropertyHolder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionPropertyHolder.java
similarity index 95%
rename from hibernate-core/src/main/java/org/hibernate/cfg/CollectionPropertyHolder.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionPropertyHolder.java
index 1889379370..8e743d228d 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/CollectionPropertyHolder.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionPropertyHolder.java
@@ -2,9 +2,9 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
+package org.hibernate.boot.model.internal;
import java.util.HashMap;
import java.util.Locale;
@@ -228,26 +228,12 @@ public class CollectionPropertyHolder extends AbstractPropertyHolder {
@Override
public void startingProperty(XProperty property) {
- if ( property == null ) {
- return;
- }
-
- // todo : implement (and make sure it gets called - for handling collections of composites)
+ // for now, nothing to do...
}
@Override
protected AttributeConversionInfo locateAttributeConversionInfo(XProperty property) {
- if ( canElementBeConverted && canKeyBeConverted ) {
- // need to decide whether 'property' refers to key/element
- // todo : this may not work for 'basic collections' since there is no XProperty for the element
- }
- else if ( canKeyBeConverted ) {
-
- }
- else {
- return null;
- }
-
+ // nothing to do
return null;
}
@@ -266,26 +252,32 @@ public class CollectionPropertyHolder extends AbstractPropertyHolder {
return elementAttributeConversionInfoMap.get( path );
}
+ @Override
public String getClassName() {
throw new AssertionFailure( "Collection property holder does not have a class name" );
}
+ @Override
public String getEntityOwnerClassName() {
return null;
}
+ @Override
public Table getTable() {
return collection.getCollectionTable();
}
+ @Override
public void addProperty(Property prop, XClass declaringClass) {
throw new AssertionFailure( "Cannot add property to a collection" );
}
+ @Override
public KeyValue getIdentifier() {
throw new AssertionFailure( "Identifier collection not yet managed" );
}
+ @Override
public boolean isOrWithinEmbeddedId() {
return false;
}
@@ -295,27 +287,33 @@ public class CollectionPropertyHolder extends AbstractPropertyHolder {
return false;
}
+ @Override
public PersistentClass getPersistentClass() {
return collection.getOwner();
}
+ @Override
public boolean isComponent() {
return false;
}
+ @Override
public boolean isEntity() {
return false;
}
+ @Override
public String getEntityName() {
return collection.getOwner().getEntityName();
}
+ @Override
public void addProperty(Property prop, AnnotatedColumns columns, XClass declaringClass) {
//Ejb3Column.checkPropertyConsistency( ); //already called earlier
throw new AssertionFailure( "addProperty to a join table of a collection: does it make sense?" );
}
+ @Override
public Join addJoin(JoinTable joinTableAnn, boolean noDelayInPkColumnCreation) {
throw new AssertionFailure( "Add a in a second pass" );
}
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/CollectionSecondPass.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionSecondPass.java
similarity index 91%
rename from hibernate-core/src/main/java/org/hibernate/cfg/CollectionSecondPass.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionSecondPass.java
index a16423f872..be122407d3 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/CollectionSecondPass.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionSecondPass.java
@@ -2,13 +2,14 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
+package org.hibernate.boot.model.internal;
import java.util.Map;
import org.hibernate.MappingException;
+import org.hibernate.boot.spi.SecondPass;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.mapping.Collection;
import org.hibernate.mapping.IndexedCollection;
@@ -34,6 +35,7 @@ public abstract class CollectionSecondPass implements SecondPass {
this.collection = collection;
}
+ @Override
public void doSecondPass(Map persistentClasses)
throws MappingException {
if ( LOG.isDebugEnabled() ) {
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/ColumnsBuilder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ColumnsBuilder.java
similarity index 92%
rename from hibernate-core/src/main/java/org/hibernate/cfg/ColumnsBuilder.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/ColumnsBuilder.java
index 3f8c02f879..85d3ebd4a8 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/ColumnsBuilder.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ColumnsBuilder.java
@@ -2,9 +2,20 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
+package org.hibernate.boot.model.internal;
+
+import org.hibernate.AnnotationException;
+import org.hibernate.annotations.Columns;
+import org.hibernate.annotations.Comment;
+import org.hibernate.annotations.Formula;
+import org.hibernate.annotations.JoinColumnOrFormula;
+import org.hibernate.annotations.JoinColumnsOrFormulas;
+import org.hibernate.annotations.JoinFormula;
+import org.hibernate.annotations.common.reflection.XProperty;
+import org.hibernate.boot.spi.MetadataBuildingContext;
+import org.hibernate.boot.spi.PropertyData;
import jakarta.persistence.Column;
import jakarta.persistence.ElementCollection;
@@ -16,25 +27,13 @@ import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.OneToOne;
-import org.hibernate.AnnotationException;
-import org.hibernate.annotations.Columns;
-import org.hibernate.annotations.Comment;
-import org.hibernate.annotations.Formula;
-import org.hibernate.annotations.JoinColumnOrFormula;
-import org.hibernate.annotations.JoinColumnsOrFormulas;
-import org.hibernate.annotations.JoinFormula;
-import org.hibernate.annotations.common.reflection.XProperty;
-import org.hibernate.boot.spi.MetadataBuildingContext;
-import org.hibernate.cfg.annotations.EntityBinder;
-import org.hibernate.cfg.annotations.Nullability;
-
-import static org.hibernate.cfg.AnnotatedColumn.buildColumnFromAnnotation;
-import static org.hibernate.cfg.AnnotatedColumn.buildColumnFromNoAnnotation;
-import static org.hibernate.cfg.AnnotatedColumn.buildColumnsFromAnnotations;
-import static org.hibernate.cfg.AnnotatedColumn.buildFormulaFromAnnotation;
-import static org.hibernate.cfg.BinderHelper.getOverridableAnnotation;
-import static org.hibernate.cfg.BinderHelper.getPath;
-import static org.hibernate.cfg.BinderHelper.getPropertyOverriddenByMapperOrMapsId;
+import static org.hibernate.boot.model.internal.AnnotatedColumn.buildColumnFromAnnotation;
+import static org.hibernate.boot.model.internal.AnnotatedColumn.buildColumnFromNoAnnotation;
+import static org.hibernate.boot.model.internal.AnnotatedColumn.buildColumnsFromAnnotations;
+import static org.hibernate.boot.model.internal.AnnotatedColumn.buildFormulaFromAnnotation;
+import static org.hibernate.boot.model.internal.BinderHelper.getOverridableAnnotation;
+import static org.hibernate.boot.model.internal.BinderHelper.getPath;
+import static org.hibernate.boot.model.internal.BinderHelper.getPropertyOverriddenByMapperOrMapsId;
import static org.hibernate.internal.util.StringHelper.isEmpty;
import static org.hibernate.internal.util.StringHelper.nullIfEmpty;
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/ComponentPropertyHolder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ComponentPropertyHolder.java
similarity index 93%
rename from hibernate-core/src/main/java/org/hibernate/cfg/ComponentPropertyHolder.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/ComponentPropertyHolder.java
index 6edbe0ebad..ccb0937505 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/ComponentPropertyHolder.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ComponentPropertyHolder.java
@@ -2,24 +2,18 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
+package org.hibernate.boot.model.internal;
import java.util.HashMap;
import java.util.Map;
-import jakarta.persistence.Column;
-import jakarta.persistence.Convert;
-import jakarta.persistence.Converts;
-import jakarta.persistence.EmbeddedId;
-import jakarta.persistence.Id;
-import jakarta.persistence.JoinColumn;
-import jakarta.persistence.JoinTable;
import org.hibernate.AnnotationException;
import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.boot.spi.MetadataBuildingContext;
+import org.hibernate.boot.spi.PropertyData;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.loader.PropertyPath;
import org.hibernate.mapping.Component;
@@ -29,6 +23,15 @@ import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
import org.hibernate.mapping.Table;
+import jakarta.persistence.Column;
+import jakarta.persistence.Convert;
+import jakarta.persistence.Converts;
+import jakarta.persistence.EmbeddedId;
+import jakarta.persistence.Id;
+import jakarta.persistence.JoinColumn;
+import jakarta.persistence.JoinTable;
+
+import static org.hibernate.boot.model.internal.HCANNHelper.hasAnnotation;
import static org.hibernate.internal.util.StringHelper.isEmpty;
/**
@@ -60,13 +63,10 @@ import static org.hibernate.internal.util.StringHelper.isEmpty;
* @author Emmanuel Bernard
*/
public class ComponentPropertyHolder extends AbstractPropertyHolder {
- //TODO introduce an overrideTable() method for columns held by sec table rather than the hack
- // joinsPerRealTableName in ClassPropertyHolder
private final Component component;
private final boolean isOrWithinEmbeddedId;
private final boolean isWithinElementCollection;
-// private boolean virtual;
private final String embeddedAttributeName;
private final Map attributeConversionInfoMap;
@@ -80,26 +80,16 @@ public class ComponentPropertyHolder extends AbstractPropertyHolder {
final XProperty embeddedXProperty = inferredData.getProperty();
setCurrentProperty( embeddedXProperty );
this.component = component;
- this.isOrWithinEmbeddedId =
- parent.isOrWithinEmbeddedId()
- || ( embeddedXProperty != null &&
- ( embeddedXProperty.isAnnotationPresent( Id.class )
- || embeddedXProperty.isAnnotationPresent( EmbeddedId.class ) ) );
+ this.isOrWithinEmbeddedId = parent.isOrWithinEmbeddedId()
+ || hasAnnotation( embeddedXProperty, Id.class, EmbeddedId.class );
this.isWithinElementCollection = parent.isWithinElementCollection() ||
parent instanceof CollectionPropertyHolder;
if ( embeddedXProperty != null ) {
-// this.virtual = false;
this.embeddedAttributeName = embeddedXProperty.getName();
this.attributeConversionInfoMap = processAttributeConversions( embeddedXProperty );
}
else {
- // could be either:
- // 1) virtual/dynamic component
- // 2) collection element/key
-
- // temp
-// this.virtual = true;
this.embeddedAttributeName = "";
this.attributeConversionInfoMap = processAttributeConversions( inferredData.getClassOrElement() );
}
@@ -209,10 +199,6 @@ public class ComponentPropertyHolder extends AbstractPropertyHolder {
return;
}
-// if ( virtual ) {
-// return;
-// }
-
// again : the property coming in here *should* be the property on the embeddable (Address#city in the example),
// so we just ignore it if there is already an existing conversion info for that path since they would have
// precedence
@@ -266,10 +252,12 @@ public class ComponentPropertyHolder extends AbstractPropertyHolder {
return attributeConversionInfoMap.get( path );
}
+ @Override
public String getEntityName() {
return component.getComponentClassName();
}
+ @Override
public void addProperty(Property property, AnnotatedColumns columns, XClass declaringClass) {
//Ejb3Column.checkPropertyConsistency( ); //already called earlier
// Check table matches between the component and the columns
@@ -293,50 +281,62 @@ public class ComponentPropertyHolder extends AbstractPropertyHolder {
addProperty( property, declaringClass );
}
+ @Override
public Join addJoin(JoinTable joinTableAnn, boolean noDelayInPkColumnCreation) {
return parent.addJoin( joinTableAnn, noDelayInPkColumnCreation );
}
+ @Override
public String getClassName() {
return component.getComponentClassName();
}
+ @Override
public String getEntityOwnerClassName() {
return component.getOwner().getClassName();
}
+ @Override
public Table getTable() {
return component.getTable();
}
+ @Override
public void addProperty(Property prop, XClass declaringClass) {
component.addProperty( prop );
}
+ @Override
public KeyValue getIdentifier() {
return component.getOwner().getIdentifier();
}
+ @Override
public boolean isOrWithinEmbeddedId() {
return isOrWithinEmbeddedId;
}
+ @Override
public boolean isWithinElementCollection() {
return isWithinElementCollection;
}
+ @Override
public PersistentClass getPersistentClass() {
return component.getOwner();
}
+ @Override
public boolean isComponent() {
return true;
}
+ @Override
public boolean isEntity() {
return false;
}
+ @Override
public void setParentProperty(String parentProperty) {
component.setParentProperty( parentProperty );
}
@@ -347,11 +347,15 @@ public class ComponentPropertyHolder extends AbstractPropertyHolder {
Column[] result = super.getOverriddenColumn( propertyName );
if ( result == null ) {
String userPropertyName = extractUserPropertyName( "id", propertyName );
- if ( userPropertyName != null ) result = super.getOverriddenColumn( userPropertyName );
+ if ( userPropertyName != null ) {
+ result = super.getOverriddenColumn( userPropertyName );
+ }
}
if ( result == null ) {
String userPropertyName = extractUserPropertyName( PropertyPath.IDENTIFIER_MAPPER_PROPERTY, propertyName );
- if ( userPropertyName != null ) result = super.getOverriddenColumn( userPropertyName );
+ if ( userPropertyName != null ) {
+ result = super.getOverriddenColumn( userPropertyName );
+ }
}
return result;
}
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/CopyIdentifierComponentSecondPass.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CopyIdentifierComponentSecondPass.java
similarity index 98%
rename from hibernate-core/src/main/java/org/hibernate/cfg/CopyIdentifierComponentSecondPass.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/CopyIdentifierComponentSecondPass.java
index 6475ac9d3a..07db17e528 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/CopyIdentifierComponentSecondPass.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CopyIdentifierComponentSecondPass.java
@@ -2,9 +2,9 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
+package org.hibernate.boot.model.internal;
import java.util.List;
import java.util.Locale;
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/CreateKeySecondPass.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CreateKeySecondPass.java
similarity index 84%
rename from hibernate-core/src/main/java/org/hibernate/cfg/CreateKeySecondPass.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/CreateKeySecondPass.java
index cfcd67eb2a..168dee022f 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/CreateKeySecondPass.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CreateKeySecondPass.java
@@ -1,41 +1,43 @@
-/*
- * 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 .
- */
-package org.hibernate.cfg;
-import java.util.Map;
-
-import org.hibernate.mapping.JoinedSubclass;
-import org.hibernate.mapping.PersistentClass;
-import org.hibernate.mapping.RootClass;
-
-/**
- * @author Emmanuel Bernard
- */
-public class CreateKeySecondPass implements SecondPass {
- private RootClass rootClass;
- private JoinedSubclass joinedSubClass;
-
- public CreateKeySecondPass(RootClass rootClass) {
- this.rootClass = rootClass;
- }
-
- public CreateKeySecondPass(JoinedSubclass joinedSubClass) {
- this.joinedSubClass = joinedSubClass;
- }
-
- public void doSecondPass(Map persistentClasses) {
- if ( rootClass != null ) {
- rootClass.createPrimaryKey();
- }
- else if ( joinedSubClass != null ) {
- joinedSubClass.createPrimaryKey();
- joinedSubClass.createForeignKey();
- }
- else {
- throw new AssertionError( "rootClass and joinedSubClass are null" );
- }
- }
-}
+/*
+ * 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.model.internal;
+import java.util.Map;
+
+import org.hibernate.boot.spi.SecondPass;
+import org.hibernate.mapping.JoinedSubclass;
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.mapping.RootClass;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class CreateKeySecondPass implements SecondPass {
+ private RootClass rootClass;
+ private JoinedSubclass joinedSubClass;
+
+ public CreateKeySecondPass(RootClass rootClass) {
+ this.rootClass = rootClass;
+ }
+
+ public CreateKeySecondPass(JoinedSubclass joinedSubClass) {
+ this.joinedSubClass = joinedSubClass;
+ }
+
+ @Override
+ public void doSecondPass(Map persistentClasses) {
+ if ( rootClass != null ) {
+ rootClass.createPrimaryKey();
+ }
+ else if ( joinedSubClass != null ) {
+ joinedSubClass.createPrimaryKey();
+ joinedSubClass.createForeignKey();
+ }
+ else {
+ throw new AssertionError( "rootClass and joinedSubClass are null" );
+ }
+ }
+}
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/EntityBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java
similarity index 97%
rename from hibernate-core/src/main/java/org/hibernate/cfg/annotations/EntityBinder.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java
index 0031a5026d..4b9e9e4835 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/EntityBinder.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java
@@ -2,9 +2,9 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg.annotations;
+package org.hibernate.boot.model.internal;
import java.lang.annotation.Annotation;
import java.util.ArrayList;
@@ -17,28 +17,6 @@ import java.util.Locale;
import java.util.Map;
import java.util.Set;
-import jakarta.persistence.Access;
-import jakarta.persistence.AttributeOverride;
-import jakarta.persistence.AttributeOverrides;
-import jakarta.persistence.Cacheable;
-import jakarta.persistence.ConstraintMode;
-import jakarta.persistence.DiscriminatorColumn;
-import jakarta.persistence.DiscriminatorType;
-import jakarta.persistence.DiscriminatorValue;
-import jakarta.persistence.Entity;
-import jakarta.persistence.IdClass;
-import jakarta.persistence.InheritanceType;
-import jakarta.persistence.JoinColumn;
-import jakarta.persistence.JoinTable;
-import jakarta.persistence.NamedEntityGraph;
-import jakarta.persistence.NamedEntityGraphs;
-import jakarta.persistence.PrimaryKeyJoinColumn;
-import jakarta.persistence.PrimaryKeyJoinColumns;
-import jakarta.persistence.SecondaryTable;
-import jakarta.persistence.SecondaryTables;
-import jakarta.persistence.SharedCacheMode;
-
-import jakarta.persistence.UniqueConstraint;
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
import org.hibernate.MappingException;
@@ -83,38 +61,22 @@ import org.hibernate.annotations.common.reflection.ReflectionManager;
import org.hibernate.annotations.common.reflection.XAnnotatedElement;
import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.boot.model.IdentifierGeneratorDefinition;
+import org.hibernate.boot.model.NamedEntityGraphDefinition;
+import org.hibernate.boot.model.internal.InheritanceState.ElementsToProcess;
import org.hibernate.boot.model.naming.EntityNaming;
import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.boot.model.naming.ImplicitEntityNameSource;
import org.hibernate.boot.model.naming.NamingStrategyHelper;
import org.hibernate.boot.model.relational.QualifiedTableName;
+import org.hibernate.boot.spi.AccessType;
import org.hibernate.boot.spi.InFlightMetadataCollector;
import org.hibernate.boot.spi.MetadataBuildingContext;
-import org.hibernate.cfg.AccessType;
-import org.hibernate.cfg.AnnotatedClassType;
-import org.hibernate.cfg.AnnotatedColumns;
-import org.hibernate.cfg.AnnotatedDiscriminatorColumn;
-import org.hibernate.cfg.AnnotatedJoinColumns;
-import org.hibernate.cfg.AnnotationBinder;
-import org.hibernate.cfg.AnnotatedJoinColumn;
+import org.hibernate.boot.spi.PropertyData;
import org.hibernate.cfg.AvailableSettings;
-import org.hibernate.cfg.CreateKeySecondPass;
-import org.hibernate.cfg.IdGeneratorResolverSecondPass;
-import org.hibernate.cfg.InheritanceState;
-import org.hibernate.cfg.InheritanceState.ElementsToProcess;
-import org.hibernate.cfg.JoinedSubclassFkSecondPass;
-import org.hibernate.cfg.PropertyData;
-import org.hibernate.cfg.PropertyHolder;
-import org.hibernate.cfg.PropertyPreloadedData;
-import org.hibernate.cfg.SecondaryTableFromAnnotationSecondPass;
-import org.hibernate.cfg.SecondaryTableSecondPass;
-import org.hibernate.cfg.UniqueConstraintHolder;
-import org.hibernate.cfg.internal.NullableDiscriminatorColumnSecondPass;
import org.hibernate.engine.OptimisticLockStyle;
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
import org.hibernate.engine.spi.FilterDefinition;
import org.hibernate.internal.CoreMessageLogger;
-import org.hibernate.internal.util.StringHelper;
import org.hibernate.jpa.event.spi.CallbackType;
import org.hibernate.loader.PropertyPath;
import org.hibernate.mapping.BasicValue;
@@ -133,20 +95,42 @@ import org.hibernate.mapping.Table;
import org.hibernate.mapping.TableOwner;
import org.hibernate.mapping.UnionSubclass;
import org.hibernate.mapping.Value;
-
import org.hibernate.persister.entity.EntityPersister;
+
import org.jboss.logging.Logger;
-import static org.hibernate.cfg.AnnotatedDiscriminatorColumn.buildDiscriminatorColumn;
-import static org.hibernate.cfg.AnnotatedJoinColumn.buildInheritanceJoinColumn;
-import static org.hibernate.cfg.BinderHelper.getMappedSuperclassOrNull;
-import static org.hibernate.cfg.BinderHelper.getOverridableAnnotation;
-import static org.hibernate.cfg.BinderHelper.hasToOneAnnotation;
-import static org.hibernate.cfg.BinderHelper.makeIdGenerator;
-import static org.hibernate.cfg.BinderHelper.toAliasEntityMap;
-import static org.hibernate.cfg.BinderHelper.toAliasTableMap;
-import static org.hibernate.cfg.InheritanceState.getInheritanceStateOfSuperEntity;
-import static org.hibernate.cfg.PropertyHolderBuilder.buildPropertyHolder;
+import jakarta.persistence.Access;
+import jakarta.persistence.AttributeOverride;
+import jakarta.persistence.AttributeOverrides;
+import jakarta.persistence.Cacheable;
+import jakarta.persistence.ConstraintMode;
+import jakarta.persistence.DiscriminatorColumn;
+import jakarta.persistence.DiscriminatorType;
+import jakarta.persistence.DiscriminatorValue;
+import jakarta.persistence.Entity;
+import jakarta.persistence.IdClass;
+import jakarta.persistence.InheritanceType;
+import jakarta.persistence.JoinColumn;
+import jakarta.persistence.JoinTable;
+import jakarta.persistence.NamedEntityGraph;
+import jakarta.persistence.NamedEntityGraphs;
+import jakarta.persistence.PrimaryKeyJoinColumn;
+import jakarta.persistence.PrimaryKeyJoinColumns;
+import jakarta.persistence.SecondaryTable;
+import jakarta.persistence.SecondaryTables;
+import jakarta.persistence.SharedCacheMode;
+import jakarta.persistence.UniqueConstraint;
+
+import static org.hibernate.boot.model.internal.AnnotatedDiscriminatorColumn.buildDiscriminatorColumn;
+import static org.hibernate.boot.model.internal.AnnotatedJoinColumn.buildInheritanceJoinColumn;
+import static org.hibernate.boot.model.internal.BinderHelper.getMappedSuperclassOrNull;
+import static org.hibernate.boot.model.internal.BinderHelper.getOverridableAnnotation;
+import static org.hibernate.boot.model.internal.BinderHelper.hasToOneAnnotation;
+import static org.hibernate.boot.model.internal.BinderHelper.makeIdGenerator;
+import static org.hibernate.boot.model.internal.BinderHelper.toAliasEntityMap;
+import static org.hibernate.boot.model.internal.BinderHelper.toAliasTableMap;
+import static org.hibernate.boot.model.internal.InheritanceState.getInheritanceStateOfSuperEntity;
+import static org.hibernate.boot.model.internal.PropertyHolderBuilder.buildPropertyHolder;
import static org.hibernate.engine.spi.ExecuteUpdateResultCheckStyle.fromResultCheckStyle;
import static org.hibernate.internal.util.StringHelper.isEmpty;
import static org.hibernate.internal.util.StringHelper.isNotEmpty;
@@ -1440,30 +1424,37 @@ public class EntityBinder {
return false;
}
switch ( effectiveCache.include().toLowerCase( Locale.ROOT ) ) {
- case "all":
+ case "all": {
return true;
- case "non-lazy":
+ }
+ case "non-lazy": {
return false;
- default:
+ }
+ default: {
throw new AnnotationException( "Class '" + annotatedClass.getName()
+ "' has a '@Cache' with undefined option 'include=\"" + effectiveCache.include() + "\"'" );
+ }
}
}
private static boolean isCacheable(SharedCacheMode sharedCacheMode, Cacheable explicitCacheableAnn) {
switch (sharedCacheMode) {
- case ALL:
+ case ALL: {
// all entities should be cached
return true;
- case ENABLE_SELECTIVE:
+ }
+ case ENABLE_SELECTIVE: {
// only entities with @Cacheable(true) should be cached
return explicitCacheableAnn != null && explicitCacheableAnn.value();
- case DISABLE_SELECTIVE:
+ }
+ case DISABLE_SELECTIVE: {
// only entities with @Cacheable(false) should not be cached
return explicitCacheableAnn == null || explicitCacheableAnn.value();
- default:
+ }
+ default: {
// treat both NONE and UNSPECIFIED the same
return false;
+ }
}
}
@@ -1476,6 +1467,7 @@ public class EntityBinder {
return new LocalCacheAnnotationStub( region, determineCacheConcurrencyStrategy( context ) );
}
+ @SuppressWarnings("ClassExplicitlyAnnotation")
private static class LocalCacheAnnotationStub implements Cache {
private final String region;
private final CacheConcurrencyStrategy usage;
@@ -1485,10 +1477,12 @@ public class EntityBinder {
this.usage = usage;
}
+ @Override
public CacheConcurrencyStrategy usage() {
return usage;
}
+ @Override
public String region() {
return region;
}
@@ -1498,10 +1492,12 @@ public class EntityBinder {
return true;
}
+ @Override
public String include() {
return "all";
}
+ @Override
public Class extends Annotation> annotationType() {
return Cache.class;
}
@@ -1522,6 +1518,7 @@ public class EntityBinder {
this.jpaEntityName = jpaEntityName;
}
+ @Override
public Identifier determineImplicitName(final MetadataBuildingContext buildingContext) {
return buildingContext.getBuildingOptions().getImplicitNamingStrategy().determinePrimaryTableName(
new ImplicitEntityNameSource() {
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/FkSecondPass.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/FkSecondPass.java
similarity index 78%
rename from hibernate-core/src/main/java/org/hibernate/cfg/FkSecondPass.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/FkSecondPass.java
index 9115eea291..b330652d43 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/FkSecondPass.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/FkSecondPass.java
@@ -2,11 +2,12 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
+package org.hibernate.boot.model.internal;
import java.util.concurrent.atomic.AtomicInteger;
+import org.hibernate.boot.spi.SecondPass;
import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.Value;
@@ -35,15 +36,20 @@ public abstract class FkSecondPass implements SecondPass {
return value;
}
+ @Override
public boolean equals(Object o) {
- if ( this == o ) return true;
- if ( !( o instanceof FkSecondPass ) ) return false;
-
- FkSecondPass that = (FkSecondPass) o;
+ if ( this == o ) {
+ return true;
+ }
+ if ( !( o instanceof FkSecondPass ) ) {
+ return false;
+ }
+ final FkSecondPass that = (FkSecondPass) o;
return uniqueCounter == that.uniqueCounter;
}
+ @Override
public int hashCode() {
return uniqueCounter;
}
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/ForeignKeyType.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ForeignKeyType.java
similarity index 79%
rename from hibernate-core/src/main/java/org/hibernate/cfg/ForeignKeyType.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/ForeignKeyType.java
index 707279587b..658be5ecf2 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/ForeignKeyType.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ForeignKeyType.java
@@ -2,9 +2,9 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
+package org.hibernate.boot.model.internal;
import org.hibernate.mapping.PersistentClass;
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/HCANNHelper.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/HCANNHelper.java
similarity index 61%
rename from hibernate-core/src/main/java/org/hibernate/cfg/annotations/HCANNHelper.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/HCANNHelper.java
index be51515121..5e9daf0d38 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/HCANNHelper.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/HCANNHelper.java
@@ -2,11 +2,12 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg.annotations;
+package org.hibernate.boot.model.internal;
import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Member;
import org.hibernate.Internal;
@@ -21,6 +22,80 @@ import org.hibernate.annotations.common.reflection.java.JavaXMember;
*/
@Internal
public final class HCANNHelper {
+ public static boolean hasAnnotation(
+ AnnotatedElement element,
+ Class extends Annotation> annotationToCheck) {
+ if ( element == null ) {
+ return false;
+ }
+
+ //noinspection RedundantIfStatement
+ if ( element.isAnnotationPresent( annotationToCheck ) ) {
+ return true;
+ }
+
+ return false;
+ }
+
+ public static boolean hasAnnotation(
+ AnnotatedElement element,
+ Class extends Annotation> annotationToCheck,
+ Class extends Annotation> annotationToCheck2) {
+ if ( element == null ) {
+ return false;
+ }
+
+ return element.isAnnotationPresent( annotationToCheck )
+ || element.isAnnotationPresent( annotationToCheck2 );
+ }
+
+ public static boolean hasAnnotation(
+ XAnnotatedElement element,
+ Class extends Annotation> annotationToCheck) {
+ if ( element == null ) {
+ return false;
+ }
+
+ //noinspection RedundantIfStatement
+ if ( element.isAnnotationPresent( annotationToCheck ) ) {
+ return true;
+ }
+
+ return false;
+ }
+
+ public static boolean hasAnnotation(
+ XAnnotatedElement element,
+ Class extends Annotation> annotationToCheck,
+ Class extends Annotation> annotationToCheck2) {
+ if ( element == null ) {
+ return false;
+ }
+
+ //noinspection RedundantIfStatement
+ if ( element.isAnnotationPresent( annotationToCheck )
+ || element.isAnnotationPresent( annotationToCheck2 ) ) {
+ return true;
+ }
+
+ return false;
+ }
+
+ public static boolean hasAnnotation(XAnnotatedElement element, Class extends Annotation>... annotationsToCheck) {
+ assert annotationsToCheck != null && annotationsToCheck.length > 0;
+
+ if ( element == null ) {
+ return false;
+ }
+
+ for ( int i = 0; i < annotationsToCheck.length; i++ ) {
+ if ( element.isAnnotationPresent( annotationsToCheck[i] ) ) {
+ return true;
+ }
+ }
+
+ return false;
+ }
/**
* @deprecated Prefer using {@link #annotatedElementSignature(JavaXMember)}
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/IdBagBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/IdBagBinder.java
similarity index 84%
rename from hibernate-core/src/main/java/org/hibernate/cfg/annotations/IdBagBinder.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/IdBagBinder.java
index 0e8b70fac7..934ac8643f 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/IdBagBinder.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/IdBagBinder.java
@@ -1,158 +1,156 @@
-/*
- * 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 .
- */
-package org.hibernate.cfg.annotations;
-
-import java.util.Collections;
-import java.util.Map;
-import java.util.function.Supplier;
-
-import org.hibernate.MappingException;
-import org.hibernate.annotations.CollectionId;
-import org.hibernate.boot.spi.MetadataBuildingContext;
-import org.hibernate.cfg.AnnotatedColumn;
-import org.hibernate.cfg.AnnotatedColumns;
-import org.hibernate.cfg.IdGeneratorResolverSecondPass;
-import org.hibernate.cfg.PropertyData;
-import org.hibernate.cfg.PropertyInferredData;
-import org.hibernate.cfg.SecondPass;
-import org.hibernate.cfg.WrappedInferredData;
-import org.hibernate.mapping.BasicValue;
-import org.hibernate.mapping.Collection;
-import org.hibernate.mapping.IdentifierBag;
-import org.hibernate.mapping.IdentifierCollection;
-import org.hibernate.mapping.PersistentClass;
-import org.hibernate.mapping.Table;
-import org.hibernate.resource.beans.spi.ManagedBean;
-import org.hibernate.usertype.UserCollectionType;
-
-import jakarta.persistence.Column;
-
-import static org.hibernate.cfg.BinderHelper.makeIdGenerator;
-
-/**
- * A {@link CollectionBinder} for {@link org.hibernate.collection.spi.PersistentIdentifierBag id bags}
- * whose mapping model type is {@link org.hibernate.mapping.IdentifierBag}.
- *
- * @author Emmanuel Bernard
- */
-public class IdBagBinder extends BagBinder {
-
- public IdBagBinder(
- Supplier> customTypeBeanResolver,
- MetadataBuildingContext buildingContext) {
- super( customTypeBeanResolver, buildingContext );
- }
-
- protected Collection createCollection(PersistentClass owner) {
- return new IdentifierBag( getCustomTypeBeanResolver(), owner, getBuildingContext() );
- }
-
- @Override
- protected boolean bindStarToManySecondPass(Map persistentClasses) {
- boolean result = super.bindStarToManySecondPass( persistentClasses );
-
- final CollectionId collectionIdAnn = property.getAnnotation( CollectionId.class );
- if ( collectionIdAnn == null ) {
- //TODO shouldn't this be an assertion?
- throw new MappingException( "idbag mapping missing '@CollectionId' annotation" );
- }
-
- final PropertyData propertyData = new WrappedInferredData(
- new PropertyInferredData(
- null,
- property,
- //default access should not be useful
- null,
- buildingContext.getBootstrapContext().getReflectionManager()
- ),
- "id"
- );
-
- final AnnotatedColumns idColumns = AnnotatedColumn.buildColumnsFromAnnotations(
- new Column[] { collectionIdAnn.column() },
- null,
- Nullability.FORCED_NOT_NULL,
- propertyHolder,
- propertyData,
- Collections.emptyMap(),
- buildingContext
- );
-
- //we need to make sure all id columns must be not-null.
- for ( AnnotatedColumn idColumn : idColumns.getColumns() ) {
- idColumn.setNullable( false );
- }
-
- final BasicValueBinder valueBinder =
- new BasicValueBinder( BasicValueBinder.Kind.COLLECTION_ID, buildingContext );
-
- final Table table = collection.getCollectionTable();
- valueBinder.setTable( table );
- valueBinder.setColumns( idColumns );
-
- valueBinder.setType(
- property,
- getElementType(),
- null,
- null
- );
-
- final BasicValue id = valueBinder.make();
- ( (IdentifierCollection) collection ).setIdentifier( id );
-
- final String namedGenerator = collectionIdAnn.generator();
-
- switch (namedGenerator) {
- case "identity":
- throw new MappingException("IDENTITY generation not supported for CollectionId");
- case "assigned":
- throw new MappingException("Assigned generation not supported for CollectionId");
- case "native":
- throw new MappingException("Native generation not supported for CollectionId");
- }
-
- final String generatorName;
- final String generatorType;
-
- if ( "sequence".equals( namedGenerator ) ) {
- generatorType = namedGenerator;
- generatorName = "";
- }
- else if ( "increment".equals( namedGenerator ) ) {
- generatorType = namedGenerator;
- generatorName = "";
- }
- else {
- generatorType = namedGenerator;
- generatorName = namedGenerator;
- }
-
- id.setIdentifierGeneratorStrategy( generatorType );
-
- if ( buildingContext.getBootstrapContext().getJpaCompliance().isGlobalGeneratorScopeEnabled() ) {
- SecondPass secondPass = new IdGeneratorResolverSecondPass(
- id,
- property,
- generatorType,
- generatorName,
- getBuildingContext()
- );
- buildingContext.getMetadataCollector().addSecondPass( secondPass );
- }
- else {
- makeIdGenerator(
- id,
- property,
- generatorType,
- generatorName,
- getBuildingContext(),
- localGenerators
- );
- }
- return result;
- }
-}
+/*
+ * 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.model.internal;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.function.Supplier;
+
+import org.hibernate.MappingException;
+import org.hibernate.annotations.CollectionId;
+import org.hibernate.boot.spi.MetadataBuildingContext;
+import org.hibernate.boot.spi.PropertyData;
+import org.hibernate.boot.spi.SecondPass;
+import org.hibernate.mapping.BasicValue;
+import org.hibernate.mapping.Collection;
+import org.hibernate.mapping.IdentifierBag;
+import org.hibernate.mapping.IdentifierCollection;
+import org.hibernate.mapping.PersistentClass;
+import org.hibernate.mapping.Table;
+import org.hibernate.resource.beans.spi.ManagedBean;
+import org.hibernate.usertype.UserCollectionType;
+
+import jakarta.persistence.Column;
+
+import static org.hibernate.boot.model.internal.BinderHelper.makeIdGenerator;
+
+/**
+ * A {@link CollectionBinder} for {@link org.hibernate.collection.spi.PersistentIdentifierBag id bags}
+ * whose mapping model type is {@link org.hibernate.mapping.IdentifierBag}.
+ *
+ * @author Emmanuel Bernard
+ */
+public class IdBagBinder extends BagBinder {
+
+ public IdBagBinder(
+ Supplier> customTypeBeanResolver,
+ MetadataBuildingContext buildingContext) {
+ super( customTypeBeanResolver, buildingContext );
+ }
+
+ @Override
+ protected Collection createCollection(PersistentClass owner) {
+ return new IdentifierBag( getCustomTypeBeanResolver(), owner, getBuildingContext() );
+ }
+
+ @Override
+ protected boolean bindStarToManySecondPass(Map persistentClasses) {
+ boolean result = super.bindStarToManySecondPass( persistentClasses );
+
+ final CollectionId collectionIdAnn = property.getAnnotation( CollectionId.class );
+ if ( collectionIdAnn == null ) {
+ throw new MappingException( "idbag mapping missing '@CollectionId' annotation" );
+ }
+
+ final PropertyData propertyData = new WrappedInferredData(
+ new PropertyInferredData(
+ null,
+ property,
+ //default access should not be useful
+ null,
+ buildingContext.getBootstrapContext().getReflectionManager()
+ ),
+ "id"
+ );
+
+ final AnnotatedColumns idColumns = AnnotatedColumn.buildColumnsFromAnnotations(
+ new Column[] { collectionIdAnn.column() },
+ null,
+ Nullability.FORCED_NOT_NULL,
+ propertyHolder,
+ propertyData,
+ Collections.emptyMap(),
+ buildingContext
+ );
+
+ //we need to make sure all id columns must be not-null.
+ for ( AnnotatedColumn idColumn : idColumns.getColumns() ) {
+ idColumn.setNullable( false );
+ }
+
+ final BasicValueBinder valueBinder =
+ new BasicValueBinder( BasicValueBinder.Kind.COLLECTION_ID, buildingContext );
+
+ final Table table = collection.getCollectionTable();
+ valueBinder.setTable( table );
+ valueBinder.setColumns( idColumns );
+
+ valueBinder.setType(
+ property,
+ getElementType(),
+ null,
+ null
+ );
+
+ final BasicValue id = valueBinder.make();
+ ( (IdentifierCollection) collection ).setIdentifier( id );
+
+ final String namedGenerator = collectionIdAnn.generator();
+
+ switch (namedGenerator) {
+ case "identity": {
+ throw new MappingException("IDENTITY generation not supported for CollectionId");
+ }
+ case "assigned": {
+ throw new MappingException("Assigned generation not supported for CollectionId");
+ }
+ case "native": {
+ throw new MappingException("Native generation not supported for CollectionId");
+ }
+ }
+
+ final String generatorName;
+ final String generatorType;
+
+ if ( "sequence".equals( namedGenerator ) ) {
+ generatorType = namedGenerator;
+ generatorName = "";
+ }
+ else if ( "increment".equals( namedGenerator ) ) {
+ generatorType = namedGenerator;
+ generatorName = "";
+ }
+ else {
+ generatorType = namedGenerator;
+ generatorName = namedGenerator;
+ }
+
+ id.setIdentifierGeneratorStrategy( generatorType );
+
+ if ( buildingContext.getBootstrapContext().getJpaCompliance().isGlobalGeneratorScopeEnabled() ) {
+ SecondPass secondPass = new IdGeneratorResolverSecondPass(
+ id,
+ property,
+ generatorType,
+ generatorName,
+ getBuildingContext()
+ );
+ buildingContext.getMetadataCollector().addSecondPass( secondPass );
+ }
+ else {
+ makeIdGenerator(
+ id,
+ property,
+ generatorType,
+ generatorName,
+ getBuildingContext(),
+ localGenerators
+ );
+ }
+ return result;
+ }
+}
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/IdGeneratorResolverSecondPass.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/IdGeneratorResolverSecondPass.java
similarity index 87%
rename from hibernate-core/src/main/java/org/hibernate/cfg/IdGeneratorResolverSecondPass.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/IdGeneratorResolverSecondPass.java
index 0e1e54f61e..93162992c3 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/IdGeneratorResolverSecondPass.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/IdGeneratorResolverSecondPass.java
@@ -2,9 +2,9 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
+package org.hibernate.boot.model.internal;
import java.util.Map;
@@ -12,10 +12,11 @@ import org.hibernate.MappingException;
import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.boot.model.IdentifierGeneratorDefinition;
import org.hibernate.boot.spi.MetadataBuildingContext;
+import org.hibernate.boot.spi.SecondPass;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.SimpleValue;
-import static org.hibernate.cfg.BinderHelper.makeIdGenerator;
+import static org.hibernate.boot.model.internal.BinderHelper.makeIdGenerator;
/**
* @author Andrea Boriero
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/IndexColumn.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/IndexColumn.java
similarity index 96%
rename from hibernate-core/src/main/java/org/hibernate/cfg/IndexColumn.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/IndexColumn.java
index f1ff0636c9..f449373267 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/IndexColumn.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/IndexColumn.java
@@ -2,16 +2,19 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
+package org.hibernate.boot.model.internal;
+
import java.util.Map;
-import jakarta.persistence.OrderColumn;
import org.hibernate.annotations.ListIndexBase;
import org.hibernate.boot.spi.MetadataBuildingContext;
+import org.hibernate.boot.spi.PropertyData;
import org.hibernate.mapping.Join;
+import jakarta.persistence.OrderColumn;
+
import static org.hibernate.internal.util.StringHelper.nullIfEmpty;
/**
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/IndexOrUniqueKeySecondPass.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/IndexOrUniqueKeySecondPass.java
similarity index 95%
rename from hibernate-core/src/main/java/org/hibernate/cfg/IndexOrUniqueKeySecondPass.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/IndexOrUniqueKeySecondPass.java
index 87aabcb7f5..2c0c0b9142 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/IndexOrUniqueKeySecondPass.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/IndexOrUniqueKeySecondPass.java
@@ -2,9 +2,9 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
+package org.hibernate.boot.model.internal;
import java.util.ArrayList;
import java.util.List;
@@ -13,6 +13,7 @@ import java.util.Map;
import org.hibernate.AnnotationException;
import org.hibernate.MappingException;
import org.hibernate.boot.spi.MetadataBuildingContext;
+import org.hibernate.boot.spi.SecondPass;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.Component;
import org.hibernate.mapping.Index;
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/InheritanceState.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/InheritanceState.java
similarity index 98%
rename from hibernate-core/src/main/java/org/hibernate/cfg/InheritanceState.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/InheritanceState.java
index d607a9c887..f18d587b16 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/InheritanceState.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/InheritanceState.java
@@ -2,13 +2,23 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
+package org.hibernate.boot.model.internal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+
+import org.hibernate.AnnotationException;
+import org.hibernate.annotations.common.reflection.XAnnotatedElement;
+import org.hibernate.annotations.common.reflection.XClass;
+import org.hibernate.annotations.common.reflection.XProperty;
+import org.hibernate.boot.spi.AccessType;
+import org.hibernate.boot.spi.MetadataBuildingContext;
+import org.hibernate.boot.spi.PropertyData;
+import org.hibernate.mapping.PersistentClass;
+
import jakarta.persistence.Access;
import jakarta.persistence.EmbeddedId;
import jakarta.persistence.Entity;
@@ -18,14 +28,6 @@ import jakarta.persistence.Inheritance;
import jakarta.persistence.InheritanceType;
import jakarta.persistence.MappedSuperclass;
-import org.hibernate.AnnotationException;
-import org.hibernate.annotations.common.reflection.XAnnotatedElement;
-import org.hibernate.annotations.common.reflection.XClass;
-import org.hibernate.annotations.common.reflection.XProperty;
-import org.hibernate.boot.spi.MetadataBuildingContext;
-import org.hibernate.cfg.annotations.EntityBinder;
-import org.hibernate.mapping.PersistentClass;
-
/**
* Some extra data to the inheritance position of a class.
*
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/JPAIndexHolder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/JPAIndexHolder.java
similarity index 92%
rename from hibernate-core/src/main/java/org/hibernate/cfg/JPAIndexHolder.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/JPAIndexHolder.java
index d6a04409e3..3467e9c09e 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/JPAIndexHolder.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/JPAIndexHolder.java
@@ -2,14 +2,15 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
+package org.hibernate.boot.model.internal;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.StringTokenizer;
+
import jakarta.persistence.Index;
/**
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/internal/JPAXMLOverriddenAnnotationReader.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/JPAXMLOverriddenAnnotationReader.java
similarity index 96%
rename from hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/internal/JPAXMLOverriddenAnnotationReader.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/JPAXMLOverriddenAnnotationReader.java
index 1b0e9ae26f..42c254e8ae 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/internal/JPAXMLOverriddenAnnotationReader.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/JPAXMLOverriddenAnnotationReader.java
@@ -4,7 +4,7 @@
* 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.cfg.annotations.reflection.internal;
+package org.hibernate.boot.model.internal;
import java.beans.Introspector;
import java.lang.annotation.Annotation;
@@ -99,7 +99,6 @@ import org.hibernate.boot.jaxb.mapping.ManagedType;
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
import org.hibernate.boot.spi.BootstrapContext;
import org.hibernate.boot.spi.ClassLoaderAccess;
-import org.hibernate.cfg.annotations.reflection.PersistentAttributeFilter;
import org.hibernate.internal.CoreLogging;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.StringHelper;
@@ -198,8 +197,9 @@ import jakarta.persistence.Transient;
import jakarta.persistence.UniqueConstraint;
import jakarta.persistence.Version;
-import static org.hibernate.cfg.annotations.reflection.internal.PropertyMappingElementCollector.JAXB_TRANSIENT_NAME;
-import static org.hibernate.cfg.annotations.reflection.internal.PropertyMappingElementCollector.PERSISTENT_ATTRIBUTE_NAME;
+import static org.hibernate.boot.model.internal.HCANNHelper.hasAnnotation;
+import static org.hibernate.boot.model.internal.PropertyMappingElementCollector.JAXB_TRANSIENT_NAME;
+import static org.hibernate.boot.model.internal.PropertyMappingElementCollector.PERSISTENT_ATTRIBUTE_NAME;
import static org.hibernate.internal.util.StringHelper.isEmpty;
import static org.hibernate.internal.util.StringHelper.isNotEmpty;
@@ -211,9 +211,7 @@ import static org.hibernate.internal.util.StringHelper.isNotEmpty;
* @author Emmanuel Bernard
* @author Hardy Ferentschik
*/
-// FIXME HHH-14529 Change this class to use JaxbEntityMappings instead of Document.
-// I'm delaying this change in order to keep the commits simpler and easier to review.
-@SuppressWarnings("unchecked")
+@SuppressWarnings({ "unchecked", "ToArrayCallWithZeroLengthArrayArgument" })
public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( JPAXMLOverriddenAnnotationReader.class );
@@ -226,7 +224,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
METHOD
}
- private static final Map annotationToXml;
+ private static final Map, String> annotationToXml;
static {
annotationToXml = new HashMap<>();
@@ -256,7 +254,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
annotationToXml.put( SqlResultSetMappings.class, "sql-result-set-mapping" );
annotationToXml.put( ExcludeDefaultListeners.class, "exclude-default-listeners" );
annotationToXml.put( ExcludeSuperclassListeners.class, "exclude-superclass-listeners" );
- annotationToXml.put( AccessType.class, "access" );
+// annotationToXml.put( AccessType.class, "access" );
annotationToXml.put( AttributeOverride.class, "attribute-override" );
annotationToXml.put( AttributeOverrides.class, "attribute-override" );
annotationToXml.put( AttributeOverride.class, "association-override" );
@@ -347,7 +345,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
try {
mirroredAttribute = field.getDeclaringClass().getDeclaredMethod( expectedGetter );
}
- catch ( NoSuchMethodException e ) {
+ catch (NoSuchMethodException e) {
//no method
}
}
@@ -371,7 +369,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
try {
mirroredAttribute = method.getDeclaringClass().getDeclaredField( propertyName );
}
- catch ( NoSuchFieldException e ) {
+ catch (NoSuchFieldException e) {
//no method
}
}
@@ -458,7 +456,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
addIfNotNull( annotationList, getEntityListeners( managedTypeOverride, defaults ) );
addIfNotNull( annotationList, getConverts( managedTypeOverride, defaults ) );
- this.annotations = annotationList.toArray( new Annotation[annotationList.size()] );
+ this.annotations = annotationList.toArray( new Annotation[0] );
for ( Annotation ann : this.annotations ) {
annotationsMap.put( ann.annotationType(), ann );
}
@@ -504,7 +502,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
}
processEventAnnotations( annotationList, defaults );
//FIXME use annotationsMap rather than annotationList this will be faster since the annotation type is usually known at put() time
- this.annotations = annotationList.toArray( new Annotation[annotationList.size()] );
+ this.annotations = annotationList.toArray( new Annotation[0] );
for ( Annotation ann : this.annotations ) {
annotationsMap.put( ann.annotationType(), ann );
}
@@ -519,16 +517,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
}
}
- private void remove(List annotationList, Class extends Annotation> annotationToRemove) {
- annotationList.removeIf( next -> next.getClass().equals( annotationToRemove ) );
- }
-
private Annotation getConvertsForAttribute(PropertyMappingElementCollector elementsForProperty, XMLContext.Default defaults) {
- // NOTE : we use a map here to make sure that an xml and annotation referring to the same attribute
- // properly overrides. Very sparse map, yes, but easy setup.
- // todo : revisit this
- // although bear in mind that this code is no longer used in 5.0...
-
final Map convertAnnotationsMap = new HashMap<>();
for ( JaxbBasic element : elementsForProperty.getBasic() ) {
@@ -555,7 +544,10 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
if ( !convertAnnotationsMap.isEmpty() ) {
final AnnotationDescriptor groupingDescriptor = new AnnotationDescriptor( Converts.class );
- groupingDescriptor.setValue( "value", convertAnnotationsMap.values().toArray( new Convert[convertAnnotationsMap.size()]) );
+ groupingDescriptor.setValue(
+ "value",
+ convertAnnotationsMap.values().toArray( new Convert[0] )
+ );
return AnnotationFactory.create( groupingDescriptor );
}
@@ -580,7 +572,10 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
if ( !convertAnnotationsMap.isEmpty() ) {
final AnnotationDescriptor groupingDescriptor = new AnnotationDescriptor( Converts.class );
- groupingDescriptor.setValue( "value", convertAnnotationsMap.values().toArray( new Convert[convertAnnotationsMap.size()]) );
+ groupingDescriptor.setValue(
+ "value",
+ convertAnnotationsMap.values().toArray( new Convert[0] )
+ );
return AnnotationFactory.create( groupingDescriptor );
}
@@ -604,7 +599,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
defaults
);
try {
- final Class converterClass = classLoaderAccess.classForName( converterClassName );
+ final Class> converterClass = classLoaderAccess.classForName( converterClassName );
convertAnnotationDescriptor.setValue( "converter", converterClass );
}
catch (ClassLoadingException e) {
@@ -644,7 +639,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
if ( physicalAnnotation != null ) {
// only add if no XML element named a converter for this attribute
final String qualifiedAttributeName = qualifyConverterAttributeName( attributeNamePrefix, physicalAnnotation.attributeName() );
- if ( ! convertAnnotationsMap.containsKey( qualifiedAttributeName ) ) {
+ if ( !convertAnnotationsMap.containsKey( qualifiedAttributeName ) ) {
convertAnnotationsMap.put( qualifiedAttributeName, physicalAnnotation );
}
}
@@ -653,7 +648,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
for ( Convert convertAnnotation : physicalGroupingAnnotation.value() ) {
// again, only add if no XML element named a converter for this attribute
final String qualifiedAttributeName = qualifyConverterAttributeName( attributeNamePrefix, convertAnnotation.attributeName() );
- if ( ! convertAnnotationsMap.containsKey( qualifiedAttributeName ) ) {
+ if ( !convertAnnotationsMap.containsKey( qualifiedAttributeName ) ) {
convertAnnotationsMap.put( qualifiedAttributeName, convertAnnotation );
}
}
@@ -661,12 +656,13 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
}
private void checkForOrphanProperties(ManagedType root) {
- Class clazz;
+ Class> clazz;
try {
clazz = classLoaderAccess.classForName( className );
}
- catch ( ClassLoadingException e ) {
- return; //a primitive type most likely
+ catch (ClassLoadingException e) {
+ //a primitive type most likely
+ return;
}
AttributesContainer container = root != null ? root.getAttributes() : null;
//put entity.attributes elements
@@ -703,14 +699,18 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
}
}
- private void checkForOrphanProperties(List elements, Set properties,
+ private void checkForOrphanProperties(
+ List elements,
+ Set properties,
Function super T, String> nameGetter) {
for ( T element : elements ) {
checkForOrphanProperties( element, properties, nameGetter );
}
}
- private void checkForOrphanProperties(T element, Set properties,
+ private void checkForOrphanProperties(
+ T element,
+ Set properties,
Function super T, String> nameGetter) {
if ( element == null ) {
return;
@@ -726,17 +726,14 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
*
* @param annotationList The list of annotations.
* @param annotation The annotation to add to the list.
- *
* @return The annotation which was added to the list or {@code null}.
*/
- private Annotation addIfNotNull(List annotationList, Annotation annotation) {
+ private void addIfNotNull(List annotationList, Annotation annotation) {
if ( annotation != null ) {
annotationList.add( annotation );
}
- return annotation;
}
- //TODO mutualize the next 2 methods
private Annotation getTableGenerator(PropertyMappingElementCollector elementsForProperty, XMLContext.Default defaults) {
for ( JaxbId element : elementsForProperty.getId() ) {
JaxbTableGenerator subelement = element.getTableGenerator();
@@ -842,7 +839,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
}
}
AnnotationDescriptor ad = new AnnotationDescriptor( EntityListeners.class );
- ad.setValue( "value", entityListenerClasses.toArray( new Class[0] ) );
+ ad.setValue( "value", entityListenerClasses.toArray( new Class[ 0 ] ) );
return AnnotationFactory.create( ad );
}
else if ( defaults.canUseJavaAnnotations() ) {
@@ -943,7 +940,9 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
return annotation;
}
- private void getJoinTable(List annotationList, AssociationAttribute associationAttribute,
+ private void getJoinTable(
+ List annotationList,
+ AssociationAttribute associationAttribute,
XMLContext.Default defaults) {
addIfNotNull( annotationList, buildJoinTable( associationAttribute.getJoinTable(), defaults ) );
}
@@ -1105,7 +1104,9 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
afterGetAssociation( ManyToAny.class, annotationList, defaults );
}
- private void afterGetAssociation(Class extends Annotation> annotationType, List annotationList,
+ private void afterGetAssociation(
+ Class extends Annotation> annotationType,
+ List annotationList,
XMLContext.Default defaults) {
if ( elementsForProperty.isEmpty() && defaults.canUseJavaAnnotations() ) {
Annotation annotation = getPhysicalAnnotation( annotationType );
@@ -1229,7 +1230,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
joinColumns.add( AnnotationFactory.create( column ) );
}
}
- return joinColumns.toArray( new MapKeyJoinColumn[0] );
+ return joinColumns.toArray( new MapKeyJoinColumn[ 0 ] );
}
private AttributeOverrides getMapKeyAttributeOverrides(List elements, XMLContext.Default defaults) {
@@ -1273,6 +1274,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
return null;
}
}
+
/**
* Adds a @MapKeyEnumerated annotation to the specified annotationList if the specified element
* contains a map-key-enumerated sub-element. This should only be the case for
@@ -1347,10 +1349,8 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
try {
clazz = classLoaderAccess.classForName( XMLContext.buildSafeClassName( className, defaults ) );
}
- catch ( ClassLoadingException e ) {
- throw new AnnotationException(
- "Unable to find " + nodeName + ": " + className, e
- );
+ catch (ClassLoadingException e) {
+ throw new AnnotationException( "Unable to find " + nodeName + ": " + className, e );
}
ad.setValue( getJavaAttributeNameFromXMLOne( nodeName ), clazz );
}
@@ -1436,13 +1436,13 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
String mapKeyClassName = element.getClazz();
AnnotationDescriptor ad = new AnnotationDescriptor( MapKeyClass.class );
if ( isNotEmpty( mapKeyClassName ) ) {
- Class clazz;
+ Class> clazz;
try {
clazz = classLoaderAccess.classForName(
XMLContext.buildSafeClassName( mapKeyClassName, defaults )
);
}
- catch ( ClassLoadingException e ) {
+ catch (ClassLoadingException e) {
throw new AnnotationException(
"Unable to find " + nodeName + ": " + mapKeyClassName, e
);
@@ -1513,7 +1513,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
cascades.add( CascadeType.PERSIST );
}
if ( cascades.size() > 0 ) {
- ad.setValue( "cascade", cascades.toArray( new CascadeType[cascades.size()] ) );
+ ad.setValue( "cascade", cascades.toArray( new CascadeType[0] ) );
}
}
@@ -1742,17 +1742,12 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
private boolean isProcessingId(XMLContext.Default defaults) {
boolean isExplicit = defaults.getAccess() != null;
- boolean correctAccess =
- ( PropertyType.PROPERTY.equals( propertyType ) && AccessType.PROPERTY.equals( defaults.getAccess() ) )
- || ( PropertyType.FIELD.equals( propertyType ) && AccessType.FIELD
- .equals( defaults.getAccess() ) );
+ boolean correctAccess = ( PropertyType.PROPERTY.equals( propertyType ) && AccessType.PROPERTY.equals( defaults.getAccess() ) )
+ || ( PropertyType.FIELD.equals( propertyType ) && AccessType.FIELD.equals( defaults.getAccess() ) );
boolean hasId = defaults.canUseJavaAnnotations()
&& ( isPhysicalAnnotationPresent( Id.class ) || isPhysicalAnnotationPresent( EmbeddedId.class ) );
- //if ( properAccessOnMetadataComplete || properOverridingOnMetadataNonComplete ) {
- boolean mirrorAttributeIsId = defaults.canUseJavaAnnotations() &&
- ( mirroredAttribute != null &&
- ( mirroredAttribute.isAnnotationPresent( Id.class )
- || mirroredAttribute.isAnnotationPresent( EmbeddedId.class ) ) );
+ boolean mirrorAttributeIsId = defaults.canUseJavaAnnotations()
+ && hasAnnotation( mirroredAttribute, Id.class, EmbeddedId.class );
boolean propertyIsDefault = PropertyType.PROPERTY.equals( propertyType )
&& !mirrorAttributeIsId;
return correctAccess || ( !isExplicit && hasId ) || ( !isExplicit && propertyIsDefault );
@@ -1765,7 +1760,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
List columns = new ArrayList<>( 1 );
columns.add( getColumn( element, false, nodeName ) );
AnnotationDescriptor columnsDescr = new AnnotationDescriptor( Columns.class );
- columnsDescr.setValue( "columns", columns.toArray( new Column[ columns.size() ] ) );
+ columnsDescr.setValue( "columns", columns.toArray( new Column[0] ) );
return AnnotationFactory.create( columnsDescr );
}
@@ -1836,8 +1831,10 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
* element, if present and not disabled by the XMLContext defaults.
* In some contexts (such as an element-collection mapping) merging
*/
- private AssociationOverrides getAssociationOverrides(List elements, XMLContext.Default defaults,
- boolean mergeWithAnnotations) {
+ private AssociationOverrides getAssociationOverrides(
+ List elements,
+ XMLContext.Default defaults,
+ boolean mergeWithAnnotations) {
List attributes = buildAssociationOverrides( elements, defaults );
if ( mergeWithAnnotations && defaults.canUseJavaAnnotations() ) {
AssociationOverride annotation = getPhysicalAnnotation( AssociationOverride.class );
@@ -1851,7 +1848,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
}
if ( attributes.size() > 0 ) {
AnnotationDescriptor ad = new AnnotationDescriptor( AssociationOverrides.class );
- ad.setValue( "value", attributes.toArray( new AssociationOverride[attributes.size()] ) );
+ ad.setValue( "value", attributes.toArray( new AssociationOverride[0] ) );
return AnnotationFactory.create( ad );
}
else {
@@ -1892,7 +1889,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
joinColumns.add( AnnotationFactory.create( column ) );
}
}
- return joinColumns.toArray( new JoinColumn[joinColumns.size()] );
+ return joinColumns.toArray( new JoinColumn[0] );
}
private void addAssociationOverrideIfNeeded(AssociationOverride annotation, List overrides) {
@@ -1924,17 +1921,19 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
* In some contexts (such as an association mapping) merging with
* annotations is never allowed.
*/
- private AttributeOverrides getAttributeOverrides(List elements, XMLContext.Default defaults,
- boolean mergeWithAnnotations) {
+ private AttributeOverrides getAttributeOverrides(
+ List elements,
+ XMLContext.Default defaults,
+ boolean mergeWithAnnotations) {
List attributes = buildAttributeOverrides( elements, "attribute-override" );
return mergeAttributeOverrides( defaults, attributes, mergeWithAnnotations );
}
/**
* @param mergeWithAnnotations Whether to use Java annotations for this
- * element, if present and not disabled by the XMLContext defaults.
- * In some contexts (such as an association mapping) merging with
- * annotations is never allowed.
+ * element, if present and not disabled by the XMLContext defaults.
+ * In some contexts (such as an association mapping) merging with
+ * annotations is never allowed.
*/
private AttributeOverrides mergeAttributeOverrides(XMLContext.Default defaults, List attributes, boolean mergeWithAnnotations) {
if ( mergeWithAnnotations && defaults.canUseJavaAnnotations() ) {
@@ -1949,7 +1948,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
}
if ( attributes.size() > 0 ) {
AnnotationDescriptor ad = new AnnotationDescriptor( AttributeOverrides.class );
- ad.setValue( "value", attributes.toArray( new AttributeOverride[attributes.size()] ) );
+ ad.setValue( "value", attributes.toArray( new AttributeOverride[ attributes.size() ] ) );
return AnnotationFactory.create( ad );
}
else {
@@ -1984,7 +1983,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
copyAttribute( column, "length", element.getLength(), false );
copyAttribute( column, "precision", element.getPrecision(), false );
copyAttribute( column, "scale", element.getScale(), false );
- return (Column) AnnotationFactory.create( column );
+ return AnnotationFactory.create( column );
}
else {
if ( isMandatory ) {
@@ -2050,8 +2049,10 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
);
}
- private Annotation getMarkerAnnotation(Class extends Annotation> clazz, JaxbEmptyType element,
- XMLContext.Default defaults) {
+ private Annotation getMarkerAnnotation(
+ Class extends Annotation> clazz,
+ JaxbEmptyType element,
+ XMLContext.Default defaults) {
if ( element != null ) {
return AnnotationFactory.create( new AnnotationDescriptor( clazz ) );
}
@@ -2080,7 +2081,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
}
if ( results.size() > 0 ) {
AnnotationDescriptor ad = new AnnotationDescriptor( SqlResultSetMappings.class );
- ad.setValue( "value", results.toArray( new SqlResultSetMapping[results.size()] ) );
+ ad.setValue( "value", results.toArray( new SqlResultSetMapping[ results.size() ] ) );
return AnnotationFactory.create( ad );
}
else {
@@ -2103,7 +2104,6 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
bindNamedSubgraph( defaults, ann, "subclassSubgraphs", element.getSubclassSubgraph(), classLoaderAccess );
namedEntityGraphList.add( AnnotationFactory.create( ann ) );
}
- //TODO
return namedEntityGraphList;
}
@@ -2118,17 +2118,17 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
AnnotationDescriptor annSubgraphNode = new AnnotationDescriptor( NamedSubgraph.class );
copyAttribute( annSubgraphNode, "name", subgraphNode.getName(), true );
String clazzName = subgraphNode.getClazz();
- Class clazz;
+ final Class> clazz;
try {
clazz = classLoaderAccess.classForName(
XMLContext.buildSafeClassName( clazzName, defaults )
);
}
- catch ( ClassLoadingException e ) {
+ catch (ClassLoadingException e) {
throw new AnnotationException( "Unable to find entity-class: " + clazzName, e );
}
annSubgraphNode.setValue( "type", clazz );
- bindNamedAttributeNodes(subgraphNode.getNamedAttributeNode(), annSubgraphNode);
+ bindNamedAttributeNodes( subgraphNode.getNamedAttributeNode(), annSubgraphNode );
annSubgraphNodes.add( AnnotationFactory.create( annSubgraphNode ) );
}
@@ -2144,7 +2144,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
copyAttribute( annNamedAttributeNode, "key-subgraph", element.getKeySubgraph(), false );
annNamedAttributeNodes.add( AnnotationFactory.create( annNamedAttributeNode ) );
}
- ann.setValue( "attributeNodes", annNamedAttributeNodes.toArray( new NamedAttributeNode[0] ) );
+ ann.setValue( "attributeNodes", annNamedAttributeNodes.toArray( new NamedAttributeNode[ 0 ] ) );
}
public static List buildNamedStoreProcedureQueries(
@@ -2176,7 +2176,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
XMLContext.buildSafeClassName( clazzName, defaults )
);
}
- catch ( ClassLoadingException e ) {
+ catch (ClassLoadingException e) {
throw new AnnotationException( "Unable to find entity-class: " + clazzName, e );
}
parameterDescriptor.setValue( "type", clazz );
@@ -2185,26 +2185,26 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
ann.setValue(
"parameters",
- storedProcedureParameters.toArray( new StoredProcedureParameter[0] )
+ storedProcedureParameters.toArray( new StoredProcedureParameter[ 0 ] )
);
- List> returnClasses = new ArrayList<>();
+ final List> returnClasses = new ArrayList<>();
for ( String clazzName : element.getResultClass() ) {
- Class> clazz;
+ final Class> clazz;
try {
clazz = classLoaderAccess.classForName(
XMLContext.buildSafeClassName( clazzName, defaults )
);
}
- catch ( ClassLoadingException e ) {
+ catch (ClassLoadingException e) {
throw new AnnotationException( "Unable to find entity-class: " + clazzName, e );
}
returnClasses.add( clazz );
}
- ann.setValue( "resultClasses", returnClasses.toArray( new Class[0] ) );
+ ann.setValue( "resultClasses", returnClasses.toArray( new Class[ 0 ] ) );
- ann.setValue( "resultSetMappings", element.getResultSetMapping().toArray( new String[0] ) );
+ ann.setValue( "resultSetMappings", element.getResultSetMapping().toArray( new String[ 0 ] ) );
buildQueryHints( element.getHint(), ann, Collections.emptyMap() );
namedStoredProcedureQueries.add( AnnotationFactory.create( ann ) );
}
@@ -2255,19 +2255,19 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
if ( entityResultAnnotations != null && !entityResultAnnotations.isEmpty() ) {
resultSetMappingAnnotation.setValue(
"entities",
- entityResultAnnotations.toArray( new EntityResult[entityResultAnnotations.size()] )
+ entityResultAnnotations.toArray( new EntityResult[ entityResultAnnotations.size() ] )
);
}
if ( columnResultAnnotations != null && !columnResultAnnotations.isEmpty() ) {
resultSetMappingAnnotation.setValue(
"columns",
- columnResultAnnotations.toArray( new ColumnResult[columnResultAnnotations.size()] )
+ columnResultAnnotations.toArray( new ColumnResult[ columnResultAnnotations.size() ] )
);
}
if ( constructorResultAnnotations != null && !constructorResultAnnotations.isEmpty() ) {
resultSetMappingAnnotation.setValue(
"classes",
- constructorResultAnnotations.toArray( new ConstructorResult[constructorResultAnnotations.size()] )
+ constructorResultAnnotations.toArray( new ConstructorResult[ constructorResultAnnotations.size() ] )
);
}
@@ -2297,12 +2297,13 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
fieldResultAnnotations.add( AnnotationFactory.create( fieldResultDescriptor ) );
}
entityResultDescriptor.setValue(
- "fields", fieldResultAnnotations.toArray( new FieldResult[fieldResultAnnotations.size()] )
+ "fields",
+ fieldResultAnnotations.toArray( new FieldResult[ fieldResultAnnotations.size() ] )
);
return AnnotationFactory.create( entityResultDescriptor );
}
- private static Class resolveClassReference(
+ private static Class> resolveClassReference(
String className,
XMLContext.Default defaults,
ClassLoaderAccess classLoaderAccess) {
@@ -2314,7 +2315,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
XMLContext.buildSafeClassName( className, defaults )
);
}
- catch ( ClassLoadingException e ) {
+ catch (ClassLoadingException e) {
throw new AnnotationException( "Unable to find specified class: " + className, e );
}
}
@@ -2338,7 +2339,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
ClassLoaderAccess classLoaderAccess) {
AnnotationDescriptor constructorResultDescriptor = new AnnotationDescriptor( ConstructorResult.class );
- final Class entityClass = resolveClassReference( constructorResultElement.getTargetClass(), defaults, classLoaderAccess );
+ final Class> entityClass = resolveClassReference( constructorResultElement.getTargetClass(), defaults, classLoaderAccess );
constructorResultDescriptor.setValue( "targetClass", entityClass );
List columnResultAnnotations = new ArrayList<>();
@@ -2815,7 +2816,7 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
try {
clazz = classLoaderAccess.classForName( XMLContext.buildSafeClassName( className, defaults ) );
}
- catch ( ClassLoadingException e ) {
+ catch (ClassLoadingException e) {
throw new AnnotationException( "Unable to find id-class: " + className, e );
}
ad.setValue( "value", clazz );
@@ -2842,8 +2843,8 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
/**
* @param mergeWithAnnotations Whether to use Java annotations for this
- * element, if present and not disabled by the XMLContext defaults.
- * In some contexts (such as an association mapping) merging with
+ * element, if present and not disabled by the XMLContext defaults.
+ * In some contexts (such as an association mapping) merging with
*/
private PrimaryKeyJoinColumns getPrimaryKeyJoinColumns(
List elements,
@@ -2921,7 +2922,8 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
return AnnotationFactory.create( entity );
}
else {
- return null; //this is not an entity
+ //this is not an entity
+ return null;
}
}
}
@@ -3081,8 +3083,9 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
annotation.setValue( "indexes", indexes );
}
- private static void buildUniqueConstraints(AnnotationDescriptor annotation,
- List elements) {
+ private static void buildUniqueConstraints(
+ AnnotationDescriptor annotation,
+ List elements) {
UniqueConstraint[] uniqueConstraints = new UniqueConstraint[ elements.size() ];
int i = 0;
for ( JaxbUniqueConstraint element : elements ) {
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/internal/JPAXMLOverriddenMetadataProvider.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/JPAXMLOverriddenMetadataProvider.java
similarity index 99%
rename from hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/internal/JPAXMLOverriddenMetadataProvider.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/JPAXMLOverriddenMetadataProvider.java
index 831dfa07a5..816ab3517d 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/internal/JPAXMLOverriddenMetadataProvider.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/JPAXMLOverriddenMetadataProvider.java
@@ -4,7 +4,7 @@
* 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.cfg.annotations.reflection.internal;
+package org.hibernate.boot.model.internal;
import java.lang.reflect.AnnotatedElement;
import java.util.ArrayList;
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/JoinedSubclassFkSecondPass.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/JoinedSubclassFkSecondPass.java
similarity index 87%
rename from hibernate-core/src/main/java/org/hibernate/cfg/JoinedSubclassFkSecondPass.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/JoinedSubclassFkSecondPass.java
index 4af2f2f605..a059393fe8 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/JoinedSubclassFkSecondPass.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/JoinedSubclassFkSecondPass.java
@@ -2,15 +2,14 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
+package org.hibernate.boot.model.internal;
import java.util.Map;
import org.hibernate.MappingException;
import org.hibernate.boot.spi.MetadataBuildingContext;
-import org.hibernate.cfg.annotations.TableBinder;
import org.hibernate.mapping.JoinedSubclass;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.SimpleValue;
@@ -32,14 +31,17 @@ public class JoinedSubclassFkSecondPass extends FkSecondPass {
this.buildingContext = buildingContext;
}
+ @Override
public String getReferencedEntityName() {
return entity.getSuperclass().getEntityName();
}
+ @Override
public boolean isInPrimaryKey() {
return true;
}
+ @Override
public void doSecondPass(Map persistentClasses) throws MappingException {
TableBinder.bindForeignKey( entity.getSuperclass(), entity, columns, value, false, buildingContext );
}
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/ListBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ListBinder.java
similarity index 89%
rename from hibernate-core/src/main/java/org/hibernate/cfg/annotations/ListBinder.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/ListBinder.java
index 53270449af..eeaf6b7d3b 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/ListBinder.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ListBinder.java
@@ -2,9 +2,9 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg.annotations;
+package org.hibernate.boot.model.internal;
import java.util.Map;
import java.util.function.Supplier;
@@ -13,10 +13,7 @@ import org.hibernate.AnnotationException;
import org.hibernate.MappingException;
import org.hibernate.annotations.OrderBy;
import org.hibernate.boot.spi.MetadataBuildingContext;
-import org.hibernate.cfg.CollectionSecondPass;
-import org.hibernate.cfg.PropertyHolder;
-import org.hibernate.cfg.PropertyHolderBuilder;
-import org.hibernate.cfg.SecondPass;
+import org.hibernate.boot.spi.SecondPass;
import org.hibernate.mapping.Collection;
import org.hibernate.mapping.IndexBackref;
import org.hibernate.mapping.List;
@@ -62,8 +59,7 @@ public class ListBinder extends CollectionBinder {
public SecondPass getSecondPass() {
return new CollectionSecondPass( ListBinder.this.collection ) {
@Override
- public void secondPass(Map persistentClasses)
- throws MappingException {
+ public void secondPass(Map persistentClasses) throws MappingException {
bindStarToManySecondPass( persistentClasses );
bindIndex();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/MapBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/MapBinder.java
similarity index 95%
rename from hibernate-core/src/main/java/org/hibernate/cfg/annotations/MapBinder.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/MapBinder.java
index c90fffe068..779cc2cd21 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/MapBinder.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/MapBinder.java
@@ -2,9 +2,9 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg.annotations;
+package org.hibernate.boot.model.internal;
import java.util.List;
import java.util.function.Supplier;
@@ -16,19 +16,10 @@ import org.hibernate.MappingException;
import org.hibernate.annotations.MapKeyCompositeType;
import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.annotations.common.reflection.XProperty;
+import org.hibernate.boot.spi.AccessType;
import org.hibernate.boot.spi.BootstrapContext;
import org.hibernate.boot.spi.MetadataBuildingContext;
-import org.hibernate.cfg.AccessType;
-import org.hibernate.cfg.AnnotatedClassType;
-import org.hibernate.cfg.AnnotatedColumns;
-import org.hibernate.cfg.AnnotatedJoinColumns;
-import org.hibernate.cfg.AnnotationBinder;
-import org.hibernate.cfg.CollectionPropertyHolder;
-import org.hibernate.cfg.CollectionSecondPass;
-import org.hibernate.cfg.AnnotatedJoinColumn;
-import org.hibernate.cfg.InheritanceState;
-import org.hibernate.cfg.PropertyPreloadedData;
-import org.hibernate.cfg.SecondPass;
+import org.hibernate.boot.spi.SecondPass;
import org.hibernate.engine.jdbc.Size;
import org.hibernate.mapping.BasicValue;
import org.hibernate.mapping.Collection;
@@ -58,10 +49,10 @@ import jakarta.persistence.MapKeyColumn;
import jakarta.persistence.MapKeyJoinColumn;
import jakarta.persistence.MapKeyJoinColumns;
-import static org.hibernate.cfg.AnnotatedClassType.EMBEDDABLE;
-import static org.hibernate.cfg.BinderHelper.findPropertyByName;
-import static org.hibernate.cfg.BinderHelper.isPrimitive;
-import static org.hibernate.cfg.PropertyHolderBuilder.buildPropertyHolder;
+import static org.hibernate.boot.model.internal.AnnotatedClassType.EMBEDDABLE;
+import static org.hibernate.boot.model.internal.BinderHelper.findPropertyByName;
+import static org.hibernate.boot.model.internal.BinderHelper.isPrimitive;
+import static org.hibernate.boot.model.internal.PropertyHolderBuilder.buildPropertyHolder;
import static org.hibernate.internal.util.StringHelper.nullIfEmpty;
import static org.hibernate.internal.util.StringHelper.qualify;
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/MapKeyColumnDelegator.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/MapKeyColumnDelegator.java
similarity index 82%
rename from hibernate-core/src/main/java/org/hibernate/cfg/annotations/MapKeyColumnDelegator.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/MapKeyColumnDelegator.java
index 15331078e5..89bf92ddcd 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/MapKeyColumnDelegator.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/MapKeyColumnDelegator.java
@@ -2,10 +2,12 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg.annotations;
+package org.hibernate.boot.model.internal;
+
import java.lang.annotation.Annotation;
+
import jakarta.persistence.Column;
import jakarta.persistence.MapKeyColumn;
@@ -20,46 +22,57 @@ public class MapKeyColumnDelegator implements Column {
this.column = column;
}
+ @Override
public String name() {
return column.name();
}
+ @Override
public boolean unique() {
return column.unique();
}
+ @Override
public boolean nullable() {
return column.nullable();
}
+ @Override
public boolean insertable() {
return column.insertable();
}
+ @Override
public boolean updatable() {
return column.updatable();
}
+ @Override
public String columnDefinition() {
return column.columnDefinition();
}
+ @Override
public String table() {
return column.table();
}
+ @Override
public int length() {
return column.length();
}
+ @Override
public int precision() {
return column.precision();
}
+ @Override
public int scale() {
return column.scale();
}
+ @Override
public Class extends Annotation> annotationType() {
return Column.class;
}
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/MapKeyJoinColumnDelegator.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/MapKeyJoinColumnDelegator.java
similarity index 91%
rename from hibernate-core/src/main/java/org/hibernate/cfg/annotations/MapKeyJoinColumnDelegator.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/MapKeyJoinColumnDelegator.java
index c990fa7b98..59d7123da0 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/MapKeyJoinColumnDelegator.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/MapKeyJoinColumnDelegator.java
@@ -2,11 +2,12 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg.annotations;
+package org.hibernate.boot.model.internal;
import java.lang.annotation.Annotation;
+
import jakarta.persistence.Column;
import jakarta.persistence.ForeignKey;
import jakarta.persistence.JoinColumn;
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/Nullability.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/Nullability.java
similarity index 69%
rename from hibernate-core/src/main/java/org/hibernate/cfg/annotations/Nullability.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/Nullability.java
index d75332a3cc..db3be47b01 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/Nullability.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/Nullability.java
@@ -2,9 +2,9 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg.annotations;
+package org.hibernate.boot.model.internal;
/**
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/internal/NullableDiscriminatorColumnSecondPass.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/NullableDiscriminatorColumnSecondPass.java
similarity index 88%
rename from hibernate-core/src/main/java/org/hibernate/cfg/internal/NullableDiscriminatorColumnSecondPass.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/NullableDiscriminatorColumnSecondPass.java
index 05577788da..ef23021678 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/internal/NullableDiscriminatorColumnSecondPass.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/NullableDiscriminatorColumnSecondPass.java
@@ -2,14 +2,14 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg.internal;
+package org.hibernate.boot.model.internal;
import java.util.Map;
import org.hibernate.MappingException;
-import org.hibernate.cfg.SecondPass;
+import org.hibernate.boot.spi.SecondPass;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Selectable;
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/ObjectNameSource.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ObjectNameSource.java
similarity index 81%
rename from hibernate-core/src/main/java/org/hibernate/cfg/ObjectNameSource.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/ObjectNameSource.java
index d66ea1cba2..95f641a50c 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/ObjectNameSource.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ObjectNameSource.java
@@ -2,9 +2,9 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
+package org.hibernate.boot.model.internal;
/**
* Source for database object names (identifiers).
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/OneToOneSecondPass.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/OneToOneSecondPass.java
similarity index 89%
rename from hibernate-core/src/main/java/org/hibernate/cfg/OneToOneSecondPass.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/OneToOneSecondPass.java
index 3ee9a002e7..a051bfed10 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/OneToOneSecondPass.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/OneToOneSecondPass.java
@@ -2,14 +2,12 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
+package org.hibernate.boot.model.internal;
import java.util.Map;
-import jakarta.persistence.ForeignKey;
-
import org.hibernate.AnnotationException;
import org.hibernate.MappingException;
import org.hibernate.annotations.LazyGroup;
@@ -18,7 +16,8 @@ import org.hibernate.annotations.OnDeleteAction;
import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.boot.spi.MetadataBuildingContext;
-import org.hibernate.cfg.annotations.PropertyBinder;
+import org.hibernate.boot.spi.PropertyData;
+import org.hibernate.boot.spi.SecondPass;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.Component;
import org.hibernate.mapping.DependantValue;
@@ -31,10 +30,13 @@ import org.hibernate.mapping.Property;
import org.hibernate.mapping.SortableValue;
import org.hibernate.type.ForeignKeyDirection;
-import static org.hibernate.cfg.BinderHelper.findPropertyByName;
-import static org.hibernate.cfg.BinderHelper.getPath;
-import static org.hibernate.cfg.ToOneBinder.bindForeignKeyNameAndDefinition;
-import static org.hibernate.cfg.ToOneBinder.getReferenceEntityName;
+import jakarta.persistence.ForeignKey;
+
+import static org.hibernate.boot.model.internal.BinderHelper.findPropertyByName;
+import static org.hibernate.boot.model.internal.BinderHelper.getPath;
+import static org.hibernate.boot.model.internal.ToOneBinder.bindForeignKeyNameAndDefinition;
+import static org.hibernate.boot.model.internal.ToOneBinder.defineFetchingStrategy;
+import static org.hibernate.boot.model.internal.ToOneBinder.getReferenceEntityName;
import static org.hibernate.internal.util.StringHelper.qualify;
import static org.hibernate.type.ForeignKeyDirection.FROM_PARENT;
import static org.hibernate.type.ForeignKeyDirection.TO_PARENT;
@@ -47,7 +49,6 @@ public class OneToOneSecondPass implements SecondPass {
private final MetadataBuildingContext buildingContext;
private final String mappedBy;
private final String ownerEntity;
- private final String ownerProperty;
private final PropertyHolder propertyHolder;
private final NotFoundAction notFoundAction;
private final PropertyData inferredData;
@@ -57,11 +58,10 @@ public class OneToOneSecondPass implements SecondPass {
private final String cascadeStrategy;
private final AnnotatedJoinColumns joinColumns;
- //that sucks, we should read that from the property mainly
public OneToOneSecondPass(
String mappedBy,
String ownerEntity,
- String ownerProperty,
+ @SuppressWarnings("unused") String ownerProperty,
PropertyHolder propertyHolder,
PropertyData inferredData,
XClass targetEntity,
@@ -72,7 +72,6 @@ public class OneToOneSecondPass implements SecondPass {
AnnotatedJoinColumns columns,
MetadataBuildingContext buildingContext) {
this.ownerEntity = ownerEntity;
- this.ownerProperty = ownerProperty;
this.mappedBy = mappedBy;
this.propertyHolder = propertyHolder;
this.buildingContext = buildingContext;
@@ -85,7 +84,7 @@ public class OneToOneSecondPass implements SecondPass {
this.joinColumns = columns;
}
- //TODO refactor this code, there is a lot of duplication in this method
+ @Override
public void doSecondPass(Map persistentClasses) throws MappingException {
final OneToOne value = new OneToOne(
buildingContext,
@@ -97,7 +96,7 @@ public class OneToOneSecondPass implements SecondPass {
final String referencedEntityName = getReferenceEntityName( inferredData, targetEntity, buildingContext );
value.setReferencedEntityName( referencedEntityName );
XProperty property = inferredData.getProperty();
- ToOneBinder.defineFetchingStrategy( value, property, inferredData, propertyHolder );
+ defineFetchingStrategy( value, property, inferredData, propertyHolder );
//value.setFetchMode( fetchMode );
value.setOnDeleteAction( onDeleteAction );
//value.setLazy( fetchMode != FetchMode.JOIN );
@@ -174,7 +173,6 @@ public class OneToOneSecondPass implements SecondPass {
persistentClasses.get( ownerEntity ), targetProperty, otherSideJoin
);
final ManyToOne manyToOne = new ManyToOne( buildingContext, mappedByJoin.getTable() );
- //FIXME use ignore not found here
manyToOne.setNotFoundAction( notFoundAction );
manyToOne.setOnDeleteAction( oneToOne.getOnDeleteAction() );
manyToOne.setFetchMode( oneToOne.getFetchMode() );
@@ -239,13 +237,6 @@ public class OneToOneSecondPass implements SecondPass {
}
private void bindOwned(Map persistentClasses, OneToOne oneToOne, String propertyName, Property property) {
- // we need to check if the columns are in the right order
- // if not, then we need to create a many to one and formula
- // but actually, since entities linked by a one to one need
- // to share the same composite id class, this cannot happen
-// boolean rightOrder = true;
-//
-// if ( rightOrder ) {
final ToOneFkSecondPass secondPass = new ToOneFkSecondPass(
oneToOne,
joinColumns,
@@ -257,10 +248,6 @@ public class OneToOneSecondPass implements SecondPass {
secondPass.doSecondPass(persistentClasses);
//no column associated since it's a one to one
propertyHolder.addProperty( property, inferredData.getDeclaringClass() );
-// }
-// else {
- // this is a @ManyToOne with Formula
-// }
}
/**
@@ -283,10 +270,9 @@ public class OneToOneSecondPass implements SecondPass {
join.disableForeignKeyCreation();
}
- //TODO support @ForeignKey
join.setKey( key );
- //TODO support for inverse and optional
- join.setOptional( true ); //perhaps not quite per-spec, but a Good Thing anyway
+ //perhaps not quite per-spec, but a Good Thing anyway
+ join.setOptional( true );
key.setOnDeleteAction( null );
for ( Column column: otherSideProperty.getValue().getColumns() ) {
Column copy = new Column();
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/PersistentAttributeFilter.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/PersistentAttributeFilter.java
similarity index 79%
rename from hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/PersistentAttributeFilter.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/PersistentAttributeFilter.java
index 592ca19425..c4e3bb674d 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/PersistentAttributeFilter.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/PersistentAttributeFilter.java
@@ -2,9 +2,9 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg.annotations.reflection;
+package org.hibernate.boot.model.internal;
import org.hibernate.annotations.common.reflection.Filter;
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/PkDrivenByDefaultMapsIdSecondPass.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/PkDrivenByDefaultMapsIdSecondPass.java
similarity index 90%
rename from hibernate-core/src/main/java/org/hibernate/cfg/PkDrivenByDefaultMapsIdSecondPass.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/PkDrivenByDefaultMapsIdSecondPass.java
index cf46300f6a..8783cc6de6 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/PkDrivenByDefaultMapsIdSecondPass.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/PkDrivenByDefaultMapsIdSecondPass.java
@@ -2,14 +2,13 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
+package org.hibernate.boot.model.internal;
import java.util.Map;
import org.hibernate.AnnotationException;
import org.hibernate.MappingException;
-import org.hibernate.cfg.annotations.TableBinder;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.SimpleValue;
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/PrimitiveArrayBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/PrimitiveArrayBinder.java
similarity index 89%
rename from hibernate-core/src/main/java/org/hibernate/cfg/annotations/PrimitiveArrayBinder.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/PrimitiveArrayBinder.java
index 462aa37fa9..8228819d09 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/PrimitiveArrayBinder.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/PrimitiveArrayBinder.java
@@ -2,9 +2,9 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg.annotations;
+package org.hibernate.boot.model.internal;
import java.util.function.Supplier;
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/PropertyBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/PropertyBinder.java
similarity index 97%
rename from hibernate-core/src/main/java/org/hibernate/cfg/annotations/PropertyBinder.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/PropertyBinder.java
index 49a5f97489..acca551920 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/PropertyBinder.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/PropertyBinder.java
@@ -2,14 +2,15 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg.annotations;
+package org.hibernate.boot.model.internal;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Member;
+import java.util.Map;
-import jakarta.persistence.EmbeddedId;
-import jakarta.persistence.Id;
-import jakarta.persistence.Lob;
-import jakarta.persistence.Version;
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
import org.hibernate.HibernateException;
@@ -22,14 +23,15 @@ import org.hibernate.annotations.OptimisticLock;
import org.hibernate.annotations.ValueGenerationType;
import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.annotations.common.reflection.XProperty;
+import org.hibernate.binder.AttributeBinder;
import org.hibernate.boot.model.relational.ExportableProducer;
+import org.hibernate.boot.spi.AccessType;
import org.hibernate.boot.spi.MetadataBuildingContext;
-import org.hibernate.cfg.AccessType;
-import org.hibernate.cfg.AnnotatedColumns;
-import org.hibernate.cfg.AnnotationBinder;
-import org.hibernate.cfg.InheritanceState;
-import org.hibernate.cfg.PropertyHolder;
-import org.hibernate.cfg.PropertyPreloadedData;
+import org.hibernate.generator.AnnotationBasedGenerator;
+import org.hibernate.generator.BeforeExecutionGenerator;
+import org.hibernate.generator.Generator;
+import org.hibernate.generator.GeneratorCreationContext;
+import org.hibernate.generator.OnExecutionGenerator;
import org.hibernate.id.IdentifierGenerator;
import org.hibernate.id.factory.spi.CustomIdGeneratorCreationContext;
import org.hibernate.internal.CoreMessageLogger;
@@ -45,21 +47,16 @@ import org.hibernate.mapping.ToOne;
import org.hibernate.mapping.Value;
import org.hibernate.metamodel.spi.EmbeddableInstantiator;
import org.hibernate.property.access.spi.PropertyAccessStrategy;
-import org.hibernate.generator.AnnotationBasedGenerator;
-import org.hibernate.generator.Generator;
-import org.hibernate.binder.AttributeBinder;
-import org.hibernate.generator.GeneratorCreationContext;
-import org.hibernate.generator.OnExecutionGenerator;
-import org.hibernate.generator.BeforeExecutionGenerator;
+
import org.jboss.logging.Logger;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Member;
-import java.util.Map;
+import jakarta.persistence.EmbeddedId;
+import jakarta.persistence.Id;
+import jakarta.persistence.Lob;
+import jakarta.persistence.Version;
-import static org.hibernate.cfg.BinderHelper.getMappedSuperclassOrNull;
-import static org.hibernate.cfg.annotations.HCANNHelper.findContainingAnnotation;
+import static org.hibernate.boot.model.internal.BinderHelper.getMappedSuperclassOrNull;
+import static org.hibernate.boot.model.internal.HCANNHelper.findContainingAnnotation;
import static org.hibernate.internal.util.StringHelper.qualify;
/**
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/PropertyContainer.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/PropertyContainer.java
similarity index 98%
rename from hibernate-core/src/main/java/org/hibernate/cfg/PropertyContainer.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/PropertyContainer.java
index 9836133ae6..2b0083c318 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/PropertyContainer.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/PropertyContainer.java
@@ -2,12 +2,12 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
// $Id$
-package org.hibernate.cfg;
+package org.hibernate.boot.model.internal;
import java.util.ArrayList;
import java.util.HashMap;
@@ -18,16 +18,16 @@ import java.util.Map;
import java.util.TreeMap;
import org.hibernate.AnnotationException;
-import org.hibernate.annotations.Type;
import org.hibernate.annotations.JavaType;
import org.hibernate.annotations.ManyToAny;
import org.hibernate.annotations.Target;
+import org.hibernate.annotations.Type;
import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.boot.MappingException;
import org.hibernate.boot.jaxb.Origin;
import org.hibernate.boot.jaxb.SourceType;
-import org.hibernate.cfg.annotations.HCANNHelper;
+import org.hibernate.boot.spi.AccessType;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.CollectionHelper;
@@ -47,7 +47,7 @@ import jakarta.persistence.Transient;
*
* @author Hardy Ferentschik
*/
-class PropertyContainer {
+public class PropertyContainer {
private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, PropertyContainer.class.getName());
@@ -65,7 +65,7 @@ class PropertyContainer {
private final List persistentAttributes;
- PropertyContainer(XClass clazz, XClass entityAtStake, AccessType defaultClassLevelAccessType) {
+ public PropertyContainer(XClass clazz, XClass entityAtStake, AccessType defaultClassLevelAccessType) {
this.xClass = clazz;
this.entityAtStake = entityAtStake;
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/PropertyHolder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/PropertyHolder.java
similarity index 95%
rename from hibernate-core/src/main/java/org/hibernate/cfg/PropertyHolder.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/PropertyHolder.java
index e2d68952e5..3e3044a6d5 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/PropertyHolder.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/PropertyHolder.java
@@ -2,14 +2,9 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
-
-import jakarta.persistence.Column;
-import jakarta.persistence.ForeignKey;
-import jakarta.persistence.JoinColumn;
-import jakarta.persistence.JoinTable;
+package org.hibernate.boot.model.internal;
import org.hibernate.annotations.ColumnTransformer;
import org.hibernate.annotations.common.reflection.XClass;
@@ -21,6 +16,11 @@ import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
import org.hibernate.mapping.Table;
+import jakarta.persistence.Column;
+import jakarta.persistence.ForeignKey;
+import jakarta.persistence.JoinColumn;
+import jakarta.persistence.JoinTable;
+
/**
* Property holder abstract property containers from their direct implementation
*
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/PropertyHolderBuilder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/PropertyHolderBuilder.java
similarity index 92%
rename from hibernate-core/src/main/java/org/hibernate/cfg/PropertyHolderBuilder.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/PropertyHolderBuilder.java
index 5218fed364..2bf86e7ff7 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/PropertyHolderBuilder.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/PropertyHolderBuilder.java
@@ -2,16 +2,16 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
+package org.hibernate.boot.model.internal;
import java.util.Map;
import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.boot.spi.MetadataBuildingContext;
-import org.hibernate.cfg.annotations.EntityBinder;
+import org.hibernate.boot.spi.PropertyData;
import org.hibernate.mapping.Collection;
import org.hibernate.mapping.Component;
import org.hibernate.mapping.Join;
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/PropertyInferredData.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/PropertyInferredData.java
similarity index 89%
rename from hibernate-core/src/main/java/org/hibernate/cfg/PropertyInferredData.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/PropertyInferredData.java
index 059756d205..4ab1f2e3e0 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/PropertyInferredData.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/PropertyInferredData.java
@@ -2,17 +2,19 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
-
-import jakarta.persistence.Access;
+package org.hibernate.boot.model.internal;
import org.hibernate.MappingException;
import org.hibernate.annotations.Target;
import org.hibernate.annotations.common.reflection.ReflectionManager;
import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.annotations.common.reflection.XProperty;
+import org.hibernate.boot.spi.AccessType;
+import org.hibernate.boot.spi.PropertyData;
+
+import jakarta.persistence.Access;
/**
* Retrieve all inferred data from an annotated element
@@ -27,11 +29,6 @@ public class PropertyInferredData implements PropertyData {
private final ReflectionManager reflectionManager;
private final XClass declaringClass;
- @Override
- public String toString() {
- return String.format( "PropertyInferredData{property=%s, declaringClass=%s}", property, declaringClass );
- }
-
/**
* Take the annotated element for lazy process
*/
@@ -42,6 +39,12 @@ public class PropertyInferredData implements PropertyData {
this.reflectionManager = reflectionManager;
}
+ @Override
+ public String toString() {
+ return String.format( "PropertyInferredData{property=%s, declaringClass=%s}", property, declaringClass );
+ }
+
+ @Override
public AccessType getDefaultAccess() throws MappingException {
AccessType accessType = defaultAccess;
@@ -58,10 +61,12 @@ public class PropertyInferredData implements PropertyData {
return accessType;
}
+ @Override
public String getPropertyName() throws MappingException {
return property.getName();
}
+ @Override
public XClass getPropertyClass() throws MappingException {
if ( property.isAnnotationPresent( Target.class ) ) {
return reflectionManager.toXClass( property.getAnnotation( Target.class ).value() );
@@ -71,6 +76,7 @@ public class PropertyInferredData implements PropertyData {
}
}
+ @Override
public XClass getClassOrElement() throws MappingException {
if ( property.isAnnotationPresent( Target.class ) ) {
return reflectionManager.toXClass( property.getAnnotation( Target.class ).value() );
@@ -80,18 +86,22 @@ public class PropertyInferredData implements PropertyData {
}
}
+ @Override
public String getClassOrElementName() throws MappingException {
return getClassOrElement().getName();
}
+ @Override
public String getTypeName() throws MappingException {
return getPropertyClass().getName();
}
+ @Override
public XProperty getProperty() {
return property;
}
+ @Override
public XClass getDeclaringClass() {
return declaringClass;
}
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/internal/PropertyMappingElementCollector.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/PropertyMappingElementCollector.java
similarity index 99%
rename from hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/internal/PropertyMappingElementCollector.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/PropertyMappingElementCollector.java
index 3dc3f7a613..42762a511e 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/internal/PropertyMappingElementCollector.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/PropertyMappingElementCollector.java
@@ -4,7 +4,7 @@
* 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.cfg.annotations.reflection.internal;
+package org.hibernate.boot.model.internal;
import java.util.ArrayList;
import java.util.Collections;
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/PropertyPreloadedData.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/PropertyPreloadedData.java
similarity index 83%
rename from hibernate-core/src/main/java/org/hibernate/cfg/PropertyPreloadedData.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/PropertyPreloadedData.java
index a4f2ab6902..6c698a88b0 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/PropertyPreloadedData.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/PropertyPreloadedData.java
@@ -2,12 +2,15 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
+package org.hibernate.boot.model.internal;
+
import org.hibernate.MappingException;
import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.annotations.common.reflection.XProperty;
+import org.hibernate.boot.spi.AccessType;
+import org.hibernate.boot.spi.PropertyData;
public class PropertyPreloadedData implements PropertyData {
private final AccessType defaultAccess;
@@ -22,34 +25,42 @@ public class PropertyPreloadedData implements PropertyData {
this.returnedClass = returnedClass;
}
+ @Override
public AccessType getDefaultAccess() throws MappingException {
return defaultAccess;
}
+ @Override
public String getPropertyName() throws MappingException {
return propertyName;
}
+ @Override
public XClass getClassOrElement() throws MappingException {
return getPropertyClass();
}
+ @Override
public XClass getPropertyClass() throws MappingException {
return returnedClass;
}
+ @Override
public String getClassOrElementName() throws MappingException {
return getTypeName();
}
+ @Override
public String getTypeName() throws MappingException {
return returnedClass == null ? null : returnedClass.getName();
}
+ @Override
public XProperty getProperty() {
return null; //instead of UnsupportedOperationException
}
+ @Override
public XClass getDeclaringClass() {
//Preloaded properties are artificial wrapper for collection element accesses
//and idClass creation, ignore.
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/QueryBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/QueryBinder.java
similarity index 99%
rename from hibernate-core/src/main/java/org/hibernate/cfg/annotations/QueryBinder.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/QueryBinder.java
index 26243fcfce..040baedff2 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/QueryBinder.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/QueryBinder.java
@@ -2,9 +2,9 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg.annotations;
+package org.hibernate.boot.model.internal;
import java.util.ArrayList;
import java.util.List;
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/QueryHintDefinition.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/QueryHintDefinition.java
similarity index 97%
rename from hibernate-core/src/main/java/org/hibernate/cfg/annotations/QueryHintDefinition.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/QueryHintDefinition.java
index 2186b3f4bc..b8498ac4d7 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/QueryHintDefinition.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/QueryHintDefinition.java
@@ -2,9 +2,9 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg.annotations;
+package org.hibernate.boot.model.internal;
import java.util.Collections;
import java.util.HashMap;
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/QuerySecondPass.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/QuerySecondPass.java
similarity index 58%
rename from hibernate-core/src/main/java/org/hibernate/cfg/QuerySecondPass.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/QuerySecondPass.java
index 11db1f1139..6fc22262a6 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/QuerySecondPass.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/QuerySecondPass.java
@@ -2,11 +2,13 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
+package org.hibernate.boot.model.internal;
+import org.hibernate.boot.spi.SecondPass;
+
/**
* Bind query
*
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/ResultSetMappingSecondPass.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ResultSetMappingSecondPass.java
similarity index 98%
rename from hibernate-core/src/main/java/org/hibernate/cfg/annotations/ResultSetMappingSecondPass.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/ResultSetMappingSecondPass.java
index 37d4384148..5ebb494b4b 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/ResultSetMappingSecondPass.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ResultSetMappingSecondPass.java
@@ -2,18 +2,18 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg.annotations;
+package org.hibernate.boot.model.internal;
import java.util.Map;
-import jakarta.persistence.SqlResultSetMapping;
import org.hibernate.MappingException;
-import org.hibernate.boot.spi.MetadataBuildingContext;
-import org.hibernate.cfg.QuerySecondPass;
-import org.hibernate.mapping.PersistentClass;
import org.hibernate.boot.query.SqlResultSetMappingDescriptor;
+import org.hibernate.boot.spi.MetadataBuildingContext;
+import org.hibernate.mapping.PersistentClass;
+
+import jakarta.persistence.SqlResultSetMapping;
/**
* @author Emmanuel Bernard
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/SecondaryTableFromAnnotationSecondPass.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/SecondaryTableFromAnnotationSecondPass.java
similarity index 70%
rename from hibernate-core/src/main/java/org/hibernate/cfg/SecondaryTableFromAnnotationSecondPass.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/SecondaryTableFromAnnotationSecondPass.java
index 9b8430fdaa..eff8c227f7 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/SecondaryTableFromAnnotationSecondPass.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/SecondaryTableFromAnnotationSecondPass.java
@@ -1,13 +1,19 @@
-package org.hibernate.cfg;
+/*
+ * 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.model.internal;
import java.util.Map;
import org.hibernate.MappingException;
import org.hibernate.annotations.common.reflection.XAnnotatedElement;
-import org.hibernate.cfg.annotations.EntityBinder;
+import org.hibernate.boot.spi.SecondPass;
import org.hibernate.mapping.PersistentClass;
-public class SecondaryTableFromAnnotationSecondPass implements SecondPass{
+public class SecondaryTableFromAnnotationSecondPass implements SecondPass {
private final EntityBinder entityBinder;
private final PropertyHolder propertyHolder;
private final XAnnotatedElement annotatedClass;
@@ -18,6 +24,7 @@ public class SecondaryTableFromAnnotationSecondPass implements SecondPass{
this.annotatedClass = annotatedClass;
}
+ @Override
public void doSecondPass(Map persistentClasses) throws MappingException {
entityBinder.finalSecondaryTableFromAnnotationBinding( propertyHolder );
}
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/SecondaryTableSecondPass.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/SecondaryTableSecondPass.java
similarity index 83%
rename from hibernate-core/src/main/java/org/hibernate/cfg/SecondaryTableSecondPass.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/SecondaryTableSecondPass.java
index 671ec17df4..a3423eaf1e 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/SecondaryTableSecondPass.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/SecondaryTableSecondPass.java
@@ -2,15 +2,15 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
+package org.hibernate.boot.model.internal;
import java.util.Map;
import org.hibernate.MappingException;
import org.hibernate.annotations.common.reflection.XAnnotatedElement;
-import org.hibernate.cfg.annotations.EntityBinder;
+import org.hibernate.boot.spi.SecondPass;
import org.hibernate.mapping.PersistentClass;
/**
@@ -27,6 +27,7 @@ public class SecondaryTableSecondPass implements SecondPass {
this.annotatedClass = annotatedClass;
}
+ @Override
public void doSecondPass(Map persistentClasses) throws MappingException {
entityBinder.finalSecondaryTableBinding( propertyHolder );
}
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/SetBasicValueTypeSecondPass.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/SetBasicValueTypeSecondPass.java
similarity index 76%
rename from hibernate-core/src/main/java/org/hibernate/cfg/SetBasicValueTypeSecondPass.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/SetBasicValueTypeSecondPass.java
index 824e0c7ac6..f87a67e5e2 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/SetBasicValueTypeSecondPass.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/SetBasicValueTypeSecondPass.java
@@ -2,14 +2,14 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
+package org.hibernate.boot.model.internal;
import java.util.Map;
import org.hibernate.MappingException;
-import org.hibernate.cfg.annotations.BasicValueBinder;
+import org.hibernate.boot.spi.SecondPass;
import org.hibernate.mapping.PersistentClass;
/**
@@ -22,6 +22,7 @@ public class SetBasicValueTypeSecondPass implements SecondPass {
binder = val;
}
+ @Override
public void doSecondPass(Map persistentClasses) throws MappingException {
binder.fillSimpleValue();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/SetBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/SetBinder.java
similarity index 90%
rename from hibernate-core/src/main/java/org/hibernate/cfg/annotations/SetBinder.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/SetBinder.java
index dd77d44b55..84aef1becc 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/SetBinder.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/SetBinder.java
@@ -2,9 +2,9 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg.annotations;
+package org.hibernate.boot.model.internal;
import java.util.function.Supplier;
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/SimpleToOneFkSecondPass.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/SimpleToOneFkSecondPass.java
similarity index 84%
rename from hibernate-core/src/main/java/org/hibernate/cfg/SimpleToOneFkSecondPass.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/SimpleToOneFkSecondPass.java
index 4efced5847..ba9155c9b2 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/SimpleToOneFkSecondPass.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/SimpleToOneFkSecondPass.java
@@ -2,9 +2,9 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
+package org.hibernate.boot.model.internal;
import org.hibernate.MappingException;
import org.hibernate.mapping.PersistentClass;
@@ -31,6 +31,7 @@ public class SimpleToOneFkSecondPass extends FkSecondPass {
return false;
}
+ @Override
public void doSecondPass(java.util.Map persistentClasses) throws MappingException {
value.createForeignKey();
}
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/TableBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/TableBinder.java
similarity index 98%
rename from hibernate-core/src/main/java/org/hibernate/cfg/annotations/TableBinder.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/TableBinder.java
index 61b9ddc3aa..b453807d89 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/TableBinder.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/TableBinder.java
@@ -2,16 +2,13 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg.annotations;
+package org.hibernate.boot.model.internal;
import java.util.ArrayList;
import java.util.List;
-import jakarta.persistence.Index;
-import jakarta.persistence.UniqueConstraint;
-
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
import org.hibernate.boot.model.naming.EntityNaming;
@@ -23,13 +20,6 @@ import org.hibernate.boot.model.naming.NamingStrategyHelper;
import org.hibernate.boot.model.source.spi.AttributePath;
import org.hibernate.boot.spi.InFlightMetadataCollector;
import org.hibernate.boot.spi.MetadataBuildingContext;
-import org.hibernate.cfg.AnnotatedJoinColumn;
-import org.hibernate.cfg.AnnotatedJoinColumns;
-import org.hibernate.cfg.IndexOrUniqueKeySecondPass;
-import org.hibernate.cfg.JPAIndexHolder;
-import org.hibernate.cfg.ObjectNameSource;
-import org.hibernate.cfg.PropertyHolder;
-import org.hibernate.cfg.UniqueConstraintHolder;
import org.hibernate.dialect.Dialect;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.collections.CollectionHelper;
@@ -49,6 +39,9 @@ import org.hibernate.mapping.Value;
import org.jboss.logging.Logger;
+import jakarta.persistence.Index;
+import jakarta.persistence.UniqueConstraint;
+
import static org.hibernate.internal.util.StringHelper.isNotEmpty;
import static org.hibernate.internal.util.StringHelper.isQuoted;
import static org.hibernate.internal.util.StringHelper.nullIfEmpty;
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/ToOneBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ToOneBinder.java
similarity index 97%
rename from hibernate-core/src/main/java/org/hibernate/cfg/ToOneBinder.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/ToOneBinder.java
index 69e8ec1c2b..8846ce4042 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/ToOneBinder.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ToOneBinder.java
@@ -2,24 +2,13 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
+package org.hibernate.boot.model.internal;
-import jakarta.persistence.Column;
-import jakarta.persistence.ConstraintMode;
-import jakarta.persistence.FetchType;
-import jakarta.persistence.ForeignKey;
-import jakarta.persistence.Id;
-import jakarta.persistence.JoinColumn;
-import jakarta.persistence.JoinColumns;
-import jakarta.persistence.JoinTable;
-import jakarta.persistence.ManyToOne;
-import jakarta.persistence.MapsId;
-import jakarta.persistence.OneToOne;
+import java.util.ArrayList;
+import java.util.List;
-import jakarta.persistence.PrimaryKeyJoinColumn;
-import jakarta.persistence.PrimaryKeyJoinColumns;
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
import org.hibernate.FetchMode;
@@ -34,21 +23,33 @@ import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;
import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.annotations.common.reflection.XProperty;
+import org.hibernate.boot.spi.AccessType;
import org.hibernate.boot.spi.MetadataBuildingContext;
-import org.hibernate.cfg.annotations.PropertyBinder;
+import org.hibernate.boot.spi.PropertyData;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.mapping.Join;
import org.hibernate.mapping.KeyValue;
import org.hibernate.mapping.SimpleValue;
import org.hibernate.mapping.ToOne;
-import java.util.ArrayList;
-import java.util.List;
+import jakarta.persistence.Column;
+import jakarta.persistence.ConstraintMode;
+import jakarta.persistence.FetchType;
+import jakarta.persistence.ForeignKey;
+import jakarta.persistence.Id;
+import jakarta.persistence.JoinColumn;
+import jakarta.persistence.JoinColumns;
+import jakarta.persistence.JoinTable;
+import jakarta.persistence.ManyToOne;
+import jakarta.persistence.MapsId;
+import jakarta.persistence.OneToOne;
+import jakarta.persistence.PrimaryKeyJoinColumn;
+import jakarta.persistence.PrimaryKeyJoinColumns;
-import static org.hibernate.cfg.AnnotationBinder.matchIgnoreNotFoundWithFetchType;
-import static org.hibernate.cfg.BinderHelper.getCascadeStrategy;
-import static org.hibernate.cfg.BinderHelper.getFetchMode;
-import static org.hibernate.cfg.BinderHelper.getPath;
+import static org.hibernate.boot.model.internal.AnnotationBinder.matchIgnoreNotFoundWithFetchType;
+import static org.hibernate.boot.model.internal.BinderHelper.getCascadeStrategy;
+import static org.hibernate.boot.model.internal.BinderHelper.getFetchMode;
+import static org.hibernate.boot.model.internal.BinderHelper.getPath;
import static org.hibernate.internal.CoreLogging.messageLogger;
import static org.hibernate.internal.util.StringHelper.isNotEmpty;
import static org.hibernate.internal.util.StringHelper.nullIfEmpty;
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/ToOneFkSecondPass.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ToOneFkSecondPass.java
similarity index 94%
rename from hibernate-core/src/main/java/org/hibernate/cfg/ToOneFkSecondPass.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/ToOneFkSecondPass.java
index 7f08fc267b..6b37806733 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/ToOneFkSecondPass.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/ToOneFkSecondPass.java
@@ -2,15 +2,14 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
+package org.hibernate.boot.model.internal;
import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
import org.hibernate.MappingException;
import org.hibernate.boot.spi.MetadataBuildingContext;
-import org.hibernate.cfg.annotations.TableBinder;
import org.hibernate.mapping.Component;
import org.hibernate.mapping.KeyValue;
import org.hibernate.mapping.ManyToOne;
@@ -19,7 +18,7 @@ import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Property;
import org.hibernate.mapping.ToOne;
-import static org.hibernate.cfg.BinderHelper.createSyntheticPropertyReference;
+import static org.hibernate.boot.model.internal.BinderHelper.createSyntheticPropertyReference;
import static org.hibernate.internal.util.StringHelper.qualify;
/**
@@ -93,6 +92,7 @@ public class ToOneFkSecondPass extends FkSecondPass {
return false;
}
+ @Override
public void doSecondPass(java.util.Map persistentClasses) throws MappingException {
if ( value instanceof ManyToOne ) {
//TODO: move this validation logic to a separate ManyToOnSecondPass
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/UniqueConstraintHolder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/UniqueConstraintHolder.java
similarity index 90%
rename from hibernate-core/src/main/java/org/hibernate/cfg/UniqueConstraintHolder.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/UniqueConstraintHolder.java
index 1c4464e9f0..d4e6ff17bf 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/UniqueConstraintHolder.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/UniqueConstraintHolder.java
@@ -2,9 +2,9 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
+package org.hibernate.boot.model.internal;
/**
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/VerifyFetchProfileReferenceSecondPass.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/VerifyFetchProfileReferenceSecondPass.java
similarity index 82%
rename from hibernate-core/src/main/java/org/hibernate/cfg/VerifyFetchProfileReferenceSecondPass.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/VerifyFetchProfileReferenceSecondPass.java
index 22ce7accfa..8456e87bb6 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/VerifyFetchProfileReferenceSecondPass.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/VerifyFetchProfileReferenceSecondPass.java
@@ -2,15 +2,16 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
+package org.hibernate.boot.model.internal;
import java.util.Locale;
import java.util.Map;
import org.hibernate.MappingException;
import org.hibernate.annotations.FetchProfile;
import org.hibernate.boot.spi.MetadataBuildingContext;
+import org.hibernate.boot.spi.SecondPass;
import org.hibernate.mapping.MetadataSource;
import org.hibernate.mapping.PersistentClass;
@@ -31,10 +32,9 @@ public class VerifyFetchProfileReferenceSecondPass implements SecondPass {
this.buildingContext = buildingContext;
}
+ @Override
public void doSecondPass(Map persistentClasses) throws MappingException {
- org.hibernate.mapping.FetchProfile profile = buildingContext.getMetadataCollector().getFetchProfile(
- fetchProfileName
- );
+ org.hibernate.mapping.FetchProfile profile = buildingContext.getMetadataCollector().getFetchProfile( fetchProfileName );
if ( profile != null ) {
if ( profile.getSource() != MetadataSource.ANNOTATIONS ) {
return;
@@ -50,7 +50,9 @@ public class VerifyFetchProfileReferenceSecondPass implements SecondPass {
clazz.getProperty( fetch.association() );
profile.addFetch(
- fetch.entity().getName(), fetch.association(), fetch.mode().toString().toLowerCase(Locale.ROOT)
+ fetch.entity().getName(),
+ fetch.association(),
+ fetch.mode().toString().toLowerCase(Locale.ROOT)
);
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/WrappedInferredData.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/WrappedInferredData.java
similarity index 83%
rename from hibernate-core/src/main/java/org/hibernate/cfg/WrappedInferredData.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/WrappedInferredData.java
index 36e107876f..4564432523 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/WrappedInferredData.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/WrappedInferredData.java
@@ -1,56 +1,67 @@
-/*
- * 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 .
- */
-package org.hibernate.cfg;
-import org.hibernate.MappingException;
-import org.hibernate.annotations.common.reflection.XClass;
-import org.hibernate.annotations.common.reflection.XProperty;
-import org.hibernate.internal.util.StringHelper;
-
-/**
- * @author Emmanuel Bernard
- */
-public class WrappedInferredData implements PropertyData {
- private final PropertyData wrappedInferredData;
- private final String propertyName;
-
- public XClass getClassOrElement() throws MappingException {
- return wrappedInferredData.getClassOrElement();
- }
-
- public String getClassOrElementName() throws MappingException {
- return wrappedInferredData.getClassOrElementName();
- }
-
- public AccessType getDefaultAccess() {
- return wrappedInferredData.getDefaultAccess();
- }
-
- public XProperty getProperty() {
- return wrappedInferredData.getProperty();
- }
-
- public XClass getDeclaringClass() {
- return wrappedInferredData.getDeclaringClass();
- }
-
- public XClass getPropertyClass() throws MappingException {
- return wrappedInferredData.getPropertyClass();
- }
-
- public String getPropertyName() throws MappingException {
- return propertyName;
- }
-
- public String getTypeName() throws MappingException {
- return wrappedInferredData.getTypeName();
- }
-
- public WrappedInferredData(PropertyData inferredData, String suffix) {
- this.wrappedInferredData = inferredData;
- this.propertyName = StringHelper.qualify( inferredData.getPropertyName(), suffix );
- }
-}
+/*
+ * 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.model.internal;
+
+import org.hibernate.MappingException;
+import org.hibernate.annotations.common.reflection.XClass;
+import org.hibernate.annotations.common.reflection.XProperty;
+import org.hibernate.boot.spi.AccessType;
+import org.hibernate.boot.spi.PropertyData;
+import org.hibernate.internal.util.StringHelper;
+
+/**
+ * @author Emmanuel Bernard
+ */
+public class WrappedInferredData implements PropertyData {
+ private final PropertyData wrappedInferredData;
+ private final String propertyName;
+
+ public WrappedInferredData(PropertyData inferredData, String suffix) {
+ this.wrappedInferredData = inferredData;
+ this.propertyName = StringHelper.qualify( inferredData.getPropertyName(), suffix );
+ }
+
+ @Override
+ public XClass getClassOrElement() throws MappingException {
+ return wrappedInferredData.getClassOrElement();
+ }
+
+ @Override
+ public String getClassOrElementName() throws MappingException {
+ return wrappedInferredData.getClassOrElementName();
+ }
+
+ @Override
+ public AccessType getDefaultAccess() {
+ return wrappedInferredData.getDefaultAccess();
+ }
+
+ @Override
+ public XProperty getProperty() {
+ return wrappedInferredData.getProperty();
+ }
+
+ @Override
+ public XClass getDeclaringClass() {
+ return wrappedInferredData.getDeclaringClass();
+ }
+
+ @Override
+ public XClass getPropertyClass() throws MappingException {
+ return wrappedInferredData.getPropertyClass();
+ }
+
+ @Override
+ public String getPropertyName() throws MappingException {
+ return propertyName;
+ }
+
+ @Override
+ public String getTypeName() throws MappingException {
+ return wrappedInferredData.getTypeName();
+ }
+}
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/internal/XMLContext.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/XMLContext.java
similarity index 98%
rename from hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/internal/XMLContext.java
rename to hibernate-core/src/main/java/org/hibernate/boot/model/internal/XMLContext.java
index f65a081994..77aedc47aa 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/internal/XMLContext.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/XMLContext.java
@@ -4,7 +4,7 @@
* 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.cfg.annotations.reflection.internal;
+package org.hibernate.boot.model.internal;
import java.io.Serializable;
import java.util.ArrayList;
@@ -326,8 +326,9 @@ public class XMLContext implements Serializable {
if ( globalDefault.getMetadataComplete() != null ) {
metadataComplete = globalDefault.getMetadataComplete();
}
- //TODO fix that in stone if cascade-persist is set already?
- if ( globalDefault.getCascadePersist() != null ) cascadePersist = globalDefault.getCascadePersist();
+ if ( globalDefault.getCascadePersist() != null ) {
+ cascadePersist = globalDefault.getCascadePersist();
+ }
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/package-info.java b/hibernate-core/src/main/java/org/hibernate/boot/model/package-info.java
index 6caeda0681..3fc9012ff2 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/model/package-info.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/package-info.java
@@ -7,11 +7,16 @@
/**
* Package defining Hibernate's boot-time metamodel, which is an
- * incrementally built understanding of the application's domain
- * model (its entities, attributes, etc).
+ * understanding of the application's domain model (its entities,
+ * attributes, etc.) and the mapping of those "domain model parts"
+ * to the database.
+ *
+ * It is {@linkplain org.hibernate.boot.model.process incrementally built}
+ * from {@linkplain org.hibernate.annotations annotations} and XML mappings
*
- * Ultimately, as part of the process of creating the
+ * @implNote Ultimately, as part of the process of creating the
* {@link org.hibernate.SessionFactory}, Hibernate will interpret
- * this boot metamodel to its runtime metamodel.
+ * this boot metamodel to its runtime
+ * {@linkplain org.hibernate.metamodel.mapping mapping metamodel}
*/
package org.hibernate.boot.model;
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/process/package-info.java b/hibernate-core/src/main/java/org/hibernate/boot/model/process/package-info.java
index 6cfe786d0a..c36546c622 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/model/process/package-info.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/process/package-info.java
@@ -6,8 +6,11 @@
*/
/**
- * Defines the contracts used to perform the process of transforming a {@link org.hibernate.boot.MetadataSources}
- * references into a {@link org.hibernate.boot.Metadata} reference. This process is mainly defined by
+ * Defines the contracts used to perform the process of transforming
+ * {@linkplain org.hibernate.boot.MetadataSources mapping sources} into
+ * the {@link org.hibernate.boot.Metadata} reference.
+ *
+ * @implNote This process is defined by
* {@link org.hibernate.boot.model.process.spi.MetadataBuildingProcess}.
*/
package org.hibernate.boot.model.process;
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/ImplicitColumnNamingSecondPass.java b/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/ImplicitColumnNamingSecondPass.java
index 0cd367c865..7b86b25c5a 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/ImplicitColumnNamingSecondPass.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/ImplicitColumnNamingSecondPass.java
@@ -6,7 +6,7 @@
*/
package org.hibernate.boot.model.source.internal;
-import org.hibernate.cfg.SecondPass;
+import org.hibernate.boot.spi.SecondPass;
/**
* Because {@link org.hibernate.boot.model.naming.ImplicitNamingStrategy} often requires
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/annotations/AnnotationMetadataSourceProcessorImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/annotations/AnnotationMetadataSourceProcessorImpl.java
index fc869af3b8..e948391736 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/annotations/AnnotationMetadataSourceProcessorImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/annotations/AnnotationMetadataSourceProcessorImpl.java
@@ -20,15 +20,15 @@ import org.hibernate.boot.internal.MetadataBuildingContextRootImpl;
import org.hibernate.boot.jaxb.mapping.JaxbEntityMappings;
import org.hibernate.boot.jaxb.spi.Binding;
import org.hibernate.boot.model.convert.spi.ConverterRegistry;
+import org.hibernate.boot.model.internal.AnnotationBinder;
+import org.hibernate.boot.model.internal.InheritanceState;
+import org.hibernate.boot.model.internal.JPAXMLOverriddenMetadataProvider;
import org.hibernate.boot.model.process.spi.ManagedResources;
import org.hibernate.boot.model.source.spi.MetadataSourceProcessor;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.boot.spi.JpaOrmXmlPersistenceUnitDefaultAware;
import org.hibernate.boot.spi.JpaOrmXmlPersistenceUnitDefaultAware.JpaOrmXmlPersistenceUnitDefaults;
import org.hibernate.boot.spi.MetadataBuildingOptions;
-import org.hibernate.cfg.AnnotationBinder;
-import org.hibernate.cfg.InheritanceState;
-import org.hibernate.cfg.annotations.reflection.internal.JPAXMLOverriddenMetadataProvider;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.CollectionHelper;
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/AbstractPluralAttributeSourceImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/AbstractPluralAttributeSourceImpl.java
index dec611cda5..90f4ba142c 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/AbstractPluralAttributeSourceImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/AbstractPluralAttributeSourceImpl.java
@@ -33,7 +33,6 @@ import org.hibernate.boot.model.source.spi.PluralAttributeKeySource;
import org.hibernate.boot.model.source.spi.PluralAttributeSource;
import org.hibernate.boot.model.source.spi.TableSpecificationSource;
import org.hibernate.boot.model.source.spi.ToolingHintContext;
-import org.hibernate.cfg.NotYetImplementedException;
import org.hibernate.internal.util.collections.ArrayHelper;
/**
@@ -265,7 +264,7 @@ public abstract class AbstractPluralAttributeSourceImpl
case MANY_TO_MANY:
return true;
case MANY_TO_ANY:
- throw new NotYetImplementedException(
+ throw new AssertionFailure(
String.format( "%s is not implemented yet.", elementSource.getNature() )
);
default:
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java
index b7a51d90c2..10630483eb 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/ModelBinder.java
@@ -17,7 +17,6 @@ import java.util.Properties;
import org.hibernate.AssertionFailure;
import org.hibernate.FetchMode;
-import org.hibernate.generator.internal.SourceGeneration;
import org.hibernate.annotations.SourceType;
import org.hibernate.boot.MappingException;
import org.hibernate.boot.jaxb.Origin;
@@ -27,6 +26,8 @@ import org.hibernate.boot.model.Caching;
import org.hibernate.boot.model.IdentifierGeneratorDefinition;
import org.hibernate.boot.model.TruthValue;
import org.hibernate.boot.model.TypeDefinition;
+import org.hibernate.boot.model.internal.FkSecondPass;
+import org.hibernate.boot.model.internal.SimpleToOneFkSecondPass;
import org.hibernate.boot.model.naming.EntityNaming;
import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.boot.model.naming.ImplicitBasicColumnNameSource;
@@ -94,15 +95,15 @@ import org.hibernate.boot.spi.InFlightMetadataCollector;
import org.hibernate.boot.spi.InFlightMetadataCollector.EntityTableXref;
import org.hibernate.boot.spi.MetadataBuildingContext;
import org.hibernate.boot.spi.NaturalIdUniqueKeyBinder;
+import org.hibernate.boot.spi.SecondPass;
import org.hibernate.cfg.AvailableSettings;
-import org.hibernate.cfg.FkSecondPass;
-import org.hibernate.cfg.SecondPass;
-import org.hibernate.cfg.SimpleToOneFkSecondPass;
import org.hibernate.engine.FetchStyle;
import org.hibernate.engine.FetchTiming;
import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
import org.hibernate.engine.spi.FilterDefinition;
+import org.hibernate.generator.internal.GeneratedGeneration;
+import org.hibernate.generator.internal.SourceGeneration;
import org.hibernate.id.PersistentIdentifierGenerator;
import org.hibernate.internal.CoreLogging;
import org.hibernate.internal.CoreMessageLogger;
@@ -147,7 +148,6 @@ import org.hibernate.mapping.UniqueKey;
import org.hibernate.mapping.Value;
import org.hibernate.resource.beans.spi.ManagedBean;
import org.hibernate.resource.beans.spi.ManagedBeanRegistry;
-import org.hibernate.generator.internal.GeneratedGeneration;
import org.hibernate.tuple.GenerationTiming;
import org.hibernate.type.AbstractSingleColumnStandardBasicType;
import org.hibernate.type.BasicType;
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/NamedQueryBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/NamedQueryBinder.java
index 88047e7a4f..7cfc96d60d 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/NamedQueryBinder.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/model/source/internal/hbm/NamedQueryBinder.java
@@ -8,8 +8,6 @@ package org.hibernate.boot.model.source.internal.hbm;
import java.util.Locale;
-import jakarta.xml.bind.JAXBElement;
-
import org.hibernate.boot.MappingException;
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmNamedNativeQueryType;
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmNamedQueryType;
@@ -19,13 +17,14 @@ import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmNativeQueryReturnType;
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmNativeQueryScalarReturnType;
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmQueryParamType;
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmSynchronizeType;
+import org.hibernate.boot.model.internal.QueryBinder;
import org.hibernate.boot.query.ImplicitHbmResultSetMappingDescriptorBuilder;
import org.hibernate.boot.query.NamedHqlQueryDefinition;
import org.hibernate.boot.query.NamedNativeQueryDefinitionBuilder;
import org.hibernate.boot.query.NamedProcedureCallDefinition;
-import org.hibernate.cfg.annotations.QueryBinder;
import org.hibernate.internal.log.DeprecationLogger;
-import org.hibernate.internal.util.StringHelper;
+
+import jakarta.xml.bind.JAXBElement;
import static org.hibernate.internal.util.StringHelper.isNotEmpty;
import static org.hibernate.internal.util.StringHelper.nullIfEmpty;
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/spi/AbstractDelegatingMetadata.java b/hibernate-core/src/main/java/org/hibernate/boot/spi/AbstractDelegatingMetadata.java
index f236ae87cc..4310887713 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/spi/AbstractDelegatingMetadata.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/spi/AbstractDelegatingMetadata.java
@@ -16,13 +16,13 @@ import org.hibernate.MappingException;
import org.hibernate.SessionFactory;
import org.hibernate.boot.SessionFactoryBuilder;
import org.hibernate.boot.model.IdentifierGeneratorDefinition;
+import org.hibernate.boot.model.NamedEntityGraphDefinition;
import org.hibernate.boot.model.TypeDefinition;
import org.hibernate.boot.model.relational.Database;
import org.hibernate.boot.query.NamedHqlQueryDefinition;
import org.hibernate.boot.query.NamedNativeQueryDefinition;
import org.hibernate.boot.query.NamedProcedureCallDefinition;
import org.hibernate.boot.query.NamedResultSetMappingDescriptor;
-import org.hibernate.cfg.annotations.NamedEntityGraphDefinition;
import org.hibernate.engine.spi.FilterDefinition;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.mapping.Component;
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/spi/AbstractDelegatingSessionFactoryOptions.java b/hibernate-core/src/main/java/org/hibernate/boot/spi/AbstractDelegatingSessionFactoryOptions.java
index 691702787b..a7ac8d2fcb 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/spi/AbstractDelegatingSessionFactoryOptions.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/spi/AbstractDelegatingSessionFactoryOptions.java
@@ -19,15 +19,15 @@ import org.hibernate.boot.SchemaAutoTooling;
import org.hibernate.boot.TempTableDdlTransactionHandling;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.cache.spi.TimestampsCacheFactory;
-import org.hibernate.cfg.BaselineSessionEventsListenerBuilder;
import org.hibernate.context.spi.CurrentTenantIdentifierResolver;
+import org.hibernate.internal.BaselineSessionEventsListenerBuilder;
import org.hibernate.jpa.spi.JpaCompliance;
import org.hibernate.loader.BatchFetchStyle;
import org.hibernate.proxy.EntityNotFoundDelegate;
import org.hibernate.query.ImmutableEntityUpdateQueryHandlingMode;
-import org.hibernate.query.sqm.NullPrecedence;
import org.hibernate.query.criteria.ValueHandlingMode;
import org.hibernate.query.hql.HqlTranslator;
+import org.hibernate.query.sqm.NullPrecedence;
import org.hibernate.query.sqm.function.SqmFunctionDescriptor;
import org.hibernate.query.sqm.function.SqmFunctionRegistry;
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableInsertStrategy;
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/AccessType.java b/hibernate-core/src/main/java/org/hibernate/boot/spi/AccessType.java
similarity index 94%
rename from hibernate-core/src/main/java/org/hibernate/cfg/AccessType.java
rename to hibernate-core/src/main/java/org/hibernate/boot/spi/AccessType.java
index 9836bf275d..71755caf2e 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/AccessType.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/spi/AccessType.java
@@ -2,9 +2,9 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
+package org.hibernate.boot.spi;
/**
* Enum defining different access strategies for accessing entity values.
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/spi/BootstrapContext.java b/hibernate-core/src/main/java/org/hibernate/boot/spi/BootstrapContext.java
index 53cd4bbadf..cb5e53463d 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/spi/BootstrapContext.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/spi/BootstrapContext.java
@@ -13,10 +13,12 @@ import org.hibernate.Incubating;
import org.hibernate.Internal;
import org.hibernate.annotations.common.reflection.ReflectionManager;
import org.hibernate.boot.CacheRegionDefinition;
+import org.hibernate.boot.Metadata;
import org.hibernate.boot.archive.scan.spi.ScanEnvironment;
import org.hibernate.boot.archive.scan.spi.ScanOptions;
import org.hibernate.boot.archive.spi.ArchiveDescriptorFactory;
import org.hibernate.boot.internal.ClassmateContext;
+import org.hibernate.boot.model.TypeBeanInstanceProducer;
import org.hibernate.boot.model.convert.spi.ConverterDescriptor;
import org.hibernate.boot.model.relational.AuxiliaryDatabaseObject;
import org.hibernate.boot.registry.StandardServiceRegistry;
@@ -39,25 +41,53 @@ import org.jboss.jandex.IndexView;
*/
@Incubating
public interface BootstrapContext {
+ /**
+ * The service-registry available to bootstrapping
+ */
StandardServiceRegistry getServiceRegistry();
+ /**
+ * In-flight form of {@link org.hibernate.jpa.spi.JpaCompliance}
+ */
MutableJpaCompliance getJpaCompliance();
+ /**
+ * @see TypeConfiguration
+ */
TypeConfiguration getTypeConfiguration();
- BeanInstanceProducer getBeanInstanceProducer();
+ /**
+ * BeanInstanceProducer to use when creating custom type references.
+ *
+ * @implNote Generally this will be a {@link TypeBeanInstanceProducer}
+ * reference
+ */
+ BeanInstanceProducer getCustomTypeProducer();
+ /**
+ * Options specific to building the {@linkplain Metadata boot metamodel}
+ */
MetadataBuildingOptions getMetadataBuildingOptions();
default IdentifierGeneratorFactory getIdentifierGeneratorFactory() {
return getMetadataBuildingOptions().getIdentifierGeneratorFactory();
}
+ /**
+ * Whether the bootstrap was initiated from JPA bootstrapping.
+ *
+ * @implSpec This is used
+ *
+ * @see #markAsJpaBootstrap()
+ */
boolean isJpaBootstrap();
/**
- * Indicates that bootstrap was initiated from JPA bootstrapping. Internally {@code false} is
- * the assumed value. We only need to call this to mark that as true.
+ *
+ * Indicates that bootstrap was initiated from JPA bootstrapping.
+ *
+ * @implSpec Internally, {@code false} is the assumed value. We
+ * only need to call this to mark that as {@code true}.
*/
void markAsJpaBootstrap();
@@ -69,6 +99,9 @@ public interface BootstrapContext {
*/
ClassLoader getJpaTempClassLoader();
+ /**
+ * Access to class loading capabilities
+ */
ClassLoaderAccess getClassLoaderAccess();
/**
@@ -172,16 +205,13 @@ public interface BootstrapContext {
*/
Collection getCacheRegionDefinitions();
+ /**
+ * See {@link ManagedTypeRepresentationResolver}
+ */
ManagedTypeRepresentationResolver getRepresentationStrategySelector();
/**
* Releases the "bootstrap only" resources held by this BootstrapContext.
- *
- * Only one call to this method is supported, after we have completed the process of
- * building the (non-inflight) Metadata impl. We may want to delay this until we
- * get into SF building. Not sure yet.
- *
- * @todo verify this ^^
*/
void release();
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/spi/ClassLoaderAccessDelegateImpl.java b/hibernate-core/src/main/java/org/hibernate/boot/spi/ClassLoaderAccessDelegateImpl.java
deleted file mode 100644
index 0285749239..0000000000
--- a/hibernate-core/src/main/java/org/hibernate/boot/spi/ClassLoaderAccessDelegateImpl.java
+++ /dev/null
@@ -1,28 +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 .
- */
-package org.hibernate.boot.spi;
-
-import java.net.URL;
-
-/**
- * A ClassLoaderAccess implementation based on delegation
- *
- * @author Steve Ebersole
- */
-public abstract class ClassLoaderAccessDelegateImpl implements ClassLoaderAccess {
- protected abstract ClassLoaderAccess getDelegate();
-
- @Override
- public Class classForName(String name) {
- return getDelegate().classForName( name );
- }
-
- @Override
- public URL locateResource(String resourceName) {
- return getDelegate().locateResource( resourceName );
- }
-}
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/spi/InFlightMetadataCollector.java b/hibernate-core/src/main/java/org/hibernate/boot/spi/InFlightMetadataCollector.java
index 03d5bc4cf5..f110798a94 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/spi/InFlightMetadataCollector.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/spi/InFlightMetadataCollector.java
@@ -19,12 +19,16 @@ import org.hibernate.annotations.CollectionTypeRegistration;
import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.boot.internal.NamedProcedureCallDefinitionImpl;
import org.hibernate.boot.model.IdentifierGeneratorDefinition;
+import org.hibernate.boot.model.NamedEntityGraphDefinition;
import org.hibernate.boot.model.TypeDefinition;
import org.hibernate.boot.model.TypeDefinitionRegistry;
import org.hibernate.boot.model.convert.spi.ConverterAutoApplyHandler;
import org.hibernate.boot.model.convert.spi.ConverterDescriptor;
import org.hibernate.boot.model.convert.spi.ConverterRegistry;
import org.hibernate.boot.model.convert.spi.RegisteredConversion;
+import org.hibernate.boot.model.internal.AnnotatedClassType;
+import org.hibernate.boot.model.internal.JPAIndexHolder;
+import org.hibernate.boot.model.internal.UniqueConstraintHolder;
import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.boot.model.relational.AuxiliaryDatabaseObject;
import org.hibernate.boot.model.relational.QualifiedTableName;
@@ -33,12 +37,6 @@ import org.hibernate.boot.query.NamedHqlQueryDefinition;
import org.hibernate.boot.query.NamedNativeQueryDefinition;
import org.hibernate.boot.query.NamedProcedureCallDefinition;
import org.hibernate.boot.query.NamedResultSetMappingDescriptor;
-import org.hibernate.cfg.AnnotatedClassType;
-import org.hibernate.cfg.JPAIndexHolder;
-import org.hibernate.cfg.PropertyData;
-import org.hibernate.cfg.SecondPass;
-import org.hibernate.cfg.UniqueConstraintHolder;
-import org.hibernate.cfg.annotations.NamedEntityGraphDefinition;
import org.hibernate.engine.spi.FilterDefinition;
import org.hibernate.engine.spi.Mapping;
import org.hibernate.mapping.Collection;
@@ -55,9 +53,9 @@ import org.hibernate.type.descriptor.java.JavaType;
import org.hibernate.type.descriptor.jdbc.JdbcType;
import org.hibernate.usertype.CompositeUserType;
import org.hibernate.usertype.UserCollectionType;
+import org.hibernate.usertype.UserType;
import jakarta.persistence.AttributeConverter;
-import org.hibernate.usertype.UserType;
/**
* An in-flight representation of {@link org.hibernate.boot.Metadata} while it is being built.
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/spi/JpaOrmXmlPersistenceUnitDefaultAware.java b/hibernate-core/src/main/java/org/hibernate/boot/spi/JpaOrmXmlPersistenceUnitDefaultAware.java
index 0677396454..629a97b97d 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/spi/JpaOrmXmlPersistenceUnitDefaultAware.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/spi/JpaOrmXmlPersistenceUnitDefaultAware.java
@@ -9,9 +9,6 @@ package org.hibernate.boot.spi;
/**
* Contract for things that need to be aware of JPA {@code orm.xml}-defined persistence-unit-defaults. Only
* MetadataBuildingOptions are supported to implement this contract.
- *
- * NOTE: it is expected that this contract will go away as we migrate to Jandex for annotation processing
- * and move to the annotation binding constructs done on the metamodel branch.
*
* @since 5.0
*
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/spi/MappingDefaults.java b/hibernate-core/src/main/java/org/hibernate/boot/spi/MappingDefaults.java
index 2e61c175f2..f1458daf84 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/spi/MappingDefaults.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/spi/MappingDefaults.java
@@ -10,8 +10,11 @@ import org.hibernate.cache.spi.access.AccessType;
import org.hibernate.metamodel.CollectionClassification;
/**
- * Defines a (contextual) set of values to use as defaults in the absence of related mapping information. The
- * context here is conceptually a stack. The "global" level is configuration settings.
+ * Values to use as defaults in the absence of certain mapping information.
+ *
+ * @implSpec Designed with stacking in mind, such that the defaults can be overridden at
+ * various levels using simple wrapping and delegation. The "global" level is configuration
+ * settings.
*
* @author Steve Ebersole
* @author Gail Badner
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/PropertyData.java b/hibernate-core/src/main/java/org/hibernate/boot/spi/PropertyData.java
similarity index 86%
rename from hibernate-core/src/main/java/org/hibernate/cfg/PropertyData.java
rename to hibernate-core/src/main/java/org/hibernate/boot/spi/PropertyData.java
index ed8e383dfb..9379e7bd05 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/PropertyData.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/spi/PropertyData.java
@@ -2,13 +2,17 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
+package org.hibernate.boot.spi;
+
import org.hibernate.MappingException;
import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.annotations.common.reflection.XProperty;
+/**
+ * Details about an attribute as we process the {@linkplain org.hibernate.mapping boot model}
+ */
public interface PropertyData {
/**
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/spi/SecondPass.java b/hibernate-core/src/main/java/org/hibernate/boot/spi/SecondPass.java
new file mode 100644
index 0000000000..2e4f482997
--- /dev/null
+++ b/hibernate-core/src/main/java/org/hibernate/boot/spi/SecondPass.java
@@ -0,0 +1,29 @@
+/*
+ * 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.spi;
+
+import java.io.Serializable;
+import java.util.Map;
+
+import org.hibernate.MappingException;
+import org.hibernate.mapping.PersistentClass;
+
+/**
+ * Hibernate builds its {@linkplain org.hibernate.mapping build-time model}
+ * incrementally, often delaying operations until other pieces of information
+ * are available. A second pass represents one of these delay-able operations.
+ *
+ * @author Gavin King
+ * @author Emmanuel Bernard
+ * @author Steve Ebersole
+ */
+public interface SecondPass extends Serializable {
+ /**
+ * Perform the operation
+ */
+ void doSecondPass(Map persistentClasses) throws MappingException;
+}
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/spi/SessionFactoryOptions.java b/hibernate-core/src/main/java/org/hibernate/boot/spi/SessionFactoryOptions.java
index 108498b761..ff36beb845 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/spi/SessionFactoryOptions.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/spi/SessionFactoryOptions.java
@@ -19,16 +19,16 @@ import org.hibernate.boot.SchemaAutoTooling;
import org.hibernate.boot.TempTableDdlTransactionHandling;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.cache.spi.TimestampsCacheFactory;
-import org.hibernate.cfg.BaselineSessionEventsListenerBuilder;
import org.hibernate.context.spi.CurrentTenantIdentifierResolver;
import org.hibernate.engine.spi.SessionFactoryImplementor;
+import org.hibernate.internal.BaselineSessionEventsListenerBuilder;
import org.hibernate.jpa.spi.JpaCompliance;
import org.hibernate.loader.BatchFetchStyle;
import org.hibernate.proxy.EntityNotFoundDelegate;
import org.hibernate.query.ImmutableEntityUpdateQueryHandlingMode;
-import org.hibernate.query.sqm.NullPrecedence;
import org.hibernate.query.criteria.ValueHandlingMode;
import org.hibernate.query.spi.QueryEngineOptions;
+import org.hibernate.query.sqm.NullPrecedence;
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
import org.hibernate.resource.jdbc.spi.StatementInspector;
import org.hibernate.stat.Statistics;
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/spi/XmlMappingBinderAccess.java b/hibernate-core/src/main/java/org/hibernate/boot/spi/XmlMappingBinderAccess.java
index f0134277c2..464d118b6b 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/spi/XmlMappingBinderAccess.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/spi/XmlMappingBinderAccess.java
@@ -29,7 +29,7 @@ import org.jboss.logging.Logger;
/**
* Poor naming. Models the binder and a class-loader to be a
- * one-stop-shop in terms of {@link #bind binding} a resource
+ * one-stop-shop in terms of binding mappings.
*
* @author Steve Ebersole
*/
@@ -53,6 +53,9 @@ public class XmlMappingBinderAccess {
return mappingBinder;
}
+ /**
+ * Create a {@linkplain Binding binding} from a named URL resource
+ */
public Binding bind(String resource) {
LOG.tracef( "reading mappings from resource : %s", resource );
@@ -66,6 +69,9 @@ public class XmlMappingBinderAccess {
return new UrlXmlSource( origin, url ).doBind( getMappingBinder() );
}
+ /**
+ * Create a {@linkplain Binding binding} from a File reference
+ */
public Binding bind(File file) {
final Origin origin = new Origin( SourceType.FILE, file.getPath() );
LOG.tracef( "reading mappings from file : %s", origin.getName() );
@@ -78,6 +84,9 @@ public class XmlMappingBinderAccess {
return new FileXmlSource( origin, file ).doBind( getMappingBinder() );
}
+ /**
+ * Create a {@linkplain Binding binding} from an input stream
+ */
public Binding bind(InputStreamAccess xmlInputStreamAccess) {
LOG.tracef( "reading mappings from InputStreamAccess : %s", xmlInputStreamAccess.getStreamName() );
@@ -97,6 +106,9 @@ public class XmlMappingBinderAccess {
}
}
+ /**
+ * Create a {@linkplain Binding binding} from an input stream
+ */
public Binding bind(InputStream xmlInputStream) {
LOG.trace( "reading mappings from InputStream" );
final Origin origin = new Origin( SourceType.INPUT_STREAM, null );
@@ -104,6 +116,9 @@ public class XmlMappingBinderAccess {
return new InputStreamXmlSource( origin, xmlInputStream, false ).doBind( getMappingBinder() );
}
+ /**
+ * Create a {@linkplain Binding binding} from a URL
+ */
public Binding bind(URL url) {
final String urlExternalForm = url.toExternalForm();
LOG.debugf( "Reading mapping document from URL : %s", urlExternalForm );
diff --git a/hibernate-core/src/main/java/org/hibernate/boot/xsd/package-info.java b/hibernate-core/src/main/java/org/hibernate/boot/xsd/package-info.java
index b6be8bfa11..35ca5308b2 100644
--- a/hibernate-core/src/main/java/org/hibernate/boot/xsd/package-info.java
+++ b/hibernate-core/src/main/java/org/hibernate/boot/xsd/package-info.java
@@ -6,7 +6,6 @@
*/
/**
- * Support for XSD handling, specifically for ORM mappings (Hibernate's `hbm.xml` and
- * JPA's `orm.xml`) and config files (Hibernate's `cfg.xml` and JPA's `persistence.xml`)
+ * Support for XSD handling
*/
package org.hibernate.boot.xsd;
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/AnnotatedColumns.java b/hibernate-core/src/main/java/org/hibernate/cfg/AnnotatedColumns.java
deleted file mode 100644
index 537d81b511..0000000000
--- a/hibernate-core/src/main/java/org/hibernate/cfg/AnnotatedColumns.java
+++ /dev/null
@@ -1,168 +0,0 @@
-package org.hibernate.cfg;
-
-import org.hibernate.AnnotationException;
-import org.hibernate.boot.spi.MetadataBuildingContext;
-import org.hibernate.mapping.Join;
-import org.hibernate.mapping.Table;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import static java.util.Collections.unmodifiableList;
-import static org.hibernate.internal.util.StringHelper.isNotEmpty;
-
-/**
- * A list of columns that are mapped to a single Java property
- * or field. This is a slightly uncomfortable abstraction here,
- * because this concept is arguably missing from JPA (where
- * there's no equivalent of the Hibernate-defined
- * {@link org.hibernate.annotations.Columns} annotation) and
- * so JPA lets each {@link jakarta.persistence.Column} specify
- * its own {@link jakarta.persistence.Column#table table}.
- * That leaves us having to enforce the requirement that every
- * column mapped to a given property must belong to the same
- * table.
- *
- * @author Gavin King
- */
-public class AnnotatedColumns {
- private final List columns = new ArrayList<>();
- private Table table;
- private PropertyHolder propertyHolder;
- private String propertyName; // this is really a .-separated property path
- private Map joins = Collections.emptyMap();
- private MetadataBuildingContext buildingContext;
-
- public List getColumns() {
- return unmodifiableList( columns );
- }
-
- public PropertyHolder getPropertyHolder() {
- return propertyHolder;
- }
-
- public void setPropertyHolder(PropertyHolder propertyHolder) {
- this.propertyHolder = propertyHolder;
- }
-
- /**
- * A property path relative to the {@link #getPropertyHolder() PropertyHolder}.
- */
- public String getPropertyName() {
- return propertyName;
- }
-
- public void setPropertyName(String propertyName) {
- this.propertyName = propertyName;
- }
-
- public void setBuildingContext(MetadataBuildingContext buildingContext) {
- this.buildingContext = buildingContext;
- }
-
- public MetadataBuildingContext getBuildingContext() {
- return buildingContext;
- }
-
- public void setJoins(Map joins) {
- this.joins = joins;
- }
-
- public Join getJoin() {
- final AnnotatedColumn firstColumn = columns.get(0);
- final String explicitTableName = firstColumn.getExplicitTableName();
- //note: checkPropertyConsistency() is responsible for ensuring they all have the same table name
- Join join = joins.get( explicitTableName );
- if ( join == null ) {
- // annotation binding seems to use logical and physical naming somewhat inconsistently...
- final String physicalTableName = getBuildingContext().getMetadataCollector()
- .getPhysicalTableName( explicitTableName );
- if ( physicalTableName != null ) {
- join = joins.get( physicalTableName );
- }
- }
- if ( join == null ) {
- throw new AnnotationException(
- "Secondary table '" + explicitTableName + "' for property '" + getPropertyHolder().getClassName()
- + "' is not declared (use '@SecondaryTable' to declare the secondary table)"
- );
- }
- else {
- return join;
- }
- }
-
- public boolean isSecondary() {
- final AnnotatedColumn firstColumn = columns.get(0);
- final String explicitTableName = firstColumn.getExplicitTableName();
- //note: checkPropertyConsistency() is responsible for ensuring they all have the same table name
- return isNotEmpty( explicitTableName )
- && !getPropertyHolder().getTable().getName().equals( explicitTableName );
- }
-
- /**
- * Find the table to which these columns belong, taking into account secondary tables.
- *
- * @return the {@link Table} given in the code by {@link jakarta.persistence.Column#table()}
- * and held here by {@code explicitTableName}.
- * @throws AnnotationException if the table named by {@code explicitTableName} is not found
- * among the secondary tables in {@code joins}.
- */
- public Table getTable() {
- if ( table != null ) {
- return table;
- }
- else {
- // all the columns have to be mapped to the same table
- // even though at the annotation level it looks like
- // they could each specify a different table
- return isSecondary() ? getJoin().getTable() : getPropertyHolder().getTable();
- }
- }
-
- public void setTable(Table table) {
- this.table = table;
- }
-
- @Deprecated
- void setTableInternal(Table table) {
- this.table = table;
- }
-
- public void addColumn(AnnotatedColumn child) {
- columns.add( child );
- }
-
- public void checkPropertyConsistency() {
- if ( columns.size() > 1 ) {
- for ( int currentIndex = 1; currentIndex < columns.size(); currentIndex++ ) {
- final AnnotatedColumn current = columns.get( currentIndex );
- final AnnotatedColumn previous = columns.get( currentIndex - 1 );
- if ( !current.isFormula() && !previous.isFormula() ) {
- if ( current.isNullable() != previous.isNullable() ) {
- throw new AnnotationException(
- "Column mappings for property '" + propertyName + "' mix nullable with 'not null'"
- );
- }
- if ( current.isInsertable() != previous.isInsertable() ) {
- throw new AnnotationException(
- "Column mappings for property '" + propertyName + "' mix insertable with 'insertable=false'"
- );
- }
- if ( current.isUpdatable() != previous.isUpdatable() ) {
- throw new AnnotationException(
- "Column mappings for property '" + propertyName + "' mix updatable with 'updatable=false'"
- );
- }
- if ( !current.getExplicitTableName().equals( previous.getExplicitTableName() ) ) {
- throw new AnnotationException(
- "Column mappings for property '" + propertyName + "' mix distinct secondary tables"
- );
- }
- }
- }
- }
- }
-}
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/AnnotatedJoinColumns.java b/hibernate-core/src/main/java/org/hibernate/cfg/AnnotatedJoinColumns.java
deleted file mode 100644
index f3a8341eff..0000000000
--- a/hibernate-core/src/main/java/org/hibernate/cfg/AnnotatedJoinColumns.java
+++ /dev/null
@@ -1,620 +0,0 @@
-package org.hibernate.cfg;
-
-import jakarta.persistence.JoinColumn;
-import org.hibernate.AnnotationException;
-import org.hibernate.AssertionFailure;
-import org.hibernate.MappingException;
-import org.hibernate.annotations.Comment;
-import org.hibernate.annotations.JoinColumnOrFormula;
-import org.hibernate.annotations.JoinFormula;
-import org.hibernate.boot.model.naming.EntityNaming;
-import org.hibernate.boot.model.naming.Identifier;
-import org.hibernate.boot.model.naming.ImplicitJoinColumnNameSource;
-import org.hibernate.boot.model.naming.ImplicitNamingStrategy;
-import org.hibernate.boot.model.naming.ImplicitPrimaryKeyJoinColumnNameSource;
-import org.hibernate.boot.model.naming.PhysicalNamingStrategy;
-import org.hibernate.boot.model.relational.Database;
-import org.hibernate.boot.model.source.spi.AttributePath;
-import org.hibernate.boot.spi.InFlightMetadataCollector;
-import org.hibernate.boot.spi.MetadataBuildingContext;
-import org.hibernate.boot.spi.MetadataBuildingOptions;
-import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
-import org.hibernate.mapping.Column;
-import org.hibernate.mapping.Join;
-import org.hibernate.mapping.PersistentClass;
-import org.hibernate.mapping.Property;
-import org.hibernate.mapping.Selectable;
-import org.hibernate.mapping.SimpleValue;
-import org.hibernate.mapping.Table;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-import static org.hibernate.cfg.BinderHelper.findReferencedColumnOwner;
-import static org.hibernate.cfg.BinderHelper.getRelativePath;
-import static org.hibernate.internal.util.StringHelper.isNotEmpty;
-import static org.hibernate.internal.util.StringHelper.isQuoted;
-import static org.hibernate.internal.util.StringHelper.nullIfEmpty;
-import static org.hibernate.internal.util.StringHelper.qualify;
-
-/**
- * A list of {@link jakarta.persistence.JoinColumn}s that form a single join
- * condition, similar in concept to {@link jakarta.persistence.JoinColumns},
- * but not every instance of this class corresponds to an explicit annotation
- * in the Java code.
- *
- * There's no exact analog of this class in the mapping model, so some
- * information is lost when it's transformed into a list of {@link Column}s.
- *
- * @author Gavin King
- */
-public class AnnotatedJoinColumns extends AnnotatedColumns {
-
- private final List columns = new ArrayList<>();
- private String propertyName; // this is really a .-separated property path
-
- //TODO: do we really need to hang so many strings off this class?
- private String mappedBy;
- private String mappedByPropertyName; //property name on the owning side if any
- private String mappedByTableName; //table name on the mapped by side if any
- private String mappedByEntityName;
- private boolean elementCollection;
- private String manyToManyOwnerSideEntityName;
-
- public static AnnotatedJoinColumns buildJoinColumnsOrFormulas(
- JoinColumnOrFormula[] joinColumnOrFormulas,
- String mappedBy,
- Map joins,
- PropertyHolder propertyHolder,
- PropertyData inferredData,
- MetadataBuildingContext context) {
- final AnnotatedJoinColumns parent = new AnnotatedJoinColumns();
- parent.setBuildingContext( context );
- parent.setJoins( joins );
- parent.setPropertyHolder( propertyHolder );
- parent.setPropertyName( getRelativePath( propertyHolder, inferredData.getPropertyName() ) );
- parent.setMappedBy( mappedBy );
- for ( JoinColumnOrFormula columnOrFormula : joinColumnOrFormulas ) {
- final JoinFormula formula = columnOrFormula.formula();
- final JoinColumn column = columnOrFormula.column();
- final String annotationString = formula.value();
- if ( isNotEmpty( annotationString ) ) {
- AnnotatedJoinColumn.buildJoinFormula( formula, parent );
- }
- else {
- AnnotatedJoinColumn.buildJoinColumn( column, mappedBy, parent, propertyHolder, inferredData );
- }
- }
- return parent;
- }
-
- static AnnotatedJoinColumns buildJoinColumnsWithFormula(
- JoinFormula joinFormula,
- Map secondaryTables,
- PropertyHolder propertyHolder,
- PropertyData inferredData,
- MetadataBuildingContext context) {
- final AnnotatedJoinColumns joinColumns = new AnnotatedJoinColumns();
- joinColumns.setBuildingContext( context );
- joinColumns.setJoins( secondaryTables );
- joinColumns.setPropertyHolder( propertyHolder );
- joinColumns.setPropertyName( getRelativePath( propertyHolder, inferredData.getPropertyName() ) );
- AnnotatedJoinColumn.buildJoinFormula( joinFormula, joinColumns );
- return joinColumns;
- }
-
- public static AnnotatedJoinColumns buildJoinColumns(
- JoinColumn[] joinColumns,
- Comment comment,
- String mappedBy,
- Map joins,
- PropertyHolder propertyHolder,
- PropertyData inferredData,
- MetadataBuildingContext buildingContext) {
- return buildJoinColumnsWithDefaultColumnSuffix(
- joinColumns,
- comment,
- mappedBy,
- joins,
- propertyHolder,
- inferredData,
- "",
- buildingContext
- );
- }
-
- public static AnnotatedJoinColumns buildJoinColumnsWithDefaultColumnSuffix(
- JoinColumn[] joinColumns,
- Comment comment,
- String mappedBy,
- Map joins,
- PropertyHolder propertyHolder,
- PropertyData inferredData,
- String defaultColumnSuffix,
- MetadataBuildingContext context) {
- assert mappedBy == null || !mappedBy.isEmpty();
- final String propertyName = inferredData.getPropertyName();
- final String path = qualify( propertyHolder.getPath(), propertyName );
- final JoinColumn[] overriddes = propertyHolder.getOverriddenJoinColumn( path );
- final JoinColumn[] actualColumns = overriddes == null ? joinColumns : overriddes;
- final AnnotatedJoinColumns parent = new AnnotatedJoinColumns();
- parent.setBuildingContext( context );
- parent.setJoins( joins );
- parent.setPropertyHolder( propertyHolder );
- parent.setPropertyName( getRelativePath( propertyHolder, propertyName ) );
- parent.setMappedBy( mappedBy );
- if ( actualColumns == null || actualColumns.length == 0 ) {
- AnnotatedJoinColumn.buildJoinColumn(
- null,
- comment,
- mappedBy,
- parent,
- propertyHolder,
- inferredData,
- defaultColumnSuffix
- );
- }
- else {
- parent.setMappedBy( mappedBy );
- for ( JoinColumn actualColumn : actualColumns ) {
- AnnotatedJoinColumn.buildJoinColumn(
- actualColumn,
- comment,
- mappedBy,
- parent,
- propertyHolder,
- inferredData,
- defaultColumnSuffix
- );
- }
- }
- return parent;
- }
-
- /**
- * Called for join tables in {@link jakarta.persistence.ManyToMany} associations.
- */
- public static AnnotatedJoinColumns buildJoinTableJoinColumns(
- JoinColumn[] joinColumns,
- Map secondaryTables,
- PropertyHolder propertyHolder,
- PropertyData inferredData,
- String mappedBy,
- MetadataBuildingContext context) {
- final AnnotatedJoinColumns parent = new AnnotatedJoinColumns();
- parent.setBuildingContext( context );
- parent.setJoins( secondaryTables );
- parent.setPropertyHolder( propertyHolder );
- parent.setPropertyName( getRelativePath( propertyHolder, inferredData.getPropertyName() ) );
- parent.setMappedBy( mappedBy );
- if ( joinColumns == null ) {
- AnnotatedJoinColumn.buildImplicitJoinTableJoinColumn( parent, propertyHolder, inferredData );
- }
- else {
- for ( JoinColumn joinColumn : joinColumns ) {
- AnnotatedJoinColumn.buildExplicitJoinTableJoinColumn( parent, propertyHolder, inferredData, joinColumn );
- }
- }
- return parent;
- }
-
- public List getJoinColumns() {
- return columns;
- }
-
- @Override
- public void addColumn(AnnotatedColumn child) {
- if ( !(child instanceof AnnotatedJoinColumn) ) {
- throw new AssertionFailure( "wrong sort of column" );
- }
- addColumn( (AnnotatedJoinColumn) child );
- }
-
- public void addColumn(AnnotatedJoinColumn child) {
- super.addColumn( child );
- columns.add( child );
- }
- public String getMappedBy() {
- return mappedBy;
- }
-
- public void setMappedBy(String mappedBy) {
- this.mappedBy = nullIfEmpty( mappedBy );
- }
-
- /**
- * @return true if the association mapping annotation did specify
- * {@link jakarta.persistence.OneToMany#mappedBy() mappedBy},
- * meaning that this {@code @JoinColumn} mapping belongs to an
- * unowned many-valued association.
- */
- public boolean hasMappedBy() {
- return mappedBy != null;
- }
-
- public String getMappedByEntityName() {
- return mappedByEntityName;
- }
-
- public String getMappedByPropertyName() {
- return mappedByPropertyName;
- }
-
- public String getMappedByTableName() {
- return mappedByTableName;
- }
-
- public boolean isElementCollection() {
- return elementCollection;
- }
-
- public void setElementCollection(boolean elementCollection) {
- this.elementCollection = elementCollection;
- }
-
- public void setManyToManyOwnerSideEntityName(String entityName) {
- manyToManyOwnerSideEntityName = entityName;
- }
-
- public String getManyToManyOwnerSideEntityName() {
- return manyToManyOwnerSideEntityName;
- }
-
- public void setMappedBy(String entityName, String logicalTableName, String mappedByProperty) {
- mappedByEntityName = entityName;
- mappedByTableName = logicalTableName;
- mappedByPropertyName = mappedByProperty;
- }
-
- /**
- * Determine if the given {@link AnnotatedJoinColumns} represent a reference to
- * the primary key of the given {@link PersistentClass}, or whether they reference
- * some other combination of mapped columns.
- */
- public ForeignKeyType getReferencedColumnsType(
- PersistentClass referencedEntity) {
- if ( columns.isEmpty() ) {
- return ForeignKeyType.IMPLICIT_PRIMARY_KEY_REFERENCE; //shortcut
- }
-
- final AnnotatedJoinColumn firstColumn = columns.get(0);
- final Object columnOwner = findReferencedColumnOwner( referencedEntity, firstColumn, getBuildingContext() );
- if ( columnOwner == null ) {
- try {
- throw new MappingException( "A '@JoinColumn' references a column named '"
- + firstColumn.getReferencedColumn() + "' but the target entity '"
- + referencedEntity.getEntityName() + "' has no property which maps to this column" );
- }
- catch (MappingException me) {
- // we throw a recoverable exception here in case this
- // is merely an ordering issue, so that the SecondPass
- // will get reprocessed later
- throw new RecoverableException( me.getMessage(), me );
- }
- }
- final Table table = table( columnOwner );
- final List keyColumns = referencedEntity.getKey().getSelectables();
- boolean explicitColumnReference = false;
- for ( AnnotatedJoinColumn column : columns ) {
- if ( !column.isReferenceImplicit() ) {
- explicitColumnReference = true;
- if ( !keyColumns.contains( column( getBuildingContext(), table, column.getReferencedColumn() ) ) ) {
- // we have a column which does not belong to the PK
- return ForeignKeyType.NON_PRIMARY_KEY_REFERENCE;
- }
- }
- }
- if ( explicitColumnReference ) {
- // if we got to here, all the columns belong to the PK
- return keyColumns.size() == columns.size()
- // we have all the PK columns
- ? ForeignKeyType.EXPLICIT_PRIMARY_KEY_REFERENCE
- // we have a subset of the PK columns
- : ForeignKeyType.NON_PRIMARY_KEY_REFERENCE;
- }
- else {
- // there were no nonempty referencedColumnNames
- return ForeignKeyType.IMPLICIT_PRIMARY_KEY_REFERENCE;
- }
- }
-
- private static Table table(Object persistentClassOrJoin) {
- return persistentClassOrJoin instanceof PersistentClass
- ? ( (PersistentClass) persistentClassOrJoin ).getTable()
- : ( (Join) persistentClassOrJoin ).getTable();
- }
-
- private static Column column(MetadataBuildingContext context, Table table, String logicalReferencedColumnName) {
- try {
- return new Column( context.getMetadataCollector().getPhysicalColumnName( table, logicalReferencedColumnName ) );
- }
- catch (MappingException me) {
- throw new MappingException( "No column with logical name '" + logicalReferencedColumnName
- + "' in table '" + table.getName() + "'" );
- }
- }
-
- String buildDefaultColumnName(PersistentClass referencedEntity, String logicalReferencedColumn) {
- final MetadataBuildingOptions options = getBuildingContext().getBuildingOptions();
- final ImplicitNamingStrategy implicitNamingStrategy = options.getImplicitNamingStrategy();
- final PhysicalNamingStrategy physicalNamingStrategy = options.getPhysicalNamingStrategy();
-
- boolean mappedBySide = getMappedByTableName() != null || getMappedByPropertyName() != null;
- boolean ownerSide = getPropertyName() != null;
- boolean isRefColumnQuoted = isQuoted( logicalReferencedColumn );
-
- final InFlightMetadataCollector collector = getBuildingContext().getMetadataCollector();
- final Database database = collector.getDatabase();
-
- Identifier columnIdentifier;
- if ( mappedBySide ) {
- // NOTE : While it is completely misleading here to allow for the combination
- // of a "JPA ElementCollection" to be mappedBy, the code that uses this
- // class relies on this behavior for handling the inverse side of
- // many-to-many mappings
- columnIdentifier = implicitNamingStrategy.determineJoinColumnName(
- new UnownedImplicitJoinColumnNameSource( referencedEntity, logicalReferencedColumn )
- );
-
- //one element was quoted so we quote
- if ( isRefColumnQuoted || isQuoted( getMappedByTableName() ) ) {
- columnIdentifier = Identifier.quote( columnIdentifier );
- }
- }
- else if ( ownerSide ) {
- final String logicalTableName = collector.getLogicalTableName( referencedEntity.getTable() );
-
- columnIdentifier = implicitNamingStrategy.determineJoinColumnName(
- new OwnedImplicitJoinColumnNameSource( referencedEntity, logicalTableName, logicalReferencedColumn )
- );
-
- // HHH-11826 magic. See Ejb3Column and the HHH-6005 comments
- if ( columnIdentifier.getText().contains( "_collection&&element_" ) ) {
- columnIdentifier = Identifier.toIdentifier(
- columnIdentifier.getText().replace( "_collection&&element_", "_" ),
- columnIdentifier.isQuoted()
- );
- }
-
- //one element was quoted so we quote
- if ( isRefColumnQuoted || isQuoted( logicalTableName ) ) {
- columnIdentifier = Identifier.quote( columnIdentifier );
- }
- }
- else {
- final Identifier logicalTableName = database.toIdentifier(
- collector.getLogicalTableName( referencedEntity.getTable() )
- );
-
- // is an intra-entity hierarchy table join so copy the name by default
- columnIdentifier = implicitNamingStrategy.determinePrimaryKeyJoinColumnName(
- new ImplicitPrimaryKeyJoinColumnNameSource() {
- @Override
- public MetadataBuildingContext getBuildingContext() {
- return AnnotatedJoinColumns.this.getBuildingContext();
- }
-
- @Override
- public Identifier getReferencedTableName() {
- return logicalTableName;
- }
-
- @Override
- public Identifier getReferencedPrimaryKeyColumnName() {
- return database.toIdentifier( logicalReferencedColumn );
- }
- }
- );
-
- if ( !columnIdentifier.isQuoted() && ( isRefColumnQuoted || logicalTableName.isQuoted() ) ) {
- columnIdentifier = Identifier.quote( columnIdentifier );
- }
- }
-
- final JdbcEnvironment jdbcEnvironment = database.getJdbcEnvironment();
- return physicalNamingStrategy.toPhysicalColumnName( columnIdentifier, jdbcEnvironment )
- .render( jdbcEnvironment.getDialect() );
- }
-
- /**
- * A property path relative to the {@link #getPropertyHolder() PropertyHolder}.
- */
- public String getPropertyName() {
- return propertyName;
- }
-
- public void setPropertyName(String propertyName) {
- this.propertyName = propertyName;
- }
-
- private ImplicitJoinColumnNameSource.Nature getImplicitNature() {
- if ( getPropertyHolder().isEntity() ) {
- return ImplicitJoinColumnNameSource.Nature.ENTITY;
- }
- else if ( isElementCollection() ) {
- return ImplicitJoinColumnNameSource.Nature.ELEMENT_COLLECTION;
- }
- else {
- return ImplicitJoinColumnNameSource.Nature.ENTITY_COLLECTION;
- }
- }
-
- private class UnownedImplicitJoinColumnNameSource implements ImplicitJoinColumnNameSource {
- final AttributePath attributePath;
- final Nature implicitNamingNature;
-
- private final EntityNaming entityNaming;
-
- private final Identifier referencedTableName;
- private final String logicalReferencedColumn;
-
- final InFlightMetadataCollector collector = getBuildingContext().getMetadataCollector();
- final Database database = collector.getDatabase();
-
- public UnownedImplicitJoinColumnNameSource(PersistentClass referencedEntity, String logicalReferencedColumn) {
- this.logicalReferencedColumn = logicalReferencedColumn;
- attributePath = AttributePath.parse( getMappedByPropertyName() );
- implicitNamingNature = getImplicitNature();
- entityNaming = new EntityNaming() {
- @Override
- public String getClassName() {
- return referencedEntity.getClassName();
- }
-
- @Override
- public String getEntityName() {
- return referencedEntity.getEntityName();
- }
-
- @Override
- public String getJpaEntityName() {
- return referencedEntity.getJpaEntityName();
- }
- };
- referencedTableName = database.toIdentifier( getMappedByTableName() );
- }
-
- @Override
- public Nature getNature() {
- return implicitNamingNature;
- }
-
- @Override
- public EntityNaming getEntityNaming() {
- return entityNaming;
- }
-
- @Override
- public AttributePath getAttributePath() {
- return attributePath;
- }
-
- @Override
- public Identifier getReferencedTableName() {
- return referencedTableName;
- }
-
- @Override
- public Identifier getReferencedColumnName() {
- if ( logicalReferencedColumn != null ) {
- return database.toIdentifier(logicalReferencedColumn);
- }
-
- if ( getMappedByEntityName() == null || getMappedByPropertyName() == null ) {
- return null;
- }
-
- final Property mappedByProperty = collector.getEntityBinding( getMappedByEntityName() )
- .getProperty( getMappedByPropertyName() );
- final SimpleValue value = (SimpleValue) mappedByProperty.getValue();
- if ( value.getSelectables().isEmpty() ) {
- throw new AnnotationException(
- String.format(
- Locale.ENGLISH,
- "Association '%s' is 'mappedBy' a property '%s' of entity '%s' with no columns",
- getPropertyHolder().getPath(),
- getMappedByPropertyName(),
- getMappedByEntityName()
- )
- );
- }
- final Selectable selectable = value.getSelectables().get(0);
- if ( !(selectable instanceof Column) ) {
- throw new AnnotationException(
- String.format(
- Locale.ENGLISH,
- "Association '%s' is 'mappedBy' a property '%s' of entity '%s' which maps to a formula",
- getPropertyHolder().getPath(),
- getMappedByPropertyName(),
- getPropertyHolder().getPath()
- )
- );
- }
- if ( value.getSelectables().size()>1 ) {
- throw new AnnotationException(
- String.format(
- Locale.ENGLISH,
- "Association '%s' is 'mappedBy' a property '%s' of entity '%s' with multiple columns",
- getPropertyHolder().getPath(),
- getMappedByPropertyName(),
- getPropertyHolder().getPath()
- )
- );
- }
- return database.toIdentifier( ( (Column) selectable ).getQuotedName() );
- }
-
- @Override
- public MetadataBuildingContext getBuildingContext() {
- return AnnotatedJoinColumns.this.getBuildingContext();
- }
- }
-
- private class OwnedImplicitJoinColumnNameSource implements ImplicitJoinColumnNameSource {
- final Nature implicitNamingNature;
-
- private final EntityNaming entityNaming;
-
- private final AttributePath attributePath;
- private final Identifier referencedTableName;
- private final Identifier referencedColumnName;
-
- final InFlightMetadataCollector collector = getBuildingContext().getMetadataCollector();
- final Database database = collector.getDatabase();
-
- public OwnedImplicitJoinColumnNameSource(PersistentClass referencedEntity, String logicalTableName, String logicalReferencedColumn) {
- implicitNamingNature = getImplicitNature();
- entityNaming = new EntityNaming() {
- @Override
- public String getClassName() {
- return referencedEntity.getClassName();
- }
-
- @Override
- public String getEntityName() {
- return referencedEntity.getEntityName();
- }
-
- @Override
- public String getJpaEntityName() {
- return referencedEntity.getJpaEntityName();
- }
- };
- attributePath = AttributePath.parse( getPropertyName() );
- referencedTableName = database.toIdentifier( logicalTableName );
- referencedColumnName = database.toIdentifier( logicalReferencedColumn );
- }
-
- @Override
- public Nature getNature() {
- return implicitNamingNature;
- }
-
- @Override
- public EntityNaming getEntityNaming() {
- return entityNaming;
- }
-
- @Override
- public AttributePath getAttributePath() {
- return attributePath;
- }
-
- @Override
- public Identifier getReferencedTableName() {
- return referencedTableName;
- }
-
- @Override
- public Identifier getReferencedColumnName() {
- return referencedColumnName;
- }
-
- @Override
- public MetadataBuildingContext getBuildingContext() {
- return AnnotatedJoinColumns.this.getBuildingContext();
- }
- }
-}
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java b/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java
index 37151999e6..1063b0f66e 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/AvailableSettings.java
@@ -237,19 +237,19 @@ public interface AvailableSettings {
* According to the JPA specification, the {@code BeanManager} should be
* passed at boot time and be ready for immediate use at that time. But
* not all environments can do this (WildFly, for example). To accommodate
- * such environments, Hibernate provides two options:
- *
- * - A proprietary CDI extension SPI (which has been proposed to the CDI
- * spec group as a standard option) which can be used to provide delayed
- * {@code BeanManager} access: to use this solution, the reference passed
- * as the {@code BeanManager} during bootstrap should be typed as
- * {@link org.hibernate.resource.beans.container.spi.ExtendedBeanManager}.
- *
- Delayed access to the {@code BeanManager} reference: here, Hibernate
- * will not access the reference passed as the {@code BeanManager} during
- * bootstrap until it is first needed. Note, however, that this has the
- * effect of delaying the detection of any deployment problems until after
- * bootstrapping.
+ * such environments, Hibernate provides two options:
+ * - A proprietary CDI extension SPI (which has been proposed to the CDI
+ * spec group as a standard option) which can be used to provide delayed
+ * {@code BeanManager} access: to use this solution, the reference passed
+ * as the {@code BeanManager} during bootstrap should be typed as
+ * {@link org.hibernate.resource.beans.container.spi.ExtendedBeanManager}.
+ *
- Delayed access to the {@code BeanManager} reference: here, Hibernate
+ * will not access the reference passed as the {@code BeanManager} during
+ * bootstrap until it is first needed. Note, however, that this has the
+ * effect of delaying the detection of any deployment problems until after
+ * bootstrapping.
*
+ *
* This setting is used to configure access to the {@code BeanManager},
* either directly, or via
* {@link org.hibernate.resource.beans.container.spi.ExtendedBeanManager}.
@@ -877,8 +877,12 @@ public interface AvailableSettings {
* The default is {@code "hbm,class"} which that {@code hbm.xml} files should be processed
* first, followed by annotations (combined with {@code orm.xml} mappings).
*
+ * @see MetadataSourceType
* @see org.hibernate.boot.MetadataBuilder#applySourceProcessOrdering(MetadataSourceType...)
+ *
+ * @deprecated {@code hbm.xml} mappings are no longer supported, making this attribute irrelevant
*/
+ @Deprecated(since = "6", forRemoval = true)
String ARTIFACT_PROCESSING_ORDER = "hibernate.mapping.precedence";
/**
@@ -2983,6 +2987,8 @@ public interface AvailableSettings {
* This setting is used to configure access to the {@code BeanManager},
* either directly, or via
* {@link org.hibernate.resource.beans.container.spi.ExtendedBeanManager}.
+ *
+ * @deprecated Use {@link #JAKARTA_CDI_BEAN_MANAGER} instead
*/
@Deprecated
String CDI_BEAN_MANAGER = "javax.persistence.bean.manager";
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java b/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java
index efbcd343f4..98aecdc1d1 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/Configuration.java
@@ -28,6 +28,7 @@ import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.SessionFactoryBuilder;
import org.hibernate.boot.internal.ClassmateContext;
import org.hibernate.boot.jaxb.spi.Binding;
+import org.hibernate.boot.model.NamedEntityGraphDefinition;
import org.hibernate.boot.model.TypeContributor;
import org.hibernate.boot.model.convert.internal.ClassBasedConverterDescriptor;
import org.hibernate.boot.model.convert.internal.InstanceBasedConverterDescriptor;
@@ -46,7 +47,6 @@ import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.boot.spi.XmlMappingBinderAccess;
-import org.hibernate.cfg.annotations.NamedEntityGraphDefinition;
import org.hibernate.context.spi.CurrentTenantIdentifierResolver;
import org.hibernate.internal.CoreLogging;
import org.hibernate.internal.CoreMessageLogger;
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/DefaultComponentSafeNamingStrategy.java b/hibernate-core/src/main/java/org/hibernate/cfg/DefaultComponentSafeNamingStrategy.java
index 3b48854c88..b3fa5b394a 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/DefaultComponentSafeNamingStrategy.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/DefaultComponentSafeNamingStrategy.java
@@ -7,11 +7,14 @@
package org.hibernate.cfg;
import java.util.Locale;
+
import org.hibernate.AssertionFailure;
import org.hibernate.internal.util.StringHelper;
/**
* @author Emmanuel Bernard
+ *
+ * @deprecated {@link NamingStrategy} itself has been deprecated
*/
@Deprecated
public class DefaultComponentSafeNamingStrategy extends PersistenceStandardNamingStrategy {
@@ -28,19 +31,27 @@ public class DefaultComponentSafeNamingStrategy extends PersistenceStandardNamin
@Override
public String collectionTableName(
- String ownerEntity, String ownerEntityTable, String associatedEntity, String associatedEntityTable,
- String propertyName
- ) {
- String entityTableName = associatedEntityTable != null ? associatedEntityTable : addUnderscores(propertyName);
+ String ownerEntity,
+ String ownerEntityTable,
+ String associatedEntity,
+ String associatedEntityTable,
+ String propertyName) {
+ final String entityTableName = associatedEntityTable != null
+ ? associatedEntityTable
+ : addUnderscores(propertyName);
return tableName( ownerEntityTable + "_" + entityTableName );
}
public String foreignKeyColumnName(
- String propertyName, String propertyEntityName, String propertyTableName, String referencedColumnName
- ) {
+ String propertyName,
+ String propertyEntityName,
+ String propertyTableName,
+ String referencedColumnName) {
String header = propertyName != null ? addUnderscores( propertyName ) : propertyTableName;
- if ( header == null ) throw new AssertionFailure( "NamingStrategy not properly filled" );
+ if ( header == null ) {
+ throw new AssertionFailure( "NamingStrategy not properly filled" );
+ }
return columnName( header + "_" + referencedColumnName );
}
@@ -51,13 +62,15 @@ public class DefaultComponentSafeNamingStrategy extends PersistenceStandardNamin
@Override
public String logicalCollectionTableName(
- String tableName, String ownerEntityTable, String associatedEntityTable, String propertyName
- ) {
+ String tableName,
+ String ownerEntityTable,
+ String associatedEntityTable,
+ String propertyName) {
if ( tableName != null ) {
return tableName;
}
else {
- String entityTableName = associatedEntityTable != null ? associatedEntityTable : propertyName;
+ final String entityTableName = associatedEntityTable != null ? associatedEntityTable : propertyName;
return ownerEntityTable + "_" + entityTableName;
}
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/DefaultNamingStrategy.java b/hibernate-core/src/main/java/org/hibernate/cfg/DefaultNamingStrategy.java
index 9e1b994b8d..04b434dd0d 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/DefaultNamingStrategy.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/DefaultNamingStrategy.java
@@ -16,6 +16,8 @@ import org.hibernate.internal.util.StringHelper;
*
* @see ImprovedNamingStrategy a better alternative
* @author Gavin King
+ *
+ * @deprecated {@link NamingStrategy} itself has been deprecated
*/
@Deprecated
public class DefaultNamingStrategy implements NamingStrategy, Serializable {
@@ -54,9 +56,11 @@ public class DefaultNamingStrategy implements NamingStrategy, Serializable {
* Return the unqualified property name, not the best strategy but a backward compatible one
*/
public String collectionTableName(
- String ownerEntity, String ownerEntityTable, String associatedEntity, String associatedEntityTable,
- String propertyName
- ) {
+ String ownerEntity,
+ String ownerEntityTable,
+ String associatedEntity,
+ String associatedEntityTable,
+ String propertyName) {
//use a degenerated strategy for backward compatibility
return StringHelper.unqualify(propertyName);
}
@@ -72,10 +76,14 @@ public class DefaultNamingStrategy implements NamingStrategy, Serializable {
* Return the property name or propertyTableName
*/
public String foreignKeyColumnName(
- String propertyName, String propertyEntityName, String propertyTableName, String referencedColumnName
- ) {
- String header = propertyName != null ? StringHelper.unqualify( propertyName ) : propertyTableName;
- if (header == null) throw new AssertionFailure("NammingStrategy not properly filled");
+ String propertyName,
+ String propertyEntityName,
+ String propertyTableName,
+ String referencedColumnName) {
+ final String header = propertyName != null ? StringHelper.unqualify( propertyName ) : propertyTableName;
+ if (header == null) {
+ throw new AssertionFailure("NammingStrategy not properly filled");
+ }
return columnName( header ); //+ "_" + referencedColumnName not used for backward compatibility
}
@@ -91,14 +99,16 @@ public class DefaultNamingStrategy implements NamingStrategy, Serializable {
* if there is an associated table, the concatenation of owner entity table and associated table
* otherwise the concatenation of owner entity table and the unqualified property name
*/
- public String logicalCollectionTableName(String tableName,
- String ownerEntityTable, String associatedEntityTable, String propertyName
- ) {
+ public String logicalCollectionTableName(
+ String tableName,
+ String ownerEntityTable,
+ String associatedEntityTable,
+ String propertyName) {
if ( tableName != null ) {
return tableName;
}
else {
- String entityTableName = associatedEntityTable != null
+ final String entityTableName = associatedEntityTable != null
? associatedEntityTable
: StringHelper.unqualify(propertyName);
return ownerEntityTable + "_" + entityTableName;
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/Environment.java b/hibernate-core/src/main/java/org/hibernate/cfg/Environment.java
index 68efe3292b..645eb2126a 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/Environment.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/Environment.java
@@ -14,7 +14,6 @@ import org.hibernate.HibernateException;
import org.hibernate.Version;
import org.hibernate.bytecode.spi.BytecodeProvider;
import org.hibernate.internal.CoreMessageLogger;
-import org.hibernate.internal.log.DeprecationLogger;
import org.hibernate.internal.util.ConfigHelper;
import org.hibernate.internal.util.config.ConfigurationHelper;
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/ImprovedNamingStrategy.java b/hibernate-core/src/main/java/org/hibernate/cfg/ImprovedNamingStrategy.java
index 84834b1f79..f7ac87a3e9 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/ImprovedNamingStrategy.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/ImprovedNamingStrategy.java
@@ -18,6 +18,8 @@ import org.hibernate.internal.util.StringHelper;
*
* @see DefaultNamingStrategy the default strategy
* @author Gavin King
+ *
+ * @deprecated {@link NamingStrategy} itself has been deprecated
*/
@Deprecated
public class ImprovedNamingStrategy implements NamingStrategy, Serializable {
@@ -86,10 +88,15 @@ public class ImprovedNamingStrategy implements NamingStrategy, Serializable {
* Return the property name or propertyTableName
*/
public String foreignKeyColumnName(
- String propertyName, String propertyEntityName, String propertyTableName, String referencedColumnName
+ String propertyName,
+ String propertyEntityName,
+ String propertyTableName,
+ String referencedColumnName
) {
String header = propertyName != null ? StringHelper.unqualify( propertyName ) : propertyTableName;
- if (header == null) throw new AssertionFailure("NamingStrategy not properly filled");
+ if (header == null) {
+ throw new AssertionFailure("NamingStrategy not properly filled");
+ }
return columnName( header ); //+ "_" + referencedColumnName not used for backward compatibility
}
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/MetadataSourceType.java b/hibernate-core/src/main/java/org/hibernate/cfg/MetadataSourceType.java
index 5d2cbb7a60..5a4bee5f75 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/MetadataSourceType.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/MetadataSourceType.java
@@ -2,9 +2,10 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.cfg;
+
import org.hibernate.HibernateException;
/**
@@ -12,7 +13,10 @@ import org.hibernate.HibernateException;
*
* @author Hardy Ferentschik
* @author Steve Ebersole
+ *
+ * @deprecated {@code hbm.xml} mappings are no longer supported, making this attribute irrelevant
*/
+@Deprecated(since = "6", forRemoval = true)
public enum MetadataSourceType {
/**
* Indicates metadata coming from {@code hbm.xml} files
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/NamingStrategy.java b/hibernate-core/src/main/java/org/hibernate/cfg/NamingStrategy.java
index 4951b43717..6eee97e3a4 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/NamingStrategy.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/NamingStrategy.java
@@ -25,7 +25,7 @@ package org.hibernate.cfg;
* and {@link org.hibernate.boot.model.naming.PhysicalNamingStrategy} should
* be used instead.
*/
-@Deprecated
+@Deprecated(since = "6", forRemoval = true)
public interface NamingStrategy {
/**
* Return a table name for an entity class
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/NotYetImplementedException.java b/hibernate-core/src/main/java/org/hibernate/cfg/NotYetImplementedException.java
deleted file mode 100644
index c2d3a88d98..0000000000
--- a/hibernate-core/src/main/java/org/hibernate/cfg/NotYetImplementedException.java
+++ /dev/null
@@ -1,32 +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 .
- */
-package org.hibernate.cfg;
-import org.hibernate.MappingException;
-
-/**
- * Mapping not yet implemented
- *
- * @author Emmanuel Bernard
- */
-public class NotYetImplementedException extends MappingException {
- public NotYetImplementedException() {
- this( "Not yet implemented" );
- }
-
- public NotYetImplementedException(String msg, Throwable root) {
- super( msg, root );
- }
-
- public NotYetImplementedException(Throwable root) {
- super( root );
- }
-
- public NotYetImplementedException(String s) {
- super( s );
- }
-
-}
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/PersistenceStandardEntityResolver.java b/hibernate-core/src/main/java/org/hibernate/cfg/PersistenceStandardEntityResolver.java
deleted file mode 100644
index 934e6f3f18..0000000000
--- a/hibernate-core/src/main/java/org/hibernate/cfg/PersistenceStandardEntityResolver.java
+++ /dev/null
@@ -1,143 +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 .
- */
-package org.hibernate.cfg;
-
-import java.io.InputStream;
-
-import org.hibernate.internal.CoreMessageLogger;
-import org.hibernate.internal.util.xml.DTDEntityResolver;
-
-import org.jboss.logging.Logger;
-
-import org.xml.sax.EntityResolver;
-import org.xml.sax.InputSource;
-
-/**
- * Resolve JPA xsd files locally
- * Hibernate OGM uses this class, consider this some kind of exposed service at the SPI level
- *
- * @author Emmanuel Bernard
- */
-public class PersistenceStandardEntityResolver extends DTDEntityResolver {
- public static final EntityResolver INSTANCE = new PersistenceStandardEntityResolver();
-
- private static final CoreMessageLogger LOG = Logger.getMessageLogger( CoreMessageLogger.class, PersistenceStandardEntityResolver.class.getName() );
-
- boolean resolved = false;
-
- /**
- * Persistence.xml has been resolved locally
- * @return true if it has
- */
- public boolean isResolved() {
- return resolved;
- }
-
- @Override
- public InputSource resolveEntity(String publicId, String systemId) {
- LOG.tracev( "Resolving XML entity {0} : {1}", publicId, systemId );
- if ( systemId != null ) {
- if ( systemId.endsWith( "orm_3_0.xsd" ) ) {
- InputStream dtdStream = getStreamFromClasspath( "orm_3_0.xsd" );
- final InputSource source = buildInputSource( publicId, systemId, dtdStream, false );
- if ( source != null ) {
- return source;
- }
- }
- else if ( systemId.endsWith( "orm_2_1.xsd" ) ) {
- InputStream dtdStream = getStreamFromClasspath( "orm_2_1.xsd" );
- final InputSource source = buildInputSource( publicId, systemId, dtdStream, false );
- if ( source != null ) {
- return source;
- }
- }
- else if ( systemId.endsWith( "orm_2_2.xsd" ) ) {
- InputStream dtdStream = getStreamFromClasspath( "orm_2_2.xsd" );
- final InputSource source = buildInputSource( publicId, systemId, dtdStream, false );
- if ( source != null ) {
- return source;
- }
- }
- else if ( systemId.endsWith( "orm_2_0.xsd" ) ) {
- InputStream dtdStream = getStreamFromClasspath( "orm_2_0.xsd" );
- final InputSource source = buildInputSource( publicId, systemId, dtdStream, false );
- if ( source != null ) {
- return source;
- }
- }
- else if ( systemId.endsWith( "orm_1_0.xsd" ) ) {
- InputStream dtdStream = getStreamFromClasspath( "orm_1_0.xsd" );
- final InputSource source = buildInputSource( publicId, systemId, dtdStream, false );
- if ( source != null ) {
- return source;
- }
- }
- else if ( systemId.endsWith( "persistence_3_0.xsd" ) ) {
- InputStream dtdStream = getStreamFromClasspath( "persistence_3_0.xsd" );
- final InputSource source = buildInputSource( publicId, systemId, dtdStream, true );
- if ( source != null ) {
- return source;
- }
- }
- else if ( systemId.endsWith( "persistence_2_2.xsd" ) ) {
- InputStream dtdStream = getStreamFromClasspath( "persistence_2_2.xsd" );
- final InputSource source = buildInputSource( publicId, systemId, dtdStream, true );
- if ( source != null ) {
- return source;
- }
- }
- else if ( systemId.endsWith( "persistence_2_1.xsd" ) ) {
- InputStream dtdStream = getStreamFromClasspath( "persistence_2_1.xsd" );
- final InputSource source = buildInputSource( publicId, systemId, dtdStream, true );
- if ( source != null ) {
- return source;
- }
- }
- else if ( systemId.endsWith( "persistence_2_0.xsd" ) ) {
- InputStream dtdStream = getStreamFromClasspath( "persistence_2_0.xsd" );
- final InputSource source = buildInputSource( publicId, systemId, dtdStream, true );
- if ( source != null ) {
- return source;
- }
- }
- else if ( systemId.endsWith( "persistence_1_0.xsd" ) ) {
- InputStream dtdStream = getStreamFromClasspath( "persistence_1_0.xsd" );
- final InputSource source = buildInputSource( publicId, systemId, dtdStream, true );
- if ( source != null ) {
- return source;
- }
- }
- }
-
- // because the old code did this too (in terms of setting resolved)
- InputSource source = super.resolveEntity( publicId, systemId );
- if ( source != null ) {
- resolved = true;
- }
- return source;
- }
-
- private InputSource buildInputSource(String publicId, String systemId, InputStream dtdStream, boolean resolved) {
- if ( dtdStream == null ) {
- LOG.tracev( "Unable to locate [{0}] on classpath", systemId );
- return null;
- }
- LOG.tracev( "Located [{0}] in classpath", systemId );
- InputSource source = new InputSource( dtdStream );
- source.setPublicId( publicId );
- source.setSystemId( systemId );
- this.resolved = resolved;
- return source;
- }
-
- private InputStream getStreamFromClasspath(String fileName) {
- LOG.trace( "Recognized JPA ORM namespace; attempting to resolve on classpath under org/hibernate/jpa" );
- String path = "org/hibernate/jpa/" + fileName;
- InputStream dtdStream = resolveInHibernateNamespace( path );
- return dtdStream;
- }
-}
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/PersistenceStandardNamingStrategy.java b/hibernate-core/src/main/java/org/hibernate/cfg/PersistenceStandardNamingStrategy.java
index df044257e2..92da08c05e 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/PersistenceStandardNamingStrategy.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/PersistenceStandardNamingStrategy.java
@@ -14,6 +14,8 @@ import org.hibernate.internal.util.StringHelper;
* Naming strategy implementing the EJB3 standards
*
* @author Emmanuel Bernard
+ *
+ * @deprecated {@link NamingStrategy} itself has been deprecated
*/
@Deprecated
public class PersistenceStandardNamingStrategy implements NamingStrategy, Serializable {
@@ -50,10 +52,14 @@ public class PersistenceStandardNamingStrategy implements NamingStrategy, Serial
}
public String foreignKeyColumnName(
- String propertyName, String propertyEntityName, String propertyTableName, String referencedColumnName
- ) {
+ String propertyName,
+ String propertyEntityName,
+ String propertyTableName,
+ String referencedColumnName) {
String header = propertyName != null ? StringHelper.unqualify( propertyName ) : propertyTableName;
- if ( header == null ) throw new AssertionFailure( "NamingStrategy not properly filled" );
+ if ( header == null ) {
+ throw new AssertionFailure( "NamingStrategy not properly filled" );
+ }
return columnName( header + "_" + referencedColumnName );
}
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/SecondPass.java b/hibernate-core/src/main/java/org/hibernate/cfg/SecondPass.java
index c3b3b48983..3716246ead 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/SecondPass.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/SecondPass.java
@@ -2,22 +2,17 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
package org.hibernate.cfg;
-import java.io.Serializable;
-
-import org.hibernate.MappingException;
-import org.hibernate.mapping.PersistentClass;
/**
* Second pass operation
*
* @author Emmanuel Bernard
+ *
+ * @deprecated Use {@link org.hibernate.boot.spi.SecondPass} instead
*/
-public interface SecondPass extends Serializable {
-
- void doSecondPass(java.util.Map persistentClasses)
- throws MappingException;
-
+@Deprecated(since = "6", forRemoval = true)
+public interface SecondPass extends org.hibernate.boot.spi.SecondPass {
}
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/package-info.java b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/package-info.java
deleted file mode 100644
index 50879cf9b4..0000000000
--- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/reflection/package-info.java
+++ /dev/null
@@ -1,12 +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 .
- */
-
-/**
- * Defines the capability to merge mapping information from both annotations and orm.xml sources into a unified set of
- * metadata in the Hibernate commons-annotations model.
- */
-package org.hibernate.cfg.annotations.reflection;
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/BeanValidationEventListener.java b/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/BeanValidationEventListener.java
index a0da2b9045..6cc0c93ce5 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/BeanValidationEventListener.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/BeanValidationEventListener.java
@@ -10,12 +10,6 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
-import jakarta.validation.ConstraintViolation;
-import jakarta.validation.ConstraintViolationException;
-import jakarta.validation.TraversableResolver;
-import jakarta.validation.Validation;
-import jakarta.validation.Validator;
-import jakarta.validation.ValidatorFactory;
import org.hibernate.boot.internal.ClassLoaderAccessImpl;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
@@ -33,6 +27,13 @@ import org.hibernate.persister.entity.EntityPersister;
import org.jboss.logging.Logger;
+import jakarta.validation.ConstraintViolation;
+import jakarta.validation.ConstraintViolationException;
+import jakarta.validation.TraversableResolver;
+import jakarta.validation.Validation;
+import jakarta.validation.Validator;
+import jakarta.validation.ValidatorFactory;
+
/**
* Event listener used to enable Bean Validation for insert/update/delete events.
*
@@ -109,14 +110,16 @@ public class BeanValidationEventListener
return false;
}
- private void validate(T object, RepresentationMode mode, EntityPersister persister,
- SessionFactoryImplementor sessionFactory, GroupsPerOperation.Operation operation) {
+ private void validate(
+ T object,
+ RepresentationMode mode,
+ EntityPersister persister,
+ SessionFactoryImplementor sessionFactory,
+ GroupsPerOperation.Operation operation) {
if ( object == null || mode != RepresentationMode.POJO ) {
return;
}
- TraversableResolver tr = new HibernateTraversableResolver(
- persister, associationsPerEntityPersister, sessionFactory
- );
+ TraversableResolver tr = new HibernateTraversableResolver( persister, associationsPerEntityPersister, sessionFactory );
Validator validator = factory.usingContext()
.traversableResolver( tr )
.getValidator();
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/BeanValidationIntegrator.java b/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/BeanValidationIntegrator.java
index 360456b886..c987dee521 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/BeanValidationIntegrator.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/BeanValidationIntegrator.java
@@ -84,9 +84,10 @@ public class BeanValidationIntegrator implements Integrator {
}
@Override
- public void integrate(Metadata metadata,
- BootstrapContext bootstrapContext,
- SessionFactoryImplementor sessionFactory) {
+ public void integrate(
+ Metadata metadata,
+ BootstrapContext bootstrapContext,
+ SessionFactoryImplementor sessionFactory) {
ServiceRegistryImplementor serviceRegistry = sessionFactory.getServiceRegistry();
final ConfigurationService cfgService = serviceRegistry.getService( ConfigurationService.class );
// IMPL NOTE : see the comments on ActivationContext.getValidationModes() as to why this is multi-valued...
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/TypeSafeActivator.java b/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/TypeSafeActivator.java
index 7db2fb3025..8b42700b36 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/TypeSafeActivator.java
+++ b/hibernate-core/src/main/java/org/hibernate/cfg/beanvalidation/TypeSafeActivator.java
@@ -14,16 +14,6 @@ import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
-import jakarta.validation.Validation;
-import jakarta.validation.ValidatorFactory;
-import jakarta.validation.constraints.Digits;
-import jakarta.validation.constraints.Max;
-import jakarta.validation.constraints.Min;
-import jakarta.validation.constraints.NotNull;
-import jakarta.validation.constraints.Size;
-import jakarta.validation.metadata.BeanDescriptor;
-import jakarta.validation.metadata.ConstraintDescriptor;
-import jakarta.validation.metadata.PropertyDescriptor;
import org.hibernate.AssertionFailure;
import org.hibernate.MappingException;
@@ -51,6 +41,17 @@ import org.hibernate.mapping.SingleTableSubclass;
import org.jboss.logging.Logger;
+import jakarta.validation.Validation;
+import jakarta.validation.ValidatorFactory;
+import jakarta.validation.constraints.Digits;
+import jakarta.validation.constraints.Max;
+import jakarta.validation.constraints.Min;
+import jakarta.validation.constraints.NotNull;
+import jakarta.validation.constraints.Size;
+import jakarta.validation.metadata.BeanDescriptor;
+import jakarta.validation.metadata.ConstraintDescriptor;
+import jakarta.validation.metadata.PropertyDescriptor;
+
/**
* @author Emmanuel Bernard
* @author Hardy Ferentschik
@@ -222,12 +223,14 @@ class TypeSafeActivator {
final boolean canSetNotNullOnColumns = activateNotNull && hasNotNull;
applyDDL(
prefix + propertyDesc.getPropertyName() + ".",
- persistentClass, componentClass, factory, groups,
+ persistentClass,
+ componentClass,
+ factory,
+ groups,
canSetNotNullOnColumns,
- dialect
+ dialect
);
}
- //FIXME add collection of components
}
}
}
diff --git a/hibernate-core/src/main/java/org/hibernate/graph/internal/RootGraphImpl.java b/hibernate-core/src/main/java/org/hibernate/graph/internal/RootGraphImpl.java
index e7875512b7..d6902a30c6 100644
--- a/hibernate-core/src/main/java/org/hibernate/graph/internal/RootGraphImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/graph/internal/RootGraphImpl.java
@@ -6,9 +6,6 @@
*/
package org.hibernate.graph.internal;
-import jakarta.persistence.EntityGraph;
-
-import org.hibernate.cfg.NotYetImplementedException;
import org.hibernate.graph.SubGraph;
import org.hibernate.graph.spi.GraphImplementor;
import org.hibernate.graph.spi.RootGraphImplementor;
@@ -18,6 +15,8 @@ import org.hibernate.metamodel.model.domain.IdentifiableDomainType;
import org.hibernate.metamodel.model.domain.JpaMetamodel;
import org.hibernate.metamodel.model.domain.ManagedDomainType;
+import jakarta.persistence.EntityGraph;
+
/**
* The Hibernate implementation of the JPA EntityGraph contract.
*
@@ -75,7 +74,7 @@ public class RootGraphImpl extends AbstractGraph implements EntityGraph
@Override
public SubGraph extends T1> addSubclassSubgraph(Class extends T1> type) {
- throw new NotYetImplementedException( );
+ throw new UnsupportedOperationException();
}
@Override
diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/BaselineSessionEventsListenerBuilder.java b/hibernate-core/src/main/java/org/hibernate/internal/BaselineSessionEventsListenerBuilder.java
similarity index 95%
rename from hibernate-core/src/main/java/org/hibernate/cfg/BaselineSessionEventsListenerBuilder.java
rename to hibernate-core/src/main/java/org/hibernate/internal/BaselineSessionEventsListenerBuilder.java
index 8d8b6404e0..abcd810775 100644
--- a/hibernate-core/src/main/java/org/hibernate/cfg/BaselineSessionEventsListenerBuilder.java
+++ b/hibernate-core/src/main/java/org/hibernate/internal/BaselineSessionEventsListenerBuilder.java
@@ -2,9 +2,9 @@
* 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 .
+ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
*/
-package org.hibernate.cfg;
+package org.hibernate.internal;
import java.util.ArrayList;
import java.util.Collections;
diff --git a/hibernate-core/src/main/java/org/hibernate/internal/FastSessionServices.java b/hibernate-core/src/main/java/org/hibernate/internal/FastSessionServices.java
index 3c5795adf8..d24f56ad07 100644
--- a/hibernate-core/src/main/java/org/hibernate/internal/FastSessionServices.java
+++ b/hibernate-core/src/main/java/org/hibernate/internal/FastSessionServices.java
@@ -10,9 +10,6 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
-import jakarta.persistence.CacheRetrieveMode;
-import jakarta.persistence.CacheStoreMode;
-import jakarta.persistence.PessimisticLockScope;
import org.hibernate.CacheMode;
import org.hibernate.FlushMode;
@@ -21,7 +18,6 @@ import org.hibernate.LockOptions;
import org.hibernate.TimeZoneStorageStrategy;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.boot.spi.SessionFactoryOptions;
-import org.hibernate.cfg.BaselineSessionEventsListenerBuilder;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.jdbc.batch.spi.BatchBuilder;
@@ -72,6 +68,10 @@ import org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder;
import org.hibernate.service.spi.ServiceRegistryImplementor;
import org.hibernate.type.FormatMapper;
+import jakarta.persistence.CacheRetrieveMode;
+import jakarta.persistence.CacheStoreMode;
+import jakarta.persistence.PessimisticLockScope;
+
import static org.hibernate.cfg.AvailableSettings.JAKARTA_LOCK_SCOPE;
import static org.hibernate.cfg.AvailableSettings.JAKARTA_LOCK_TIMEOUT;
import static org.hibernate.cfg.AvailableSettings.JAKARTA_SHARED_CACHE_RETRIEVE_MODE;
diff --git a/hibernate-core/src/main/java/org/hibernate/jpa/internal/MutableJpaComplianceImpl.java b/hibernate-core/src/main/java/org/hibernate/jpa/internal/MutableJpaComplianceImpl.java
index b886959ec1..6d997654af 100644
--- a/hibernate-core/src/main/java/org/hibernate/jpa/internal/MutableJpaComplianceImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/jpa/internal/MutableJpaComplianceImpl.java
@@ -27,7 +27,7 @@ public class MutableJpaComplianceImpl implements MutableJpaCompliance {
private boolean cachingCompliance;
private boolean loadByIdCompliance;
- public MutableJpaComplianceImpl(Map configurationSettings) {
+ public MutableJpaComplianceImpl(Map,?> configurationSettings) {
this(
configurationSettings,
ConfigurationHelper.getBoolean(
@@ -39,9 +39,10 @@ public class MutableJpaComplianceImpl implements MutableJpaCompliance {
}
@SuppressWarnings("ConstantConditions")
- public MutableJpaComplianceImpl(Map configurationSettings, boolean jpaByDefault) {
+ public MutableJpaComplianceImpl(Map,?> configurationSettings, boolean jpaByDefault) {
final Object legacyQueryCompliance = configurationSettings.get( AvailableSettings.JPAQL_STRICT_COMPLIANCE );
+ //noinspection deprecation
listCompliance = ConfigurationHelper.getBoolean(
AvailableSettings.JPA_LIST_COMPLIANCE,
configurationSettings,
@@ -62,31 +63,26 @@ public class MutableJpaComplianceImpl implements MutableJpaCompliance {
configurationSettings,
jpaByDefault
);
-
queryCompliance = ConfigurationHelper.getBoolean(
AvailableSettings.JPA_QUERY_COMPLIANCE,
configurationSettings,
ConfigurationHelper.toBoolean( legacyQueryCompliance, jpaByDefault )
);
-
transactionCompliance = ConfigurationHelper.getBoolean(
AvailableSettings.JPA_TRANSACTION_COMPLIANCE,
configurationSettings,
jpaByDefault
);
-
closedCompliance = ConfigurationHelper.getBoolean(
AvailableSettings.JPA_CLOSED_COMPLIANCE,
configurationSettings,
jpaByDefault
);
-
cachingCompliance = ConfigurationHelper.getBoolean(
AvailableSettings.JPA_CACHING_COMPLIANCE,
configurationSettings,
jpaByDefault
);
-
loadByIdCompliance = ConfigurationHelper.getBoolean(
AvailableSettings.JPA_LOAD_BY_ID_COMPLIANCE,
configurationSettings,
diff --git a/hibernate-core/src/main/java/org/hibernate/mapping/BasicValue.java b/hibernate-core/src/main/java/org/hibernate/mapping/BasicValue.java
index d3b8a10d62..55a0ee39fd 100644
--- a/hibernate-core/src/main/java/org/hibernate/mapping/BasicValue.java
+++ b/hibernate-core/src/main/java/org/hibernate/mapping/BasicValue.java
@@ -806,7 +806,7 @@ public class BasicValue extends SimpleValue implements JdbcTypeIndicators, Resol
}
final BootstrapContext bootstrapContext = getBuildingContext().getBootstrapContext();
- final BeanInstanceProducer instanceProducer = bootstrapContext.getBeanInstanceProducer();
+ final BeanInstanceProducer instanceProducer = bootstrapContext.getCustomTypeProducer();
final Properties properties = new Properties();
if ( CollectionHelper.isNotEmpty( getTypeParameters() ) ) {
diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/package-info.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/package-info.java
index 266ea88c98..25c4a3daff 100644
--- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/package-info.java
+++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/package-info.java
@@ -6,12 +6,13 @@
*/
/**
- * Hibernate's run-time mapping model. This model defines the mapping of the application's domain model
+ * Hibernate's run-time mapping metamodel which defines the mapping
+ * of the application's domain model parts (entity, attribute, etc)
* to database objects (tables, columns, etc).
*
- * @implNote At the moment, this mapping model is built on top of the {@link org.hibernate.persister} package.
+ * @implNote Built on top of the {@link org.hibernate.persister} package.
*
- * @implSpec This entire package is considered an SPI and incubating at the moment
+ * @implSpec This entire package is considered incubating at the moment
*/
@Incubating
package org.hibernate.metamodel.mapping;
diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/JpaMetamodelImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/JpaMetamodelImpl.java
index 69ea9dc0a7..b0bb703ad9 100644
--- a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/JpaMetamodelImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/JpaMetamodelImpl.java
@@ -20,10 +20,10 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Consumer;
import java.util.stream.Stream;
+import org.hibernate.boot.model.NamedEntityGraphDefinition;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
import org.hibernate.boot.spi.MetadataImplementor;
-import org.hibernate.cfg.annotations.NamedEntityGraphDefinition;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.graph.internal.RootGraphImpl;
import org.hibernate.graph.spi.AttributeNodeImplementor;
diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/MappedSuperclassTypeImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/MappedSuperclassTypeImpl.java
index 9cbb144e08..17a2e49ac5 100644
--- a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/MappedSuperclassTypeImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/MappedSuperclassTypeImpl.java
@@ -6,16 +6,12 @@
*/
package org.hibernate.metamodel.model.domain.internal;
-import org.hibernate.cfg.NotYetImplementedException;
import org.hibernate.graph.internal.SubGraphImpl;
import org.hibernate.graph.spi.SubGraphImplementor;
import org.hibernate.mapping.MappedSuperclass;
import org.hibernate.metamodel.UnsupportedMappingException;
-import org.hibernate.metamodel.mapping.EntityDiscriminatorMapping;
import org.hibernate.metamodel.mapping.EntityIdentifierMapping;
import org.hibernate.metamodel.model.domain.AbstractIdentifiableType;
-import org.hibernate.metamodel.model.domain.DomainType;
-import org.hibernate.metamodel.model.domain.EntityDomainType;
import org.hibernate.metamodel.model.domain.IdentifiableDomainType;
import org.hibernate.metamodel.model.domain.JpaMetamodel;
import org.hibernate.metamodel.model.domain.MappedSuperclassDomainType;
diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/QuerySqmImpl.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/QuerySqmImpl.java
index 0978d5b615..9f0482d446 100644
--- a/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/QuerySqmImpl.java
+++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/QuerySqmImpl.java
@@ -19,14 +19,6 @@ import java.util.Optional;
import java.util.function.Supplier;
import java.util.stream.Stream;
-import jakarta.persistence.CacheRetrieveMode;
-import jakarta.persistence.CacheStoreMode;
-import jakarta.persistence.FlushModeType;
-import jakarta.persistence.LockModeType;
-import jakarta.persistence.Parameter;
-import jakarta.persistence.PersistenceException;
-import jakarta.persistence.TemporalType;
-
import org.hibernate.CacheMode;
import org.hibernate.FlushMode;
import org.hibernate.HibernateException;
@@ -34,11 +26,11 @@ import org.hibernate.LockMode;
import org.hibernate.LockOptions;
import org.hibernate.ScrollMode;
import org.hibernate.TypeMismatchException;
-import org.hibernate.cfg.NotYetImplementedException;
import org.hibernate.engine.query.spi.EntityGraphQueryHint;
import org.hibernate.engine.spi.LoadQueryInfluencers;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
+import org.hibernate.generator.Generator;
import org.hibernate.graph.GraphSemantic;
import org.hibernate.graph.RootGraph;
import org.hibernate.graph.spi.AppliedGraph;
@@ -107,7 +99,14 @@ import org.hibernate.query.sqm.tree.update.SqmAssignment;
import org.hibernate.query.sqm.tree.update.SqmUpdateStatement;
import org.hibernate.sql.results.internal.TupleMetadata;
import org.hibernate.sql.results.spi.ListResultsConsumer;
-import org.hibernate.generator.Generator;
+
+import jakarta.persistence.CacheRetrieveMode;
+import jakarta.persistence.CacheStoreMode;
+import jakarta.persistence.FlushModeType;
+import jakarta.persistence.LockModeType;
+import jakarta.persistence.Parameter;
+import jakarta.persistence.PersistenceException;
+import jakarta.persistence.TemporalType;
import static org.hibernate.jpa.HibernateHints.HINT_CACHEABLE;
import static org.hibernate.jpa.HibernateHints.HINT_CACHE_MODE;
@@ -770,7 +769,7 @@ public class QuerySqmImpl
return buildInsertQueryPlan();
}
- throw new NotYetImplementedException( "Query#executeUpdate for Statements of type [" + getSqmStatement() + "not yet supported" );
+ throw new UnsupportedOperationException( "Query#executeUpdate for Statements of type [" + getSqmStatement() + "] not supported" );
}
@SuppressWarnings({ "unchecked", "rawtypes" })
diff --git a/hibernate-core/src/main/java/org/hibernate/tuple/entity/EntityMetamodel.java b/hibernate-core/src/main/java/org/hibernate/tuple/entity/EntityMetamodel.java
index 7501a66f35..15c62927b5 100644
--- a/hibernate-core/src/main/java/org/hibernate/tuple/entity/EntityMetamodel.java
+++ b/hibernate-core/src/main/java/org/hibernate/tuple/entity/EntityMetamodel.java
@@ -25,7 +25,6 @@ import org.hibernate.bytecode.enhance.spi.interceptor.EnhancementHelper;
import org.hibernate.bytecode.internal.BytecodeEnhancementMetadataNonPojoImpl;
import org.hibernate.bytecode.internal.BytecodeEnhancementMetadataPojoImpl;
import org.hibernate.bytecode.spi.BytecodeEnhancementMetadata;
-import org.hibernate.cfg.NotYetImplementedException;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.OptimisticLockStyle;
import org.hibernate.engine.spi.CascadeStyle;
@@ -558,7 +557,7 @@ public class EntityMetamodel implements Serializable {
);
}
else if ( hadInMemoryGeneration ) {
- throw new NotYetImplementedException( "Still need to wire in composite in-memory value generation" );
+ throw new UnsupportedOperationException( "Composite in-memory value generation not supported" );
}
else if ( hadInDatabaseGeneration ) {
diff --git a/hibernate-core/src/main/java/org/hibernate/type/spi/TypeBootstrapContext.java b/hibernate-core/src/main/java/org/hibernate/type/spi/TypeBootstrapContext.java
index 65fe898242..11c398b42f 100644
--- a/hibernate-core/src/main/java/org/hibernate/type/spi/TypeBootstrapContext.java
+++ b/hibernate-core/src/main/java/org/hibernate/type/spi/TypeBootstrapContext.java
@@ -20,5 +20,6 @@ import java.util.Map;
* @since 5.4
*/
public interface TypeBootstrapContext {
+ @SuppressWarnings("unused")
Map getConfigurationSettings();
}
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/formula/JoinFormulaManyToOneNotIgnoreLazyFetchingTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/formula/JoinFormulaManyToOneNotIgnoreLazyFetchingTest.java
index d408d7729c..e85fe7bf12 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/formula/JoinFormulaManyToOneNotIgnoreLazyFetchingTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/formula/JoinFormulaManyToOneNotIgnoreLazyFetchingTest.java
@@ -8,20 +8,12 @@ package org.hibernate.orm.test.annotations.formula;
import java.io.Serializable;
import java.util.List;
-import jakarta.persistence.Column;
-import jakarta.persistence.Entity;
-import jakarta.persistence.EnumType;
-import jakarta.persistence.Enumerated;
-import jakarta.persistence.FetchType;
-import jakarta.persistence.Id;
-import jakarta.persistence.JoinColumn;
-import jakarta.persistence.ManyToOne;
import org.hibernate.annotations.JoinColumnOrFormula;
import org.hibernate.annotations.JoinFormula;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
-import org.hibernate.cfg.AnnotationBinder;
+import org.hibernate.boot.model.internal.AnnotationBinder;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
@@ -33,12 +25,19 @@ import org.junit.Test;
import org.jboss.logging.Logger;
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.EnumType;
+import jakarta.persistence.Enumerated;
+import jakarta.persistence.FetchType;
+import jakarta.persistence.Id;
+import jakarta.persistence.JoinColumn;
+import jakarta.persistence.ManyToOne;
+
import static org.assertj.core.api.Assertions.assertThat;
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
@TestForIssue(jiraKey = "HHH-12770")
public class JoinFormulaManyToOneNotIgnoreLazyFetchingTest extends BaseEntityManagerFunctionalTestCase {
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/formula/JoinFormulaOneToOneNotIgnoreLazyFetchingTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/formula/JoinFormulaOneToOneNotIgnoreLazyFetchingTest.java
index 25ad48f306..35917bbcbe 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/formula/JoinFormulaOneToOneNotIgnoreLazyFetchingTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/formula/JoinFormulaOneToOneNotIgnoreLazyFetchingTest.java
@@ -8,21 +8,12 @@ package org.hibernate.orm.test.annotations.formula;
import java.io.Serializable;
import java.util.List;
-import jakarta.persistence.Column;
-import jakarta.persistence.Entity;
-import jakarta.persistence.EnumType;
-import jakarta.persistence.Enumerated;
-import jakarta.persistence.FetchType;
-import jakarta.persistence.Id;
-import jakarta.persistence.JoinColumn;
-import jakarta.persistence.ManyToOne;
-import jakarta.persistence.OneToOne;
import org.hibernate.annotations.JoinColumnOrFormula;
import org.hibernate.annotations.JoinFormula;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
-import org.hibernate.cfg.AnnotationBinder;
+import org.hibernate.boot.model.internal.AnnotationBinder;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
@@ -34,6 +25,15 @@ import org.junit.Test;
import org.jboss.logging.Logger;
+import jakarta.persistence.Column;
+import jakarta.persistence.Entity;
+import jakarta.persistence.EnumType;
+import jakarta.persistence.Enumerated;
+import jakarta.persistence.FetchType;
+import jakarta.persistence.Id;
+import jakarta.persistence.JoinColumn;
+import jakarta.persistence.OneToOne;
+
import static org.assertj.core.api.Assertions.assertThat;
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
import static org.junit.Assert.assertEquals;
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/formula/ManyToManyNotIgnoreLazyFetchingTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/formula/ManyToManyNotIgnoreLazyFetchingTest.java
index 34929a05ff..3b937e6eea 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/formula/ManyToManyNotIgnoreLazyFetchingTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/formula/ManyToManyNotIgnoreLazyFetchingTest.java
@@ -6,6 +6,26 @@
*/
package org.hibernate.orm.test.annotations.formula;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.hibernate.Hibernate;
+import org.hibernate.annotations.NotFound;
+import org.hibernate.annotations.NotFoundAction;
+import org.hibernate.boot.model.internal.AnnotationBinder;
+import org.hibernate.engine.spi.SessionFactoryImplementor;
+import org.hibernate.internal.CoreMessageLogger;
+import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
+
+import org.hibernate.testing.TestForIssue;
+import org.hibernate.testing.logger.LoggerInspectionRule;
+import org.hibernate.testing.logger.Triggerable;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.jboss.logging.Logger;
+
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
@@ -14,23 +34,6 @@ import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.JoinTable;
import jakarta.persistence.ManyToMany;
-import org.hibernate.Hibernate;
-import org.hibernate.annotations.NotFound;
-import org.hibernate.annotations.NotFoundAction;
-import org.hibernate.cfg.AnnotationBinder;
-import org.hibernate.engine.spi.SessionFactoryImplementor;
-import org.hibernate.internal.CoreMessageLogger;
-import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
-import org.hibernate.testing.TestForIssue;
-import org.hibernate.testing.logger.LoggerInspectionRule;
-import org.hibernate.testing.logger.Triggerable;
-import org.jboss.logging.Logger;
-import org.junit.Rule;
-import org.junit.Test;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/id/AndFormulaTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/id/AndFormulaTest.java
index d5ddc101e0..c841ec5321 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/id/AndFormulaTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/id/AndFormulaTest.java
@@ -6,22 +6,21 @@
*/
package org.hibernate.orm.test.annotations.id;
-import jakarta.persistence.Entity;
-import jakarta.persistence.Id;
-
import org.hibernate.annotations.Formula;
import org.hibernate.boot.MetadataSources;
+import org.hibernate.boot.model.internal.CannotForceNonNullableException;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
-import org.hibernate.cfg.CannotForceNonNullableException;
import org.hibernate.testing.orm.junit.BaseUnitTest;
import org.hibernate.testing.orm.junit.ServiceRegistry;
-
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import jakarta.persistence.Entity;
+import jakarta.persistence.Id;
+
import static org.hamcrest.CoreMatchers.startsWith;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.fail;
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/override/inheritance/EntityInheritanceAttributeOverrideTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/override/inheritance/EntityInheritanceAttributeOverrideTest.java
index 272f46a9ad..b5f0ccb06d 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/override/inheritance/EntityInheritanceAttributeOverrideTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/override/inheritance/EntityInheritanceAttributeOverrideTest.java
@@ -6,6 +6,18 @@
*/
package org.hibernate.orm.test.annotations.override.inheritance;
+import org.hibernate.boot.model.internal.EntityBinder;
+import org.hibernate.internal.CoreMessageLogger;
+
+import org.hibernate.testing.TestForIssue;
+import org.hibernate.testing.logger.LoggerInspectionRule;
+import org.hibernate.testing.logger.Triggerable;
+import org.hibernate.testing.orm.junit.EntityManagerFactoryBasedFunctionalTest;
+import org.junit.Rule;
+import org.junit.jupiter.api.Test;
+
+import org.jboss.logging.Logger;
+
import jakarta.persistence.AttributeOverride;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
@@ -16,19 +28,6 @@ import jakarta.persistence.InheritanceType;
import jakarta.persistence.Table;
import jakarta.persistence.UniqueConstraint;
-import org.hibernate.cfg.AnnotationBinder;
-import org.hibernate.cfg.annotations.EntityBinder;
-import org.hibernate.internal.CoreMessageLogger;
-
-import org.hibernate.testing.TestForIssue;
-import org.hibernate.testing.orm.junit.EntityManagerFactoryBasedFunctionalTest;
-import org.hibernate.testing.logger.LoggerInspectionRule;
-import org.hibernate.testing.logger.Triggerable;
-import org.junit.Rule;
-import org.junit.jupiter.api.Test;
-
-import org.jboss.logging.Logger;
-
import static org.junit.jupiter.api.Assertions.assertTrue;
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/reflection/JPAXMLOverriddenAnnotationReaderTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/reflection/JPAXMLOverriddenAnnotationReaderTest.java
index 03cf3cf997..e81ddba35e 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/reflection/JPAXMLOverriddenAnnotationReaderTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/reflection/JPAXMLOverriddenAnnotationReaderTest.java
@@ -12,8 +12,8 @@ import java.lang.reflect.Method;
import org.hibernate.annotations.Columns;
import org.hibernate.boot.jaxb.mapping.JaxbEntityMappings;
-import org.hibernate.cfg.annotations.reflection.internal.JPAXMLOverriddenAnnotationReader;
-import org.hibernate.cfg.annotations.reflection.internal.XMLContext;
+import org.hibernate.boot.model.internal.JPAXMLOverriddenAnnotationReader;
+import org.hibernate.boot.model.internal.XMLContext;
import org.hibernate.orm.test.internal.util.xml.XMLMappingHelper;
import org.hibernate.testing.TestForIssue;
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/reflection/XMLContextTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/reflection/XMLContextTest.java
index 1694016863..e7cea09fd6 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/reflection/XMLContextTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/reflection/XMLContextTest.java
@@ -7,7 +7,7 @@
package org.hibernate.orm.test.annotations.reflection;
import org.hibernate.boot.jaxb.mapping.JaxbEntityMappings;
-import org.hibernate.cfg.annotations.reflection.internal.XMLContext;
+import org.hibernate.boot.model.internal.XMLContext;
import org.hibernate.orm.test.internal.util.xml.XMLMappingHelper;
import org.hibernate.testing.TestForIssue;
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/ejb3/Ejb3XmlTestCase.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/ejb3/Ejb3XmlTestCase.java
index fee1820d4f..63d471e564 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/ejb3/Ejb3XmlTestCase.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/xml/ejb3/Ejb3XmlTestCase.java
@@ -11,8 +11,8 @@ import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
import org.hibernate.boot.jaxb.mapping.JaxbEntityMappings;
-import org.hibernate.cfg.annotations.reflection.internal.JPAXMLOverriddenAnnotationReader;
-import org.hibernate.cfg.annotations.reflection.internal.XMLContext;
+import org.hibernate.boot.model.internal.JPAXMLOverriddenAnnotationReader;
+import org.hibernate.boot.model.internal.XMLContext;
import org.hibernate.orm.test.internal.util.xml.XMLMappingHelper;
import org.hibernate.testing.boot.BootstrapContextImpl;
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/cache/NonRootEntityWithCacheAnnotationTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/cache/NonRootEntityWithCacheAnnotationTest.java
index 5e2ac22102..075e27ed21 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/cache/NonRootEntityWithCacheAnnotationTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/cache/NonRootEntityWithCacheAnnotationTest.java
@@ -8,19 +8,15 @@ package org.hibernate.orm.test.cache;
import java.util.HashMap;
import java.util.Map;
-import jakarta.persistence.Entity;
-import jakarta.persistence.Id;
-import jakarta.persistence.Inheritance;
-import jakarta.persistence.SharedCacheMode;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.boot.Metadata;
import org.hibernate.boot.MetadataSources;
+import org.hibernate.boot.model.internal.EntityBinder;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Environment;
-import org.hibernate.cfg.annotations.EntityBinder;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.service.spi.ServiceRegistryImplementor;
@@ -33,8 +29,12 @@ import org.junit.Test;
import org.jboss.logging.Logger;
+import jakarta.persistence.Entity;
+import jakarta.persistence.Id;
+import jakarta.persistence.Inheritance;
+import jakarta.persistence.SharedCacheMode;
+
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
/**
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/cache/NonRootEntityWithCacheableAnnotationTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/cache/NonRootEntityWithCacheableAnnotationTest.java
index ed309d675e..eae3fc31b4 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/cache/NonRootEntityWithCacheableAnnotationTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/cache/NonRootEntityWithCacheableAnnotationTest.java
@@ -8,18 +8,13 @@ package org.hibernate.orm.test.cache;
import java.util.HashMap;
import java.util.Map;
-import jakarta.persistence.Cacheable;
-import jakarta.persistence.Entity;
-import jakarta.persistence.Id;
-import jakarta.persistence.Inheritance;
-import jakarta.persistence.SharedCacheMode;
import org.hibernate.boot.Metadata;
import org.hibernate.boot.MetadataSources;
+import org.hibernate.boot.model.internal.EntityBinder;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Environment;
-import org.hibernate.cfg.annotations.EntityBinder;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.service.spi.ServiceRegistryImplementor;
@@ -32,6 +27,12 @@ import org.junit.Test;
import org.jboss.logging.Logger;
+import jakarta.persistence.Cacheable;
+import jakarta.persistence.Entity;
+import jakarta.persistence.Id;
+import jakarta.persistence.Inheritance;
+import jakarta.persistence.SharedCacheMode;
+
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/cfg/AnnotationBinderTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/cfg/AnnotationBinderTest.java
index ff95b930fd..5a40a76518 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/cfg/AnnotationBinderTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/cfg/AnnotationBinderTest.java
@@ -6,24 +6,26 @@
*/
package org.hibernate.orm.test.cfg;
-import static org.junit.Assert.assertTrue;
+import org.hibernate.boot.Metadata;
+import org.hibernate.boot.MetadataSources;
+import org.hibernate.boot.model.internal.EntityBinder;
+import org.hibernate.boot.registry.StandardServiceRegistry;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
+import org.hibernate.internal.CoreMessageLogger;
+
+import org.hibernate.testing.TestForIssue;
+import org.hibernate.testing.logger.LoggerInspectionRule;
+import org.hibernate.testing.logger.Triggerable;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.jboss.logging.Logger;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.PrimaryKeyJoinColumn;
-import org.hibernate.boot.Metadata;
-import org.hibernate.boot.MetadataSources;
-import org.hibernate.boot.registry.StandardServiceRegistry;
-import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
-import org.hibernate.cfg.AnnotationBinder;
-import org.hibernate.cfg.annotations.EntityBinder;
-import org.hibernate.internal.CoreMessageLogger;
-import org.hibernate.testing.TestForIssue;
-import org.hibernate.testing.logger.LoggerInspectionRule;
-import org.hibernate.testing.logger.Triggerable;
-import org.jboss.logging.Logger;
-import org.junit.Rule;
-import org.junit.Test;
+
+import static org.junit.Assert.assertTrue;
/**
* @author Dominique Toupin
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/cfg/persister/GoofyPersisterClassProvider.java b/hibernate-core/src/test/java/org/hibernate/orm/test/cfg/persister/GoofyPersisterClassProvider.java
index f0b45d217a..d102ead84c 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/cfg/persister/GoofyPersisterClassProvider.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/cfg/persister/GoofyPersisterClassProvider.java
@@ -27,7 +27,6 @@ import org.hibernate.cache.spi.access.EntityDataAccess;
import org.hibernate.cache.spi.access.NaturalIdDataAccess;
import org.hibernate.cache.spi.entry.CacheEntry;
import org.hibernate.cache.spi.entry.CacheEntryStructure;
-import org.hibernate.cfg.NotYetImplementedException;
import org.hibernate.collection.spi.CollectionSemantics;
import org.hibernate.collection.spi.PersistentCollection;
import org.hibernate.engine.internal.MutableEntityEntryFactory;
@@ -809,7 +808,7 @@ public class GoofyPersisterClassProvider implements PersisterClassResolver {
}
public CollectionType getCollectionType() {
- throw new NotYetImplementedException();
+ throw new UnsupportedOperationException();
}
public Type getKeyType() {
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/inheritance/MappedSuperclassInheritanceTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/inheritance/MappedSuperclassInheritanceTest.java
index 4cb1567ba6..b324d90729 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/inheritance/MappedSuperclassInheritanceTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/inheritance/MappedSuperclassInheritanceTest.java
@@ -6,14 +6,7 @@
*/
package org.hibernate.orm.test.inheritance;
-import jakarta.persistence.Entity;
-import jakarta.persistence.GeneratedValue;
-import jakarta.persistence.Id;
-import jakarta.persistence.Inheritance;
-import jakarta.persistence.InheritanceType;
-import jakarta.persistence.MappedSuperclass;
-
-import org.hibernate.cfg.AnnotationBinder;
+import org.hibernate.boot.model.internal.AnnotationBinder;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase;
import org.hibernate.query.SemanticException;
@@ -27,6 +20,13 @@ import org.junit.Test;
import org.jboss.logging.Logger;
+import jakarta.persistence.Entity;
+import jakarta.persistence.GeneratedValue;
+import jakarta.persistence.Id;
+import jakarta.persistence.Inheritance;
+import jakarta.persistence.InheritanceType;
+import jakarta.persistence.MappedSuperclass;
+
import static org.hibernate.testing.transaction.TransactionUtil.doInJPA;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/joinedsubclass/JoinedSubclassWithImplicitDiscriminatorTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/joinedsubclass/JoinedSubclassWithImplicitDiscriminatorTest.java
index 031d86f516..8567ebf4f9 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/joinedsubclass/JoinedSubclassWithImplicitDiscriminatorTest.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/joinedsubclass/JoinedSubclassWithImplicitDiscriminatorTest.java
@@ -6,14 +6,8 @@
*/
package org.hibernate.orm.test.joinedsubclass;
-import jakarta.persistence.Entity;
-import jakarta.persistence.Id;
-import jakarta.persistence.Inheritance;
-import jakarta.persistence.InheritanceType;
-import jakarta.persistence.Table;
-
+import org.hibernate.boot.model.internal.AnnotatedDiscriminatorColumn;
import org.hibernate.cfg.AvailableSettings;
-import org.hibernate.cfg.AnnotatedDiscriminatorColumn;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.JoinedSubclassEntityPersister;
@@ -25,6 +19,12 @@ import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.hibernate.testing.orm.junit.Setting;
import org.junit.jupiter.api.Test;
+import jakarta.persistence.Entity;
+import jakarta.persistence.Id;
+import jakarta.persistence.Inheritance;
+import jakarta.persistence.InheritanceType;
+import jakarta.persistence.Table;
+
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.fail;
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/converted/converter/elementCollection/ElementCollectionTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/converted/converter/elementCollection/ElementCollectionTests.java
index 5bef8b41ca..d7478e4864 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/converted/converter/elementCollection/ElementCollectionTests.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/converted/converter/elementCollection/ElementCollectionTests.java
@@ -11,19 +11,8 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-import jakarta.persistence.AttributeConverter;
-import jakarta.persistence.CollectionTable;
-import jakarta.persistence.Column;
-import jakarta.persistence.Convert;
-import jakarta.persistence.Converts;
-import jakarta.persistence.ElementCollection;
-import jakarta.persistence.Entity;
-import jakarta.persistence.FetchType;
-import jakarta.persistence.Id;
-import jakarta.persistence.JoinColumn;
-import jakarta.persistence.MapKeyColumn;
-import jakarta.persistence.Table;
+import org.hibernate.boot.model.internal.CollectionPropertyHolder;
import org.hibernate.mapping.Collection;
import org.hibernate.mapping.IndexedCollection;
import org.hibernate.mapping.PersistentClass;
@@ -38,12 +27,25 @@ import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
+import jakarta.persistence.AttributeConverter;
+import jakarta.persistence.CollectionTable;
+import jakarta.persistence.Column;
+import jakarta.persistence.Convert;
+import jakarta.persistence.Converts;
+import jakarta.persistence.ElementCollection;
+import jakarta.persistence.Entity;
+import jakarta.persistence.FetchType;
+import jakarta.persistence.Id;
+import jakarta.persistence.JoinColumn;
+import jakarta.persistence.MapKeyColumn;
+import jakarta.persistence.Table;
+
import static org.hibernate.testing.junit4.ExtraAssertions.assertTyping;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
/**
- * Test for {@link org.hibernate.cfg.CollectionPropertyHolder}.
+ * Test for {@link CollectionPropertyHolder}.
*
* Tests that {@link jakarta.persistence.AttributeConverter}s are considered correctly for {@link jakarta.persistence.ElementCollection}.
*
diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/ejb3joincolumn/Tests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/ejb3joincolumn/Tests.java
index 1922ac5fa1..a63bcf02b3 100644
--- a/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/ejb3joincolumn/Tests.java
+++ b/hibernate-core/src/test/java/org/hibernate/orm/test/namingstrategy/ejb3joincolumn/Tests.java
@@ -12,11 +12,11 @@ import java.util.Locale;
import org.hibernate.boot.Metadata;
import org.hibernate.boot.MetadataBuilder;
import org.hibernate.boot.MetadataSources;
+import org.hibernate.boot.model.internal.AnnotatedJoinColumn;
import org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.boot.spi.MetadataImplementor;
-import org.hibernate.cfg.AnnotatedJoinColumn;
import org.hibernate.cfg.Environment;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.PersistentClass;
diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/boot/BootstrapContextImpl.java b/hibernate-testing/src/main/java/org/hibernate/testing/boot/BootstrapContextImpl.java
index 6c81878a6a..83c2ae797a 100644
--- a/hibernate-testing/src/main/java/org/hibernate/testing/boot/BootstrapContextImpl.java
+++ b/hibernate-testing/src/main/java/org/hibernate/testing/boot/BootstrapContextImpl.java
@@ -63,8 +63,8 @@ public class BootstrapContextImpl implements BootstrapContext {
}
@Override
- public BeanInstanceProducer getBeanInstanceProducer() {
- return delegate.getBeanInstanceProducer();
+ public BeanInstanceProducer getCustomTypeProducer() {
+ return delegate.getCustomTypeProducer();
}
@Override
diff --git a/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/SettingProvider.java b/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/SettingProvider.java
index 51c2befaef..9e4ac9c658 100644
--- a/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/SettingProvider.java
+++ b/hibernate-testing/src/main/java/org/hibernate/testing/orm/junit/SettingProvider.java
@@ -7,13 +7,29 @@
package org.hibernate.testing.orm.junit;
/**
+ * Annotation to allow providing settings whose values can be
+ * types other than String.
+ *
* @author Steve Ebersole
*/
public @interface SettingProvider {
+ /**
+ * The name of the setting whose value is being provided
+ */
+ String settingName();
+
+ /**
+ * The value provider
+ */
+ Class extends Provider>> provider();
+
+ /**
+ * Contract for providing a value
+ */
interface Provider {
+ /**
+ * Get the setting value
+ */
S getSetting();
}
-
- String settingName();
- Class extends Provider>> provider();
}