HHH-15837 - Cleanup the tuple package

This commit is contained in:
Steve Ebersole 2022-12-08 07:01:53 -06:00
parent 33c00d78c3
commit 78c3edf695
28 changed files with 134 additions and 165 deletions

View File

@ -23,7 +23,8 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
* of a deprecation lifecycle. * of a deprecation lifecycle.
* *
* @apiNote Intended for use at development-time for developers to better understand * @apiNote Intended for use at development-time for developers to better understand
* the lifecycle of the annotated element. * the lifecycle of the annotated element. Also, useful for "deprecating" a package
* as the Java compiler does not like `@Deprecated` on packages.
* *
* @see Deprecated#forRemoval() * @see Deprecated#forRemoval()
* *

View File

@ -2,9 +2,9 @@
* Hibernate, Relational Persistence for Idiomatic Java * Hibernate, Relational Persistence for Idiomatic Java
* *
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. * 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.tuple.entity; package org.hibernate.bytecode.internal;
import org.hibernate.bytecode.enhance.spi.interceptor.BytecodeLazyAttributeInterceptor; import org.hibernate.bytecode.enhance.spi.interceptor.BytecodeLazyAttributeInterceptor;
import org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeLoadingInterceptor; import org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeLoadingInterceptor;
@ -17,6 +17,9 @@ import org.hibernate.engine.spi.PersistentAttributeInterceptor;
import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor;
/** /**
* BytecodeEnhancementMetadata implementation for non-POJO models, mainly
* {@link org.hibernate.metamodel.RepresentationMode#MAP}
*
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public class BytecodeEnhancementMetadataNonPojoImpl implements BytecodeEnhancementMetadata { public class BytecodeEnhancementMetadataNonPojoImpl implements BytecodeEnhancementMetadata {

View File

@ -2,9 +2,9 @@
* Hibernate, Relational Persistence for Idiomatic Java * Hibernate, Relational Persistence for Idiomatic Java
* *
* License: GNU Lesser General Public License (LGPL), version 2.1 or later. * 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.tuple.entity; package org.hibernate.bytecode.internal;
import java.util.Set; import java.util.Set;
@ -32,6 +32,8 @@ import static org.hibernate.engine.internal.ManagedTypeHelper.isPersistentAttrib
import static org.hibernate.engine.internal.ManagedTypeHelper.processIfSelfDirtinessTracker; import static org.hibernate.engine.internal.ManagedTypeHelper.processIfSelfDirtinessTracker;
/** /**
* BytecodeEnhancementMetadata implementation for {@link org.hibernate.metamodel.RepresentationMode#POJO POJO} models
*
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public final class BytecodeEnhancementMetadataPojoImpl implements BytecodeEnhancementMetadata { public final class BytecodeEnhancementMetadataPojoImpl implements BytecodeEnhancementMetadata {

View File

@ -68,6 +68,7 @@ import org.hibernate.classic.Lifecycle;
import org.hibernate.collection.spi.PersistentCollection; import org.hibernate.collection.spi.PersistentCollection;
import org.hibernate.dialect.Dialect; import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.lock.LockingStrategy; import org.hibernate.dialect.lock.LockingStrategy;
import org.hibernate.engine.FetchStyle;
import org.hibernate.engine.FetchTiming; import org.hibernate.engine.FetchTiming;
import org.hibernate.engine.OptimisticLockStyle; import org.hibernate.engine.OptimisticLockStyle;
import org.hibernate.engine.internal.CacheHelper; import org.hibernate.engine.internal.CacheHelper;
@ -95,6 +96,8 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.event.spi.EventSource; import org.hibernate.event.spi.EventSource;
import org.hibernate.event.spi.LoadEvent; import org.hibernate.event.spi.LoadEvent;
import org.hibernate.generator.EventType; import org.hibernate.generator.EventType;
import org.hibernate.generator.Generator;
import org.hibernate.generator.InDatabaseGenerator;
import org.hibernate.generator.InMemoryGenerator; import org.hibernate.generator.InMemoryGenerator;
import org.hibernate.generator.internal.VersionGeneration; import org.hibernate.generator.internal.VersionGeneration;
import org.hibernate.id.Assigned; import org.hibernate.id.Assigned;
@ -193,7 +196,6 @@ import org.hibernate.metamodel.spi.EntityInstantiator;
import org.hibernate.metamodel.spi.EntityRepresentationStrategy; import org.hibernate.metamodel.spi.EntityRepresentationStrategy;
import org.hibernate.metamodel.spi.RuntimeModelCreationContext; import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.collection.QueryableCollection;
import org.hibernate.persister.entity.mutation.DeleteCoordinator; import org.hibernate.persister.entity.mutation.DeleteCoordinator;
import org.hibernate.persister.entity.mutation.EntityMutationTarget; import org.hibernate.persister.entity.mutation.EntityMutationTarget;
import org.hibernate.persister.entity.mutation.EntityTableMapping; import org.hibernate.persister.entity.mutation.EntityTableMapping;
@ -262,10 +264,7 @@ import org.hibernate.sql.results.graph.embeddable.EmbeddableResultGraphNode;
import org.hibernate.sql.results.graph.entity.internal.EntityResultImpl; import org.hibernate.sql.results.graph.entity.internal.EntityResultImpl;
import org.hibernate.sql.results.internal.SqlSelectionImpl; import org.hibernate.sql.results.internal.SqlSelectionImpl;
import org.hibernate.stat.spi.StatisticsImplementor; import org.hibernate.stat.spi.StatisticsImplementor;
import org.hibernate.generator.Generator;
import org.hibernate.generator.InDatabaseGenerator;
import org.hibernate.tuple.NonIdentifierAttribute; import org.hibernate.tuple.NonIdentifierAttribute;
import org.hibernate.tuple.entity.EntityBasedAssociationAttribute;
import org.hibernate.tuple.entity.EntityMetamodel; import org.hibernate.tuple.entity.EntityMetamodel;
import org.hibernate.type.AnyType; import org.hibernate.type.AnyType;
import org.hibernate.type.AssociationType; import org.hibernate.type.AssociationType;
@ -3484,23 +3483,21 @@ public abstract class AbstractEntityPersister
if ( filterHelper.isAffectedBy( loadQueryInfluencers.getEnabledFilters() ) ) { if ( filterHelper.isAffectedBy( loadQueryInfluencers.getEnabledFilters() ) ) {
return true; return true;
} }
// we still need to verify collection fields to be eagerly loaded by 'join'
for ( NonIdentifierAttribute attribute : entityMetamodel.getProperties() ) { // we still need to verify collection fields to be eagerly loaded by join
if ( attribute instanceof EntityBasedAssociationAttribute ) { final List<AttributeMapping> attributeMappings = getAttributeMappings();
final AssociationType associationType = ( (EntityBasedAssociationAttribute) attribute ).getType(); for ( int i = 0; i < attributeMappings.size(); i++ ) {
if ( associationType instanceof CollectionType ) { final AttributeMapping attributeMapping = attributeMappings.get( i );
final Joinable joinable = associationType.getAssociatedJoinable( getFactory() ); if ( attributeMapping instanceof PluralAttributeMapping ) {
if ( joinable.isCollection() ) { final PluralAttributeMapping pluralAttributeMapping = (PluralAttributeMapping) attributeMapping;
final QueryableCollection collectionPersister = (QueryableCollection) joinable; if ( pluralAttributeMapping.getMappedFetchOptions().getTiming() == FetchTiming.IMMEDIATE
if ( collectionPersister.getFetchMode() == FetchMode.JOIN && pluralAttributeMapping.getMappedFetchOptions().getStyle() == FetchStyle.JOIN
&& collectionPersister.isAffectedByEnabledFilters( loadQueryInfluencers ) ) { && pluralAttributeMapping.getCollectionDescriptor().isAffectedByEnabledFilters( loadQueryInfluencers ) ) {
return true; return true;
} }
} }
} }
} }
}
}
return false; return false;
} }
@ -3583,7 +3580,8 @@ public abstract class AbstractEntityPersister
private void logDirtyProperties(int[] props) { private void logDirtyProperties(int[] props) {
if ( LOG.isTraceEnabled() ) { if ( LOG.isTraceEnabled() ) {
for ( int prop : props ) { for ( int prop : props ) {
String propertyName = entityMetamodel.getProperties()[prop].getName(); final AttributeMapping attributeMapping = getAttributeMapping( prop );
final String propertyName = attributeMapping.getAttributeName();
LOG.trace(StringHelper.qualify(getEntityName(), propertyName) + " is dirty"); LOG.trace(StringHelper.qualify(getEntityName(), propertyName) + " is dirty");
} }
} }

View File

@ -9,8 +9,9 @@ package org.hibernate.tuple;
import org.hibernate.type.Type; import org.hibernate.type.Type;
/** /**
* @author Steve Ebersole * @deprecated No direct replacement.
*/ */
@Deprecated(forRemoval = true)
public abstract class AbstractAttribute implements Attribute { public abstract class AbstractAttribute implements Attribute {
private final String attributeName; private final String attributeName;
private final Type attributeType; private final Type attributeType;

View File

@ -13,8 +13,9 @@ import org.hibernate.persister.walking.spi.AttributeSource;
import org.hibernate.type.Type; import org.hibernate.type.Type;
/** /**
* @author Steve Ebersole * @deprecated No direct replacement.
*/ */
@Deprecated(forRemoval = true)
public abstract class AbstractNonIdentifierAttribute extends AbstractAttribute implements NonIdentifierAttribute { public abstract class AbstractNonIdentifierAttribute extends AbstractAttribute implements NonIdentifierAttribute {
private final AttributeSource source; private final AttributeSource source;
private final SessionFactoryImplementor sessionFactory; private final SessionFactoryImplementor sessionFactory;

View File

@ -9,10 +9,9 @@ package org.hibernate.tuple;
import org.hibernate.type.Type; import org.hibernate.type.Type;
/** /**
* Contract for attributes * @deprecated Replaced by {@link org.hibernate.metamodel.mapping.AttributeMapping}
*
* @author Steve Ebersole
*/ */
@Deprecated(forRemoval = true)
public interface Attribute { public interface Attribute {
String getName(); String getName();
Type getType(); Type getType();

View File

@ -10,8 +10,10 @@ import org.hibernate.FetchMode;
import org.hibernate.engine.spi.CascadeStyle; import org.hibernate.engine.spi.CascadeStyle;
/** /**
* @author Steve Ebersole * @deprecated No direct replacement, though see {@link org.hibernate.metamodel.mapping.AttributeMapping}
* and {@link org.hibernate.metamodel.mapping.AttributeMetadata}
*/ */
@Deprecated(forRemoval = true)
public class BaselineAttributeInformation { public class BaselineAttributeInformation {
private final boolean lazy; private final boolean lazy;
private final boolean insertable; private final boolean insertable;

View File

@ -10,8 +10,9 @@ import org.hibernate.generator.Generator;
import org.hibernate.id.IdentifierGenerator; import org.hibernate.id.IdentifierGenerator;
/** /**
* @author Steve Ebersole * @deprecated No direct replacement; see {@link org.hibernate.metamodel.mapping.EntityIdentifierMapping}
*/ */
@Deprecated(forRemoval = true)
public interface IdentifierAttribute extends Attribute { public interface IdentifierAttribute extends Attribute {
boolean isVirtual(); boolean isVirtual();

View File

@ -11,11 +11,9 @@ import org.hibernate.id.IdentifierGenerator;
import org.hibernate.type.Type; import org.hibernate.type.Type;
/** /**
* Represents a defined entity identifier property within the Hibernate * @deprecated No direct replacement; see {@link org.hibernate.metamodel.mapping.EntityIdentifierMapping}
* runtime-metamodel.
*
* @author Steve Ebersole
*/ */
@Deprecated(forRemoval = true)
public class IdentifierProperty extends AbstractAttribute implements IdentifierAttribute { public class IdentifierProperty extends AbstractAttribute implements IdentifierAttribute {
private final boolean virtual; private final boolean virtual;

View File

@ -10,8 +10,9 @@ import org.hibernate.FetchMode;
import org.hibernate.engine.spi.CascadeStyle; import org.hibernate.engine.spi.CascadeStyle;
/** /**
* @author Steve Ebersole * @deprecated No direct replacement
*/ */
@Deprecated(forRemoval = true)
public interface NonIdentifierAttribute extends Attribute { public interface NonIdentifierAttribute extends Attribute {
boolean isLazy(); boolean isLazy();

View File

@ -25,11 +25,9 @@ import org.hibernate.type.CompositeType;
import org.hibernate.type.Type; import org.hibernate.type.Type;
/** /**
* Responsible for generation of runtime metamodel {@link Property} representations. * @deprecated No direct replacement
* Makes distinction between identifier, version, and other (standard) properties.
*
* @author Steve Ebersole
*/ */
@Deprecated(forRemoval = true)
public final class PropertyFactory { public final class PropertyFactory {
private PropertyFactory() { private PropertyFactory() {
} }
@ -240,37 +238,4 @@ public final class PropertyFactory {
} }
} }
/**
* @deprecated See mainly {@link #buildEntityBasedAttribute}
*/
@Deprecated
public static StandardProperty buildStandardProperty(Property property, boolean lazyAvailable) {
final Type type = property.getValue().getType();
// we need to dirty check collections, since they can cause an owner
// version number increment
// we need to dirty check many-to-ones with not-found="ignore" in order
// to update the cache (not the database), since in this case a null
// entity reference can lose information
boolean alwaysDirtyCheck = type.isAssociationType()
&& ( (AssociationType) type ).isAlwaysDirtyChecked();
return new StandardProperty(
property.getName(),
type,
// only called for embeddable sub-attributes which are never (yet) lazy
//lazyAvailable && property.isLazy(),
false,
property.isInsertable(),
property.isUpdateable(),
property.isOptional(),
alwaysDirtyCheck || property.isUpdateable(),
property.isOptimisticLocked(),
property.getCascadeStyle(),
property.getValue().getFetchMode()
);
}
} }

View File

@ -11,13 +11,9 @@ import org.hibernate.engine.spi.CascadeStyle;
import org.hibernate.type.Type; import org.hibernate.type.Type;
/** /**
* Represents a non-identifier property within the Hibernate runtime-metamodel. * @deprecated Replaced by {@link org.hibernate.metamodel.mapping.AttributeMapping}
*
* @author Steve Ebersole
*
* @deprecated Use one of the {@link Attribute}-based impls instead.
*/ */
@Deprecated @Deprecated(forRemoval = true)
public class StandardProperty extends AbstractNonIdentifierAttribute implements NonIdentifierAttribute { public class StandardProperty extends AbstractNonIdentifierAttribute implements NonIdentifierAttribute {
/** /**

View File

@ -14,10 +14,9 @@ import org.hibernate.tuple.BaselineAttributeInformation;
import org.hibernate.type.CompositeType; import org.hibernate.type.CompositeType;
/** /**
* A base class for a composite, non-identifier attribute. * @deprecated No direct replacement
*
* @author Steve Ebersole
*/ */
@Deprecated(forRemoval = true)
public abstract class AbstractCompositionAttribute public abstract class AbstractCompositionAttribute
extends AbstractNonIdentifierAttribute { extends AbstractNonIdentifierAttribute {

View File

@ -13,8 +13,9 @@ import org.hibernate.tuple.BaselineAttributeInformation;
import org.hibernate.type.Type; import org.hibernate.type.Type;
/** /**
* @author Steve Ebersole * @deprecated No direct replacement
*/ */
@Deprecated(forRemoval = true)
public abstract class AbstractEntityBasedAttribute extends AbstractNonIdentifierAttribute { public abstract class AbstractEntityBasedAttribute extends AbstractNonIdentifierAttribute {
protected AbstractEntityBasedAttribute( protected AbstractEntityBasedAttribute(
EntityPersister source, EntityPersister source,

View File

@ -12,8 +12,9 @@ import org.hibernate.tuple.BaselineAttributeInformation;
import org.hibernate.type.AssociationType; import org.hibernate.type.AssociationType;
/** /**
* @author Steve Ebersole * @deprecated No direct replacement
*/ */
@Deprecated(forRemoval = true)
public class EntityBasedAssociationAttribute public class EntityBasedAssociationAttribute
extends AbstractEntityBasedAttribute { extends AbstractEntityBasedAttribute {

View File

@ -12,8 +12,9 @@ import org.hibernate.tuple.BaselineAttributeInformation;
import org.hibernate.type.Type; import org.hibernate.type.Type;
/** /**
* @author Steve Ebersole * @deprecated No direct replacement
*/ */
@Deprecated(forRemoval = true)
public class EntityBasedBasicAttribute extends AbstractEntityBasedAttribute { public class EntityBasedBasicAttribute extends AbstractEntityBasedAttribute {
public EntityBasedBasicAttribute( public EntityBasedBasicAttribute(
EntityPersister source, EntityPersister source,

View File

@ -13,8 +13,9 @@ import org.hibernate.tuple.component.AbstractCompositionAttribute;
import org.hibernate.type.CompositeType; import org.hibernate.type.CompositeType;
/** /**
* @author Steve Ebersole * @deprecated No direct replacement
*/ */
@Deprecated(forRemoval = true)
public class EntityBasedCompositionAttribute public class EntityBasedCompositionAttribute
extends AbstractCompositionAttribute { extends AbstractCompositionAttribute {

View File

@ -22,6 +22,8 @@ import org.hibernate.MappingException;
import org.hibernate.boot.spi.MetadataImplementor; import org.hibernate.boot.spi.MetadataImplementor;
import org.hibernate.boot.spi.SessionFactoryOptions; import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.bytecode.enhance.spi.interceptor.EnhancementHelper; import org.hibernate.bytecode.enhance.spi.interceptor.EnhancementHelper;
import org.hibernate.bytecode.internal.BytecodeEnhancementMetadataNonPojoImpl;
import org.hibernate.bytecode.internal.BytecodeEnhancementMetadataPojoImpl;
import org.hibernate.bytecode.spi.BytecodeEnhancementMetadata; import org.hibernate.bytecode.spi.BytecodeEnhancementMetadata;
import org.hibernate.cfg.NotYetImplementedException; import org.hibernate.cfg.NotYetImplementedException;
import org.hibernate.dialect.Dialect; import org.hibernate.dialect.Dialect;
@ -31,6 +33,9 @@ import org.hibernate.engine.spi.CascadeStyles;
import org.hibernate.engine.spi.CascadingActions; import org.hibernate.engine.spi.CascadingActions;
import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.generator.EventType; import org.hibernate.generator.EventType;
import org.hibernate.generator.Generator;
import org.hibernate.generator.InDatabaseGenerator;
import org.hibernate.generator.InMemoryGenerator;
import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.ReflectHelper; import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.internal.util.collections.ArrayHelper; import org.hibernate.internal.util.collections.ArrayHelper;
@ -44,10 +49,7 @@ import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.spi.RuntimeModelCreationContext; import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.spi.PersisterCreationContext; import org.hibernate.persister.spi.PersisterCreationContext;
import org.hibernate.generator.Generator;
import org.hibernate.tuple.IdentifierProperty; import org.hibernate.tuple.IdentifierProperty;
import org.hibernate.generator.InDatabaseGenerator;
import org.hibernate.generator.InMemoryGenerator;
import org.hibernate.tuple.NonIdentifierAttribute; import org.hibernate.tuple.NonIdentifierAttribute;
import org.hibernate.tuple.PropertyFactory; import org.hibernate.tuple.PropertyFactory;
import org.hibernate.type.AssociationType; import org.hibernate.type.AssociationType;
@ -803,6 +805,9 @@ public class EntityMetamodel implements Serializable {
return propertyIndexes.get( propertyName ); return propertyIndexes.get( propertyName );
} }
public boolean hasCollections() { public boolean hasCollections() {
return hasCollections; return hasCollections;
} }

View File

@ -7,17 +7,15 @@
package org.hibernate.tuple.entity; package org.hibernate.tuple.entity;
import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.VersionValue;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.tuple.AbstractNonIdentifierAttribute; import org.hibernate.tuple.AbstractNonIdentifierAttribute;
import org.hibernate.tuple.BaselineAttributeInformation; import org.hibernate.tuple.BaselineAttributeInformation;
import org.hibernate.type.Type; import org.hibernate.type.Type;
/** /**
* Represents a version property within the Hibernate runtime-metamodel. * @deprecated Replaced by {@link org.hibernate.metamodel.mapping.EntityVersionMapping}
*
* @author Steve Ebersole
*/ */
@Deprecated(forRemoval = true)
public class VersionProperty extends AbstractNonIdentifierAttribute { public class VersionProperty extends AbstractNonIdentifierAttribute {
/** /**
* Constructs VersionProperty instances. * Constructs VersionProperty instances.

View File

@ -0,0 +1,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.
*/
/**
* Most contracts here have been replaced by Hibernate's
* {@linkplain org.hibernate.metamodel.mapping mapping-model}.
*/
@Remove
package org.hibernate.tuple;
import org.hibernate.Remove;

View File

@ -1,22 +0,0 @@
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later.
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
-->
<html>
<head></head>
<body>
<p>
This package defines a runtime metamodel for entities at
the object level and abstracts the differences between
the various entity modes. It is unaware of mappings to
the database.
</p>
<p>
(This package is still undergoing maturation and will change
over the next few months.)
</p>
</body>
</html>

View File

@ -26,6 +26,7 @@ import org.hibernate.engine.spi.CascadeStyle;
import org.hibernate.engine.spi.Mapping; import org.hibernate.engine.spi.Mapping;
import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.generator.Generator;
import org.hibernate.internal.util.StringHelper; import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.ArrayHelper; import org.hibernate.internal.util.collections.ArrayHelper;
import org.hibernate.mapping.Component; import org.hibernate.mapping.Component;
@ -36,9 +37,6 @@ import org.hibernate.metamodel.spi.EmbeddableInstantiator;
import org.hibernate.property.access.spi.PropertyAccess; import org.hibernate.property.access.spi.PropertyAccess;
import org.hibernate.query.sqm.SqmExpressible; import org.hibernate.query.sqm.SqmExpressible;
import org.hibernate.resource.beans.spi.ManagedBeanRegistry; import org.hibernate.resource.beans.spi.ManagedBeanRegistry;
import org.hibernate.generator.Generator;
import org.hibernate.tuple.PropertyFactory;
import org.hibernate.tuple.StandardProperty;
import org.hibernate.type.descriptor.jdbc.JdbcType; import org.hibernate.type.descriptor.jdbc.JdbcType;
import org.hibernate.type.spi.CompositeTypeImplementor; import org.hibernate.type.spi.CompositeTypeImplementor;
import org.hibernate.usertype.CompositeUserType; import org.hibernate.usertype.CompositeUserType;
@ -81,30 +79,26 @@ public class ComponentType extends AbstractType implements CompositeTypeImplemen
int i = 0; int i = 0;
for ( Property property : component.getProperties() ) { for ( Property property : component.getProperties() ) {
// todo (6.0) : see if we really need to create these this.propertyNames[i] = property.getName();
final StandardProperty prop = PropertyFactory.buildStandardProperty( property, false ); this.propertyTypes[i] = property.getValue().getType();
this.propertyNames[i] = prop.getName(); this.propertyNullability[i] = property.isOptional();
this.propertyTypes[i] = prop.getType(); this.cascade[i] = property.getCascadeStyle();
this.propertyNullability[i] = prop.isNullable(); this.joinedFetch[i] = property.getValue().getFetchMode();
this.cascade[i] = prop.getCascadeStyle(); if ( !propertyNullability[i] ) {
this.joinedFetch[i] = prop.getFetchMode();
if ( !prop.isNullable() ) {
hasNotNullProperty = true; hasNotNullProperty = true;
} }
i++; i++;
} }
if ( component.getTypeName() != null ) { if ( component.getTypeName() != null ) {
//noinspection unchecked final ManagedBeanRegistry beanRegistry = buildingContext.getBootstrapContext()
this.compositeUserType = (CompositeUserType<Object>) buildingContext.getBootstrapContext()
.getServiceRegistry() .getServiceRegistry()
.getService( ManagedBeanRegistry.class ) .getService( ManagedBeanRegistry.class );
.getBean( final Class<Object> customTypeClass = buildingContext.getBootstrapContext()
buildingContext.getBootstrapContext()
.getClassLoaderAccess() .getClassLoaderAccess()
.classForName( component.getTypeName() ) .classForName( component.getTypeName() );
) //noinspection unchecked
.getBeanInstance(); this.compositeUserType = (CompositeUserType<Object>) beanRegistry.getBean( customTypeClass ).getBeanInstance();
} }
else { else {
this.compositeUserType = null; this.compositeUserType = null;

View File

@ -8,21 +8,22 @@ package org.hibernate.orm.test.annotations.lob;
import java.util.Arrays; import java.util.Arrays;
import org.junit.Test;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.dialect.CockroachDialect;
import org.hibernate.metamodel.mapping.AttributeMapping;
import org.hibernate.metamodel.mapping.BasicValuedModelPart;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.type.descriptor.java.PrimitiveByteArrayJavaType;
import org.hibernate.type.descriptor.jdbc.BlobJdbcType;
import org.hibernate.testing.DialectChecks; import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.RequiresDialectFeature; import org.hibernate.testing.RequiresDialectFeature;
import org.hibernate.testing.SkipForDialect; import org.hibernate.testing.SkipForDialect;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
import org.hibernate.dialect.CockroachDialect;
import org.hibernate.type.BasicType;
import org.hibernate.type.descriptor.java.PrimitiveByteArrayJavaType;
import org.hibernate.type.descriptor.jdbc.BlobJdbcType;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
/** /**
@ -38,10 +39,14 @@ public class MaterializedBlobTest extends BaseCoreFunctionalTestCase {
@Test @Test
@SkipForDialect(value = CockroachDialect.class, comment = "Blob in CockroachDB is same as a varbinary, to assertions will fail") @SkipForDialect(value = CockroachDialect.class, comment = "Blob in CockroachDB is same as a varbinary, to assertions will fail")
public void testTypeSelection() { public void testTypeSelection() {
int index = sessionFactory().getRuntimeMetamodels().getMappingMetamodel().getEntityDescriptor(MaterializedBlobEntity.class.getName()).getEntityMetamodel().getPropertyIndex( "theBytes" ); final EntityPersister entityDescriptor = sessionFactory().getRuntimeMetamodels()
BasicType<?> type = (BasicType<?>) sessionFactory().getRuntimeMetamodels().getMappingMetamodel().getEntityDescriptor(MaterializedBlobEntity.class.getName()).getEntityMetamodel().getProperties()[index].getType(); .getMappingMetamodel()
assertTrue( type.getJavaTypeDescriptor() instanceof PrimitiveByteArrayJavaType ); .getEntityDescriptor( MaterializedBlobEntity.class.getName() );
assertTrue( type.getJdbcType() instanceof BlobJdbcType ); final AttributeMapping theBytesAttr = entityDescriptor.findAttributeMapping( "theBytes" );
assertThat( theBytesAttr ).isInstanceOf( BasicValuedModelPart.class );
final JdbcMapping mapping = ( (BasicValuedModelPart) theBytesAttr ).getJdbcMapping();
assertTrue( mapping.getJavaTypeDescriptor() instanceof PrimitiveByteArrayJavaType );
assertTrue( mapping.getJdbcType() instanceof BlobJdbcType );
} }
@Test @Test

View File

@ -6,18 +6,13 @@
*/ */
package org.hibernate.orm.test.bytecode.enhancement.lazy; package org.hibernate.orm.test.bytecode.enhancement.lazy;
import jakarta.persistence.Basic;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Configuration;
import org.hibernate.engine.FetchTiming;
import org.hibernate.metamodel.mapping.AttributeMapping;
import org.hibernate.metamodel.mapping.BasicValuedModelPart;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.tuple.NonIdentifierAttribute;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.bytecode.enhancement.BytecodeEnhancerRunner; import org.hibernate.testing.bytecode.enhancement.BytecodeEnhancerRunner;
@ -27,6 +22,14 @@ import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import jakarta.persistence.Basic;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate; import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
@ -76,9 +79,9 @@ public class LazyBasicFieldNotInitializedTest extends BaseCoreFunctionalTestCase
assertTrue( propertyLaziness[0] ); assertTrue( propertyLaziness[0] );
// Make sure NonIdentifierAttribute#isLazy is consistent (HHH-10551) // Make sure NonIdentifierAttribute#isLazy is consistent (HHH-10551)
NonIdentifierAttribute[] properties = entityPersister.getEntityMetamodel().getProperties(); final AttributeMapping theBytesAttr = entityPersister.findAttributeMapping( "description" );
assertEquals( 1, properties.length ); assertThat( theBytesAttr ).isInstanceOf( BasicValuedModelPart.class );
assertTrue( properties[0].isLazy() ); assertThat( theBytesAttr.getMappedFetchOptions().getTiming() ).isEqualTo( FetchTiming.DELAYED );
} ); } );
} }

View File

@ -20,6 +20,7 @@ import org.hibernate.HibernateException;
import org.hibernate.LockMode; import org.hibernate.LockMode;
import org.hibernate.LockOptions; import org.hibernate.LockOptions;
import org.hibernate.MappingException; import org.hibernate.MappingException;
import org.hibernate.bytecode.internal.BytecodeEnhancementMetadataNonPojoImpl;
import org.hibernate.bytecode.spi.BytecodeEnhancementMetadata; import org.hibernate.bytecode.spi.BytecodeEnhancementMetadata;
import org.hibernate.cache.spi.access.CollectionDataAccess; import org.hibernate.cache.spi.access.CollectionDataAccess;
import org.hibernate.cache.spi.access.EntityDataAccess; import org.hibernate.cache.spi.access.EntityDataAccess;
@ -61,17 +62,16 @@ import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.AttributeMappingsList; import org.hibernate.persister.entity.AttributeMappingsList;
import org.hibernate.persister.spi.PersisterClassResolver; import org.hibernate.persister.spi.PersisterClassResolver;
import org.hibernate.persister.spi.PersisterCreationContext; import org.hibernate.persister.spi.PersisterCreationContext;
import org.hibernate.spi.NavigablePath;
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableInsertStrategy; import org.hibernate.query.sqm.mutation.spi.SqmMultiTableInsertStrategy;
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy;
import org.hibernate.spi.NavigablePath;
import org.hibernate.sql.ast.Clause; import org.hibernate.sql.ast.Clause;
import org.hibernate.sql.ast.spi.SqlAstCreationState; import org.hibernate.sql.ast.spi.SqlAstCreationState;
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy;
import org.hibernate.sql.ast.spi.SqlSelection; import org.hibernate.sql.ast.spi.SqlSelection;
import org.hibernate.sql.ast.tree.from.TableGroup; import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.ast.tree.predicate.Predicate; import org.hibernate.sql.ast.tree.predicate.Predicate;
import org.hibernate.sql.results.graph.DomainResult; import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState; import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.tuple.entity.BytecodeEnhancementMetadataNonPojoImpl;
import org.hibernate.tuple.entity.EntityMetamodel; import org.hibernate.tuple.entity.EntityMetamodel;
import org.hibernate.type.BasicType; import org.hibernate.type.BasicType;
import org.hibernate.type.CollectionType; import org.hibernate.type.CollectionType;

View File

@ -19,6 +19,7 @@ import org.hibernate.HibernateException;
import org.hibernate.LockMode; import org.hibernate.LockMode;
import org.hibernate.LockOptions; import org.hibernate.LockOptions;
import org.hibernate.MappingException; import org.hibernate.MappingException;
import org.hibernate.bytecode.internal.BytecodeEnhancementMetadataNonPojoImpl;
import org.hibernate.bytecode.spi.BytecodeEnhancementMetadata; import org.hibernate.bytecode.spi.BytecodeEnhancementMetadata;
import org.hibernate.cache.spi.access.EntityDataAccess; import org.hibernate.cache.spi.access.EntityDataAccess;
import org.hibernate.cache.spi.access.NaturalIdDataAccess; import org.hibernate.cache.spi.access.NaturalIdDataAccess;
@ -59,15 +60,14 @@ import org.hibernate.persister.entity.AttributeMappingsList;
import org.hibernate.persister.internal.PersisterClassResolverInitiator; import org.hibernate.persister.internal.PersisterClassResolverInitiator;
import org.hibernate.persister.spi.PersisterClassResolver; import org.hibernate.persister.spi.PersisterClassResolver;
import org.hibernate.persister.spi.PersisterCreationContext; import org.hibernate.persister.spi.PersisterCreationContext;
import org.hibernate.spi.NavigablePath;
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableInsertStrategy; import org.hibernate.query.sqm.mutation.spi.SqmMultiTableInsertStrategy;
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy; import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy;
import org.hibernate.spi.NavigablePath;
import org.hibernate.sql.ast.Clause; import org.hibernate.sql.ast.Clause;
import org.hibernate.sql.ast.spi.SqlSelection; import org.hibernate.sql.ast.spi.SqlSelection;
import org.hibernate.sql.ast.tree.from.TableGroup; import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.results.graph.DomainResult; import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState; import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.tuple.entity.BytecodeEnhancementMetadataNonPojoImpl;
import org.hibernate.tuple.entity.EntityMetamodel; import org.hibernate.tuple.entity.EntityMetamodel;
import org.hibernate.type.BasicType; import org.hibernate.type.BasicType;
import org.hibernate.type.Type; import org.hibernate.type.Type;

View File

@ -19,6 +19,7 @@ import org.hibernate.HibernateException;
import org.hibernate.LockMode; import org.hibernate.LockMode;
import org.hibernate.LockOptions; import org.hibernate.LockOptions;
import org.hibernate.MappingException; import org.hibernate.MappingException;
import org.hibernate.bytecode.internal.BytecodeEnhancementMetadataNonPojoImpl;
import org.hibernate.bytecode.spi.BytecodeEnhancementMetadata; import org.hibernate.bytecode.spi.BytecodeEnhancementMetadata;
import org.hibernate.cache.spi.access.EntityDataAccess; import org.hibernate.cache.spi.access.EntityDataAccess;
import org.hibernate.cache.spi.access.NaturalIdDataAccess; import org.hibernate.cache.spi.access.NaturalIdDataAccess;
@ -56,15 +57,14 @@ import org.hibernate.persister.entity.AttributeMappingsMap;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.AttributeMappingsList; import org.hibernate.persister.entity.AttributeMappingsList;
import org.hibernate.persister.spi.PersisterCreationContext; import org.hibernate.persister.spi.PersisterCreationContext;
import org.hibernate.spi.NavigablePath;
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableInsertStrategy; import org.hibernate.query.sqm.mutation.spi.SqmMultiTableInsertStrategy;
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy; import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy;
import org.hibernate.spi.NavigablePath;
import org.hibernate.sql.ast.Clause; import org.hibernate.sql.ast.Clause;
import org.hibernate.sql.ast.spi.SqlSelection; import org.hibernate.sql.ast.spi.SqlSelection;
import org.hibernate.sql.ast.tree.from.TableGroup; import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.results.graph.DomainResult; import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState; import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.tuple.entity.BytecodeEnhancementMetadataNonPojoImpl;
import org.hibernate.tuple.entity.EntityMetamodel; import org.hibernate.tuple.entity.EntityMetamodel;
import org.hibernate.type.BasicType; import org.hibernate.type.BasicType;
import org.hibernate.type.Type; import org.hibernate.type.Type;