HHH-15799 - API/internal split for org.hibernate.cfg package

This commit is contained in:
Steve Ebersole 2022-12-19 14:52:35 -06:00
parent 023e73cb46
commit 3f7dd8c23b
163 changed files with 2360 additions and 2242 deletions

View File

@ -502,9 +502,6 @@ checkstyle {
// exclude generated java sources - by explicitly setting the base source dir
tasks.checkstyleMain.source = 'src/main/java'
// because cfg package is a mess mainly from annotation stuff
tasks.checkstyleMain.exclude '**/org/hibernate/cfg/**'
tasks.checkstyleMain.exclude '**/org/hibernate/cfg/*'
// define a second checkstyle task for checking non-fatal violations
task nonFatalCheckstyle(type:Checkstyle) {

View File

@ -6,13 +6,25 @@
*/
package org.hibernate.annotations;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import org.hibernate.usertype.UserType;
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
/**
* Form of {@link Type} for use with map-keys
*
* @since 6.0
*/
@Target({METHOD, FIELD, ANNOTATION_TYPE})
@Inherited
@Retention(RUNTIME)
public @interface MapKeyType {
/**
* The custom type implementor class

View File

@ -7,12 +7,12 @@
package org.hibernate.boot;
/**
* Models the definition of caching settings for a particular region. Generally as found in either:<ul>
* Models the definition of caching settings for a particular region. Generally found in:<ul>
* <li>{@code cfg.xml}</li>
* <li>annotations</li>
* <li>{@code orm.xml}</li>
* <li>{@code hbm.xml}</li>
* <li>annotation</li>
* </ul>
* Though certainly other custom sources are acceptable too.
*
* @author Steve Ebersole
*/

View File

@ -13,13 +13,13 @@ import java.util.function.Consumer;
import org.hibernate.SessionFactory;
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.Mapping;
import org.hibernate.mapping.Collection;

View File

@ -357,7 +357,10 @@ public interface MetadataBuilder {
* @return {@code this} for method chaining
*
* @see org.hibernate.cfg.AvailableSettings#ARTIFACT_PROCESSING_ORDER
*
* @deprecated {@code hbm.xml} mappings are no longer supported, making this irrelevant
*/
@Deprecated(since = "6", forRemoval = true)
MetadataBuilder applySourceProcessOrdering(MetadataSourceType... sourceTypes);
MetadataBuilder applySqlFunction(String functionName, SqmFunctionDescriptor function);

View File

@ -17,7 +17,6 @@ import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.hibernate.HibernateException;
import org.hibernate.Internal;

View File

@ -11,6 +11,8 @@ import java.net.URL;
/**
* Abstraction for locating class-path resources
*
* @see ResourceStreamLocator
*
* @author Steve Ebersole
*/
@FunctionalInterface

View File

@ -11,6 +11,8 @@ import java.io.InputStream;
/**
* Abstraction for locating class-path resources
*
* @see ResourceLocator
*
* @author Steve Ebersole
*/
@FunctionalInterface

View File

@ -9,6 +9,8 @@ package org.hibernate.boot;
import org.hibernate.boot.jaxb.Origin;
/**
* Specialized exception indicating that an unsupported {@code orm.xml} XSD version was specified
*
* @author Steve Ebersole
*/
public class UnsupportedOrmXsdVersionException extends MappingException {

View File

@ -23,6 +23,7 @@ import org.hibernate.boot.archive.scan.spi.Scanner;
import org.hibernate.boot.archive.spi.ArchiveDescriptorFactory;
import org.hibernate.boot.model.TypeBeanInstanceProducer;
import org.hibernate.boot.model.convert.spi.ConverterDescriptor;
import org.hibernate.boot.model.internal.JPAXMLOverriddenMetadataProvider;
import org.hibernate.boot.model.relational.AuxiliaryDatabaseObject;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
@ -31,7 +32,6 @@ import org.hibernate.boot.spi.BootstrapContext;
import org.hibernate.boot.spi.ClassLoaderAccess;
import org.hibernate.boot.spi.MetadataBuildingOptions;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.annotations.reflection.internal.JPAXMLOverriddenMetadataProvider;
import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.jpa.internal.MutableJpaComplianceImpl;
import org.hibernate.jpa.spi.MutableJpaCompliance;
@ -126,7 +126,7 @@ public class BootstrapContextImpl implements BootstrapContext {
}
@Override
public BeanInstanceProducer getBeanInstanceProducer() {
public BeanInstanceProducer getCustomTypeProducer() {
return beanInstanceProducer;
}

View File

@ -33,6 +33,7 @@ import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.boot.CacheRegionDefinition;
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.TypeDefinitionRegistry;
import org.hibernate.boot.model.TypeDefinitionRegistryStandardImpl;
@ -42,6 +43,17 @@ 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.AggregateComponentSecondPass;
import org.hibernate.boot.model.internal.AnnotatedClassType;
import org.hibernate.boot.model.internal.CreateKeySecondPass;
import org.hibernate.boot.model.internal.FkSecondPass;
import org.hibernate.boot.model.internal.IdGeneratorResolverSecondPass;
import org.hibernate.boot.model.internal.JPAIndexHolder;
import org.hibernate.boot.model.internal.QuerySecondPass;
import org.hibernate.boot.model.internal.SecondaryTableFromAnnotationSecondPass;
import org.hibernate.boot.model.internal.SecondaryTableSecondPass;
import org.hibernate.boot.model.internal.SetBasicValueTypeSecondPass;
import org.hibernate.boot.model.internal.UniqueConstraintHolder;
import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.boot.model.naming.ImplicitForeignKeyNameSource;
import org.hibernate.boot.model.naming.ImplicitIndexNameSource;
@ -62,25 +74,14 @@ import org.hibernate.boot.spi.InFlightMetadataCollector;
import org.hibernate.boot.spi.MetadataBuildingContext;
import org.hibernate.boot.spi.MetadataBuildingOptions;
import org.hibernate.boot.spi.NaturalIdUniqueKeyBinder;
import org.hibernate.cfg.AggregateComponentSecondPass;
import org.hibernate.cfg.AnnotatedClassType;
import org.hibernate.boot.spi.PropertyData;
import org.hibernate.boot.spi.SecondPass;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.CreateKeySecondPass;
import org.hibernate.cfg.FkSecondPass;
import org.hibernate.cfg.IdGeneratorResolverSecondPass;
import org.hibernate.cfg.JPAIndexHolder;
import org.hibernate.cfg.PropertyData;
import org.hibernate.cfg.QuerySecondPass;
import org.hibernate.cfg.RecoverableException;
import org.hibernate.cfg.SecondPass;
import org.hibernate.cfg.SecondaryTableFromAnnotationSecondPass;
import org.hibernate.cfg.SecondaryTableSecondPass;
import org.hibernate.cfg.SetBasicValueTypeSecondPass;
import org.hibernate.cfg.UniqueConstraintHolder;
import org.hibernate.cfg.annotations.NamedEntityGraphDefinition;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.spi.FilterDefinition;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.generator.Generator;
import org.hibernate.internal.CoreLogging;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.collections.CollectionHelper;
@ -105,17 +106,16 @@ import org.hibernate.metamodel.CollectionClassification;
import org.hibernate.metamodel.spi.EmbeddableInstantiator;
import org.hibernate.query.named.NamedObjectRepository;
import org.hibernate.query.sqm.function.SqmFunctionDescriptor;
import org.hibernate.generator.Generator;
import org.hibernate.type.descriptor.java.JavaType;
import org.hibernate.type.descriptor.jdbc.JdbcType;
import org.hibernate.type.spi.TypeConfiguration;
import org.hibernate.usertype.CompositeUserType;
import org.hibernate.usertype.UserType;
import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Embeddable;
import jakarta.persistence.Entity;
import jakarta.persistence.MapsId;
import org.hibernate.usertype.UserType;
/**
* The implementation of the {@linkplain InFlightMetadataCollector in-flight

View File

@ -23,6 +23,7 @@ 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.ColumnOrderingStrategy;
import org.hibernate.boot.model.relational.ColumnOrderingStrategyLegacy;
@ -41,7 +42,6 @@ import org.hibernate.boot.spi.SessionFactoryBuilderFactory;
import org.hibernate.boot.spi.SessionFactoryBuilderImplementor;
import org.hibernate.boot.spi.SessionFactoryBuilderService;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.annotations.NamedEntityGraphDefinition;
import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.engine.spi.FilterDefinition;
import org.hibernate.engine.spi.SessionFactoryImplementor;

View File

@ -15,8 +15,8 @@ import java.util.Set;
import org.hibernate.CacheMode;
import org.hibernate.FlushMode;
import org.hibernate.MappingException;
import org.hibernate.boot.model.internal.QueryHintDefinition;
import org.hibernate.boot.query.NamedProcedureCallDefinition;
import org.hibernate.cfg.annotations.QueryHintDefinition;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.procedure.internal.NamedCallableQueryMementoImpl;

View File

@ -37,7 +37,6 @@ import org.hibernate.cache.internal.StandardTimestampsCacheFactory;
import org.hibernate.cache.spi.RegionFactory;
import org.hibernate.cache.spi.TimestampsCacheFactory;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.BaselineSessionEventsListenerBuilder;
import org.hibernate.context.spi.CurrentTenantIdentifierResolver;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.config.internal.ConfigurationServiceImpl;
@ -46,6 +45,7 @@ import org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider;
import org.hibernate.engine.jdbc.env.spi.ExtractedDatabaseMetaData;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.id.uuid.LocalObjectUuidHelper;
import org.hibernate.internal.BaselineSessionEventsListenerBuilder;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.EmptyInterceptor;
import org.hibernate.internal.util.NullnessHelper;
@ -57,9 +57,9 @@ import org.hibernate.jpa.spi.MutableJpaCompliance;
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;
@ -71,9 +71,9 @@ import org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder;
import org.hibernate.service.spi.ServiceRegistryImplementor;
import org.hibernate.stat.Statistics;
import org.hibernate.type.FormatMapper;
import org.hibernate.type.jaxb.JaxbXmlFormatMapper;
import org.hibernate.type.jackson.JacksonIntegration;
import org.hibernate.type.jakartajson.JakartaJsonIntegration;
import org.hibernate.type.jaxb.JaxbXmlFormatMapper;
import static org.hibernate.cfg.AvailableSettings.ALLOW_JTA_TRANSACTION_ACCESS;
import static org.hibernate.cfg.AvailableSettings.ALLOW_REFRESH_DETACHED_ENTITY;

View File

@ -7,6 +7,7 @@
package org.hibernate.boot.model;
import org.hibernate.query.sqm.function.SqmFunctionRegistry;
import org.hibernate.service.Service;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.type.spi.TypeConfiguration;
@ -16,9 +17,19 @@ import org.hibernate.type.spi.TypeConfiguration;
* @author Christian Beikov
*/
public interface FunctionContributions {
TypeConfiguration getTypeConfiguration();
/**
* The registry into which the contributions should be made.
*/
SqmFunctionRegistry getFunctionRegistry();
/**
* Access to type information
*/
TypeConfiguration getTypeConfiguration();
/**
* Access to {@linkplain Service services}
*/
ServiceRegistry getServiceRegistry();
}

View File

@ -14,9 +14,13 @@
package org.hibernate.boot.model;
import org.hibernate.query.sqm.function.SqmFunctionRegistry;
/**
* Contract for contributing functions
*
* @see SqmFunctionRegistry
*
* @author Karel Maesen
*/
public interface FunctionContributor {

View File

@ -13,21 +13,24 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Index;
import jakarta.persistence.SequenceGenerator;
import jakarta.persistence.TableGenerator;
import jakarta.persistence.UniqueConstraint;
import org.hibernate.AssertionFailure;
import org.hibernate.Internal;
import org.hibernate.id.IdentifierGenerator;
import org.hibernate.internal.util.collections.CollectionHelper;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Index;
import jakarta.persistence.SequenceGenerator;
import jakarta.persistence.TableGenerator;
import jakarta.persistence.UniqueConstraint;
import static java.util.Collections.emptyMap;
import static java.util.Collections.unmodifiableMap;
/**
* Identifier generator definition, should be immutable.
* Models the definition of an {@linkplain org.hibernate.id.IdentityGenerator identifier generator}
*
* @implSpec Should be immutable.
*
* @author Steve Ebersole
* @author Emmanuel Bernard

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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
*/

View File

@ -8,9 +8,10 @@ package org.hibernate.boot.model;
/**
* An enumeration of truth values.
* <p>
* 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
*/

View File

@ -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) {

View File

@ -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 );

View File

@ -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;

View File

@ -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

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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." ) ) {

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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;

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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;

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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;

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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() );

View File

@ -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<AnnotatedColumn> columns = new ArrayList<>();
private Table table;
private PropertyHolder propertyHolder;
// this is really a .-separated property path
private String propertyName;
private Map<String, Join> joins = Collections.emptyMap();
private MetadataBuildingContext buildingContext;
public List<AnnotatedColumn> 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<String, Join> 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"
);
}
}
}
}
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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,7 +50,6 @@ public class AnnotatedDiscriminatorColumn extends AnnotatedColumn {
final AnnotatedColumns parent = new AnnotatedColumns();
parent.setBuildingContext( context );
final AnnotatedDiscriminatorColumn column = new AnnotatedDiscriminatorColumn();
// column.setContext( context );
if ( discriminatorFormula != null ) {
column.setImplicit( false );
column.setFormula( discriminatorFormula.value() );

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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;

View File

@ -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.
* <p>
* 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<AnnotatedJoinColumn> 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<String, Join> 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<String, Join> 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<String, Join> 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<String, Join> 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<String, Join> 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<AnnotatedJoinColumn> 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<Selectable> 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();
}
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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;

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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;

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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;
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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 {

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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() );
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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);
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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;

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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;

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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;
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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;

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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 <join> in a second pass" );
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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<String, PersistentClass> persistentClasses)
throws MappingException {
if ( LOG.isDebugEnabled() ) {

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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;

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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<String,AttributeConversionInfo> 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;
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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;

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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.boot.spi.SecondPass;
import org.hibernate.mapping.JoinedSubclass;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.RootClass;
@ -26,6 +27,7 @@ public class CreateKeySecondPass implements SecondPass {
this.joinedSubClass = joinedSubClass;
}
@Override
public void doSecondPass(Map<String, PersistentClass> persistentClasses) {
if ( rootClass != null ) {
rootClass.createPrimaryKey();

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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,32 +1424,39 @@ 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;
}
}
}
private static String resolveCacheConcurrencyStrategy(CacheConcurrencyStrategy strategy) {
final org.hibernate.cache.spi.access.AccessType accessType = strategy.toAccessType();
@ -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() {

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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;
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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;

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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)}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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.Map;
@ -13,13 +13,8 @@ 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.boot.spi.PropertyData;
import org.hibernate.boot.spi.SecondPass;
import org.hibernate.mapping.BasicValue;
import org.hibernate.mapping.Collection;
import org.hibernate.mapping.IdentifierBag;
@ -31,7 +26,7 @@ import org.hibernate.usertype.UserCollectionType;
import jakarta.persistence.Column;
import static org.hibernate.cfg.BinderHelper.makeIdGenerator;
import static org.hibernate.boot.model.internal.BinderHelper.makeIdGenerator;
/**
* A {@link CollectionBinder} for {@link org.hibernate.collection.spi.PersistentIdentifierBag id bags}
@ -47,6 +42,7 @@ public class IdBagBinder extends BagBinder {
super( customTypeBeanResolver, buildingContext );
}
@Override
protected Collection createCollection(PersistentClass owner) {
return new IdentifierBag( getCustomTypeBeanResolver(), owner, getBuildingContext() );
}
@ -57,7 +53,6 @@ public class IdBagBinder extends BagBinder {
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" );
}
@ -107,13 +102,16 @@ public class IdBagBinder extends BagBinder {
final String namedGenerator = collectionIdAnn.generator();
switch (namedGenerator) {
case "identity":
case "identity": {
throw new MappingException("IDENTITY generation not supported for CollectionId");
case "assigned":
}
case "assigned": {
throw new MappingException("Assigned generation not supported for CollectionId");
case "native":
}
case "native": {
throw new MappingException("Native generation not supported for CollectionId");
}
}
final String generatorName;
final String generatorType;

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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;
/**

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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;

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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.
*

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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;
/**

View File

@ -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<Class, String> annotationToXml;
private static final Map<Class<? extends Annotation>, 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<Annotation> 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<String, Convert> 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 <T> void checkForOrphanProperties(List<T> elements, Set<String> properties,
private <T> void checkForOrphanProperties(
List<T> elements,
Set<String> properties,
Function<? super T, String> nameGetter) {
for ( T element : elements ) {
checkForOrphanProperties( element, properties, nameGetter );
}
}
private <T> void checkForOrphanProperties(T element, Set<String> properties,
private <T> void checkForOrphanProperties(
T element,
Set<String> 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<Annotation> annotationList, Annotation annotation) {
private void addIfNotNull(List<Annotation> 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<Annotation> annotationList, AssociationAttribute associationAttribute,
private void getJoinTable(
List<Annotation> 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<Annotation> annotationList,
private void afterGetAssociation(
Class<? extends Annotation> annotationType,
List<Annotation> 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<JaxbAttributeOverride> 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<Column> 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,7 +1831,9 @@ 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<JaxbAssociationOverride> elements, XMLContext.Default defaults,
private AssociationOverrides getAssociationOverrides(
List<JaxbAssociationOverride> elements,
XMLContext.Default defaults,
boolean mergeWithAnnotations) {
List<AssociationOverride> attributes = buildAssociationOverrides( elements, defaults );
if ( mergeWithAnnotations && defaults.canUseJavaAnnotations() ) {
@ -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<AssociationOverride> overrides) {
@ -1924,7 +1921,9 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
* In some contexts (such as an association mapping) merging with
* annotations is never allowed.
*/
private AttributeOverrides getAttributeOverrides(List<JaxbAttributeOverride> elements, XMLContext.Default defaults,
private AttributeOverrides getAttributeOverrides(
List<JaxbAttributeOverride> elements,
XMLContext.Default defaults,
boolean mergeWithAnnotations) {
List<AttributeOverride> attributes = buildAttributeOverrides( elements, "attribute-override" );
return mergeAttributeOverrides( defaults, attributes, mergeWithAnnotations );
@ -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,7 +2049,9 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
);
}
private Annotation getMarkerAnnotation(Class<? extends Annotation> clazz, JaxbEmptyType element,
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<NamedStoredProcedureQuery> 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<Class<?>> returnClasses = new ArrayList<>();
final List<Class<?>> 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<ColumnResult> 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 );
@ -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,7 +3083,8 @@ public class JPAXMLOverriddenAnnotationReader implements AnnotationReader {
annotation.setValue( "indexes", indexes );
}
private static void buildUniqueConstraints(AnnotationDescriptor annotation,
private static void buildUniqueConstraints(
AnnotationDescriptor annotation,
List<JaxbUniqueConstraint> elements) {
UniqueConstraint[] uniqueConstraints = new UniqueConstraint[ elements.size() ];
int i = 0;

View File

@ -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;

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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<String, PersistentClass> persistentClasses) throws MappingException {
TableBinder.bindForeignKey( entity.getSuperclass(), entity, columns, value, false, buildingContext );
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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<String, PersistentClass> persistentClasses)
throws MappingException {
public void secondPass(Map<String, PersistentClass> persistentClasses) throws MappingException {
bindStarToManySecondPass( persistentClasses );
bindIndex();
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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;

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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;
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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;

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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;
/**

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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;

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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).

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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<String, PersistentClass> 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<String, PersistentClass> 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();

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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;

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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;

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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;

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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;
/**

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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<XProperty> persistentAttributes;
PropertyContainer(XClass clazz, XClass entityAtStake, AccessType defaultClassLevelAccessType) {
public PropertyContainer(XClass clazz, XClass entityAtStake, AccessType defaultClassLevelAccessType) {
this.xClass = clazz;
this.entityAtStake = entityAtStake;

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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
*

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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;

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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;
}

View File

@ -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;

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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.

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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;

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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;

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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
*

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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

View File

@ -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<String, PersistentClass> persistentClasses) throws MappingException {
entityBinder.finalSecondaryTableFromAnnotationBinding( propertyHolder );
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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<String, PersistentClass> persistentClasses) throws MappingException {
entityBinder.finalSecondaryTableBinding( propertyHolder );
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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<String, PersistentClass> persistentClasses) throws MappingException {
binder.fillSimpleValue();
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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;

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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<String, PersistentClass> persistentClasses) throws MappingException {
value.createForeignKey();
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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;

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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;

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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<String, PersistentClass> persistentClasses) throws MappingException {
if ( value instanceof ManyToOne ) {
//TODO: move this validation logic to a separate ManyToOnSecondPass

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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;
/**

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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<String, PersistentClass> 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)
);
}
}

View File

@ -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 <http://www.gnu.org/licenses/lgpl-2.1.html>.
* 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;
import org.hibernate.internal.util.StringHelper;
/**
@ -17,40 +20,48 @@ 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 );
}
@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();
}
}

View File

@ -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();
}
}
}

View File

@ -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.
* <p/>
* 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;

View File

@ -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;

View File

@ -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

View File

@ -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;

Some files were not shown because too many files have changed in this diff Show More