Migrate internal uses of `MetamodelImplementor` (deprecated) to instead use `MappingMetamodel`

This commit is contained in:
Steve Ebersole 2022-01-25 20:21:39 -06:00
parent f6287cedc2
commit 7b00d3ce78
304 changed files with 1602 additions and 913 deletions

View File

@ -12,9 +12,9 @@ import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
@ -40,10 +40,11 @@ public class BigDecimalMappingTests {
@Test
public void testMappings(SessionFactoryScope scope) {
// first, verify the type selections...
final MappingMetamodel domainModel = scope.getSessionFactory().getDomainModel();
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor(EntityOfBigDecimals.class);
final JdbcTypeRegistry jdbcTypeRegistry = domainModel.getTypeConfiguration()
.getJdbcTypeRegistry();
final MappingMetamodelImplementor mappingMetamodel = scope.getSessionFactory()
.getRuntimeMetamodels()
.getMappingMetamodel();
final EntityPersister entityDescriptor = mappingMetamodel.getEntityDescriptor( EntityOfBigDecimals.class );
final JdbcTypeRegistry jdbcTypeRegistry = mappingMetamodel.getTypeConfiguration().getJdbcTypeRegistry();
{
final BasicAttributeMapping attribute = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("wrapper");

View File

@ -12,9 +12,9 @@ import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
@ -40,10 +40,11 @@ public class BigIntegerMappingTests {
@Test
public void testMappings(SessionFactoryScope scope) {
// first, verify the type selections...
final MappingMetamodel domainModel = scope.getSessionFactory().getDomainModel();
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor(EntityOfBigIntegers.class);
final JdbcTypeRegistry jdbcTypeRegistry = domainModel.getTypeConfiguration()
.getJdbcTypeRegistry();
final MappingMetamodelImplementor mappingMetamodel = scope.getSessionFactory()
.getRuntimeMetamodels()
.getMappingMetamodel();
final EntityPersister entityDescriptor = mappingMetamodel.getEntityDescriptor(EntityOfBigIntegers.class);
final JdbcTypeRegistry jdbcTypeRegistry = mappingMetamodel.getTypeConfiguration().getJdbcTypeRegistry();
{
final BasicAttributeMapping attribute = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("wrapper");

View File

@ -7,10 +7,15 @@
package org.hibernate.userguide.mapping.basic;
import java.sql.Types;
import jakarta.persistence.Basic;
import jakarta.persistence.Convert;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.testing.orm.junit.DomainModel;
@ -18,12 +23,6 @@ import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.junit.jupiter.api.Test;
import jakarta.persistence.Basic;
import jakarta.persistence.Convert;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.isOneOf;
@ -38,8 +37,10 @@ import static org.hamcrest.Matchers.isOneOf;
public class BooleanMappingTests {
@Test
public void verifyMappings(SessionFactoryScope scope) {
final MappingMetamodel domainModel = scope.getSessionFactory().getDomainModel();
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor(EntityOfBooleans.class);
final MappingMetamodelImplementor mappingMetamodel = scope.getSessionFactory()
.getRuntimeMetamodels()
.getMappingMetamodel();
final EntityPersister entityDescriptor = mappingMetamodel.getEntityDescriptor(EntityOfBooleans.class);
{
final BasicAttributeMapping implicit = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("implicit");

View File

@ -15,6 +15,7 @@ import jakarta.persistence.Table;
import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.testing.orm.junit.DomainModel;
@ -35,8 +36,10 @@ public class ByteArrayMappingTests {
@Test
public void verifyMappings(SessionFactoryScope scope) {
final MappingMetamodel domainModel = scope.getSessionFactory().getDomainModel();
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor(EntityOfByteArrays.class);
final MappingMetamodelImplementor mappingMetamodel = scope.getSessionFactory()
.getRuntimeMetamodels()
.getMappingMetamodel();
final EntityPersister entityDescriptor = mappingMetamodel.getEntityDescriptor(EntityOfByteArrays.class);
{
final BasicAttributeMapping primitive = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("primitive");

View File

@ -11,9 +11,9 @@ import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
@ -39,10 +39,11 @@ public class ByteMappingTests {
@Test
public void testMappings(SessionFactoryScope scope) {
// first, verify the type selections...
final MappingMetamodel domainModel = scope.getSessionFactory().getDomainModel();
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor(EntityOfBytes.class);
final JdbcTypeRegistry jdbcTypeRegistry = domainModel.getTypeConfiguration()
.getJdbcTypeRegistry();
final MappingMetamodelImplementor mappingMetamodel = scope.getSessionFactory()
.getRuntimeMetamodels()
.getMappingMetamodel();
final EntityPersister entityDescriptor = mappingMetamodel.getEntityDescriptor(EntityOfBytes.class);
final JdbcTypeRegistry jdbcTypeRegistry = mappingMetamodel.getTypeConfiguration().getJdbcTypeRegistry();
{
final BasicAttributeMapping attribute = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("wrapper");

View File

@ -12,9 +12,9 @@ import jakarta.persistence.Id;
import jakarta.persistence.Lob;
import jakarta.persistence.Table;
import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
@ -34,9 +34,11 @@ import static org.hamcrest.Matchers.equalTo;
public class CharacterArrayMappingTests {
@Test
public void verifyMappings(SessionFactoryScope scope) {
final MappingMetamodel domainModel = scope.getSessionFactory().getDomainModel();
final JdbcTypeRegistry jdbcRegistry = domainModel.getTypeConfiguration().getJdbcTypeRegistry();
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor(EntityWithCharArrays.class);
final MappingMetamodelImplementor mappingMetamodel = scope.getSessionFactory()
.getRuntimeMetamodels()
.getMappingMetamodel();
final JdbcTypeRegistry jdbcRegistry = mappingMetamodel.getTypeConfiguration().getJdbcTypeRegistry();
final EntityPersister entityDescriptor = mappingMetamodel.getEntityDescriptor(EntityWithCharArrays.class);
{
final BasicAttributeMapping attributeMapping = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("primitive");

View File

@ -14,9 +14,9 @@ import jakarta.persistence.Table;
import org.hibernate.annotations.Nationalized;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.NationalizationSupport;
import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
@ -41,10 +41,11 @@ import static org.hamcrest.Matchers.is;
public class CharacterArrayNationalizedMappingTests {
@Test
public void verifyMappings(SessionFactoryScope scope) {
final MappingMetamodel domainModel = scope.getSessionFactory().getDomainModel();
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor(EntityWithCharArrays.class);
final JdbcTypeRegistry jdbcTypeRegistry = domainModel.getTypeConfiguration()
.getJdbcTypeRegistry();
final MappingMetamodelImplementor mappingMetamodel = scope.getSessionFactory()
.getRuntimeMetamodels()
.getMappingMetamodel();
final EntityPersister entityDescriptor = mappingMetamodel.getEntityDescriptor(EntityWithCharArrays.class);
final JdbcTypeRegistry jdbcTypeRegistry = mappingMetamodel.getTypeConfiguration().getJdbcTypeRegistry();
final Dialect dialect = scope.getSessionFactory().getJdbcServices().getDialect();
final NationalizationSupport nationalizationSupport = dialect.getNationalizationSupport();

View File

@ -11,9 +11,9 @@ import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
@ -38,9 +38,11 @@ public class CharacterMappingTests {
@Test
public void testMappings(SessionFactoryScope scope) {
// first, verify the type selections...
final MappingMetamodel domainModel = scope.getSessionFactory().getDomainModel();
final JdbcTypeRegistry jdbcRegistry = domainModel.getTypeConfiguration().getJdbcTypeRegistry();
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor(EntityOfCharacters.class);
final MappingMetamodelImplementor mappingMetamodel = scope.getSessionFactory()
.getRuntimeMetamodels()
.getMappingMetamodel();
final JdbcTypeRegistry jdbcRegistry = mappingMetamodel.getTypeConfiguration().getJdbcTypeRegistry();
final EntityPersister entityDescriptor = mappingMetamodel.getEntityDescriptor(EntityOfCharacters.class);
{
final BasicAttributeMapping attribute = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("wrapper");

View File

@ -7,14 +7,13 @@
package org.hibernate.userguide.mapping.basic;
import java.sql.Types;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
@ -35,9 +34,11 @@ public class ClassMappingTests {
@Test
public void verifyMappings(SessionFactoryScope scope) {
final MappingMetamodel domainModel = scope.getSessionFactory().getDomainModel();
final JdbcTypeRegistry jdbcRegistry = domainModel.getTypeConfiguration().getJdbcTypeRegistry();
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor(EntityWithClass.class);
final MappingMetamodelImplementor mappingMetamodel = scope.getSessionFactory()
.getRuntimeMetamodels()
.getMappingMetamodel();
final JdbcTypeRegistry jdbcRegistry = mappingMetamodel.getTypeConfiguration().getJdbcTypeRegistry();
final EntityPersister entityDescriptor = mappingMetamodel.findEntityDescriptor(EntityWithClass.class);
final BasicAttributeMapping duration = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("clazz");
final JdbcMapping jdbcMapping = duration.getJdbcMapping();

View File

@ -12,9 +12,9 @@ import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
@ -35,9 +35,11 @@ public class CurrencyMappingTests {
@Test
public void verifyMappings(SessionFactoryScope scope) {
final MappingMetamodel domainModel = scope.getSessionFactory().getDomainModel();
final JdbcTypeRegistry jdbcRegistry = domainModel.getTypeConfiguration().getJdbcTypeRegistry();
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor(EntityWithCurrency.class);
final MappingMetamodelImplementor mappingMetamodel = scope.getSessionFactory()
.getRuntimeMetamodels()
.getMappingMetamodel();
final JdbcTypeRegistry jdbcRegistry = mappingMetamodel.getTypeConfiguration().getJdbcTypeRegistry();
final EntityPersister entityDescriptor = mappingMetamodel.getEntityDescriptor(EntityWithCurrency.class);
final BasicAttributeMapping duration = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("currency");
final JdbcMapping jdbcMapping = duration.getJdbcMapping();

View File

@ -16,9 +16,9 @@ import jakarta.persistence.Id;
import jakarta.persistence.Temporal;
import jakarta.persistence.TemporalType;
import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.type.descriptor.java.TemporalJavaType;
@ -39,8 +39,10 @@ import static org.hamcrest.Matchers.is;
public class DatePrecisionTests {
@Test
public void verifyMapping(SessionFactoryScope scope) {
final MappingMetamodel domainModel = scope.getSessionFactory().getDomainModel();
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor(EntityOfDates.class);
final MappingMetamodelImplementor mappingMetamodel = scope.getSessionFactory()
.getRuntimeMetamodels()
.getMappingMetamodel();
final EntityPersister entityDescriptor = mappingMetamodel.findEntityDescriptor(EntityOfDates.class);
{
final BasicAttributeMapping attribute = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("dateAsTimestamp");

View File

@ -11,9 +11,9 @@ import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.testing.orm.junit.DomainModel;
@ -24,7 +24,6 @@ import org.junit.jupiter.api.Test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.isOneOf;
/**
@ -39,8 +38,10 @@ public class DoubleMappingTests {
@Test
public void testMappings(SessionFactoryScope scope) {
// first, verify the type selections...
final MappingMetamodel domainModel = scope.getSessionFactory().getDomainModel();
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor(EntityOfDoubles.class);
final MappingMetamodelImplementor mappingMetamodel = scope.getSessionFactory()
.getRuntimeMetamodels()
.getMappingMetamodel();
final EntityPersister entityDescriptor = mappingMetamodel.getEntityDescriptor(EntityOfDoubles.class);
{
final BasicAttributeMapping attribute = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("wrapper");

View File

@ -11,9 +11,9 @@ import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.type.SqlTypes;
import org.hibernate.type.descriptor.jdbc.AdjustableJdbcType;
@ -38,10 +38,11 @@ public class DurationMappingTests {
@Test
public void verifyMappings(SessionFactoryScope scope) {
final MappingMetamodel domainModel = scope.getSessionFactory().getDomainModel();
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor(EntityWithDuration.class);
final JdbcTypeRegistry jdbcTypeRegistry = domainModel.getTypeConfiguration()
.getJdbcTypeRegistry();
final MappingMetamodelImplementor mappingMetamodel = scope.getSessionFactory()
.getRuntimeMetamodels()
.getMappingMetamodel();
final EntityPersister entityDescriptor = mappingMetamodel.findEntityDescriptor(EntityWithDuration.class);
final JdbcTypeRegistry jdbcTypeRegistry = mappingMetamodel.getTypeConfiguration().getJdbcTypeRegistry();
final BasicAttributeMapping duration = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("duration");
final JdbcMapping jdbcMapping = duration.getJdbcMapping();
@ -50,7 +51,7 @@ public class DurationMappingTests {
final JdbcType realType;
if (intervalType instanceof AdjustableJdbcType) {
realType = ((AdjustableJdbcType) intervalType).resolveIndicatedType(
() -> domainModel.getTypeConfiguration(),
() -> mappingMetamodel.getTypeConfiguration(),
jdbcMapping.getJavaTypeDescriptor()
);
}

View File

@ -11,9 +11,9 @@ import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.testing.orm.junit.DomainModel;
@ -38,8 +38,10 @@ public class FloatMappingTests {
@Test
public void testMappings(SessionFactoryScope scope) {
// first, verify the type selections...
final MappingMetamodel domainModel = scope.getSessionFactory().getDomainModel();
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor(EntityOfFloats.class);
final MappingMetamodelImplementor mappingMetamodel = scope.getSessionFactory()
.getRuntimeMetamodels()
.getMappingMetamodel();
final EntityPersister entityDescriptor = mappingMetamodel.findEntityDescriptor(EntityOfFloats.class);
{
final BasicAttributeMapping attribute = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("wrapper");

View File

@ -12,9 +12,9 @@ import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.testing.orm.junit.DomainModel;
@ -34,8 +34,10 @@ public class InstantMappingTests {
@Test
public void verifyMappings(SessionFactoryScope scope) {
final MappingMetamodel domainModel = scope.getSessionFactory().getDomainModel();
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor(EntityWithInstant.class);
final MappingMetamodelImplementor mappingMetamodel = scope.getSessionFactory()
.getRuntimeMetamodels()
.getMappingMetamodel();
final EntityPersister entityDescriptor = mappingMetamodel.findEntityDescriptor(EntityWithInstant.class);
final BasicAttributeMapping duration = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("instant");
final JdbcMapping jdbcMapping = duration.getJdbcMapping();

View File

@ -11,9 +11,9 @@ import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.testing.orm.junit.DomainModel;
@ -38,8 +38,10 @@ public class IntegerMappingTests {
@Test
public void testMappings(SessionFactoryScope scope) {
// first, verify the type selections...
final MappingMetamodel domainModel = scope.getSessionFactory().getDomainModel();
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor(EntityOfIntegers.class);
final MappingMetamodelImplementor mappingMetamodel = scope.getSessionFactory()
.getRuntimeMetamodels()
.getMappingMetamodel();
final EntityPersister entityDescriptor = mappingMetamodel.findEntityDescriptor(EntityOfIntegers.class);
{
final BasicAttributeMapping attribute = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("wrapper");

View File

@ -12,9 +12,9 @@ import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.testing.orm.junit.DomainModel;
@ -34,8 +34,10 @@ public class LocalDateMappingTests {
@Test
public void verifyMappings(SessionFactoryScope scope) {
final MappingMetamodel domainModel = scope.getSessionFactory().getDomainModel();
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor(EntityWithLocalDate.class);
final MappingMetamodelImplementor mappingMetamodel = scope.getSessionFactory()
.getRuntimeMetamodels()
.getMappingMetamodel();
final EntityPersister entityDescriptor = mappingMetamodel.findEntityDescriptor(EntityWithLocalDate.class);
final BasicAttributeMapping duration = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("localDate");
final JdbcMapping jdbcMapping = duration.getJdbcMapping();

View File

@ -12,9 +12,9 @@ import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.testing.orm.junit.DomainModel;
@ -34,8 +34,10 @@ public class LocalDateTimeMappingTests {
@Test
public void verifyMappings(SessionFactoryScope scope) {
final MappingMetamodel domainModel = scope.getSessionFactory().getDomainModel();
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor(EntityWithLocalDateTime.class);
final MappingMetamodelImplementor mappingMetamodel = scope.getSessionFactory()
.getRuntimeMetamodels()
.getMappingMetamodel();
final EntityPersister entityDescriptor = mappingMetamodel.findEntityDescriptor(EntityWithLocalDateTime.class);
final BasicAttributeMapping duration = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("localDateTime");
final JdbcMapping jdbcMapping = duration.getJdbcMapping();

View File

@ -16,6 +16,7 @@ import jakarta.persistence.Table;
import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.testing.orm.junit.DomainModel;
@ -35,8 +36,10 @@ public class LocalTimeMappingTests {
@Test
public void verifyMappings(SessionFactoryScope scope) {
final MappingMetamodel domainModel = scope.getSessionFactory().getDomainModel();
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor(EntityWithLocalTime.class);
final MappingMetamodelImplementor mappingMetamodel = scope.getSessionFactory()
.getRuntimeMetamodels()
.getMappingMetamodel();
final EntityPersister entityDescriptor = mappingMetamodel.findEntityDescriptor(EntityWithLocalTime.class);
final BasicAttributeMapping duration = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("localTime");
final JdbcMapping jdbcMapping = duration.getJdbcMapping();

View File

@ -12,9 +12,9 @@ import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
@ -35,9 +35,11 @@ public class LocaleMappingTests {
@Test
public void verifyMappings(SessionFactoryScope scope) {
final MappingMetamodel domainModel = scope.getSessionFactory().getDomainModel();
final JdbcTypeRegistry jdbcRegistry = domainModel.getTypeConfiguration().getJdbcTypeRegistry();
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor(EntityWithLocale.class);
final MappingMetamodelImplementor mappingMetamodel = scope.getSessionFactory()
.getRuntimeMetamodels()
.getMappingMetamodel();
final JdbcTypeRegistry jdbcRegistry = mappingMetamodel.getTypeConfiguration().getJdbcTypeRegistry();
final EntityPersister entityDescriptor = mappingMetamodel.findEntityDescriptor(EntityWithLocale.class);
final BasicAttributeMapping duration = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("locale");
final JdbcMapping jdbcMapping = duration.getJdbcMapping();

View File

@ -11,9 +11,9 @@ import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.testing.orm.junit.DomainModel;
@ -38,8 +38,10 @@ public class LongMappingTests {
@Test
public void testMappings(SessionFactoryScope scope) {
// first, verify the type selections...
final MappingMetamodel domainModel = scope.getSessionFactory().getDomainModel();
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor(EntityOfLongs.class);
final MappingMetamodelImplementor mappingMetamodel = scope.getSessionFactory()
.getRuntimeMetamodels()
.getMappingMetamodel();
final EntityPersister entityDescriptor = mappingMetamodel.findEntityDescriptor(EntityOfLongs.class);
{
final BasicAttributeMapping attribute = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("wrapper");

View File

@ -8,14 +8,13 @@ package org.hibernate.userguide.mapping.basic;
import java.sql.Types;
import java.time.OffsetDateTime;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.testing.orm.junit.DomainModel;
@ -36,8 +35,10 @@ public class OffsetDateTimeMappingTests {
@Test
public void verifyMappings(SessionFactoryScope scope) {
final MappingMetamodel domainModel = scope.getSessionFactory().getDomainModel();
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor(EntityWithOffsetDateTime.class);
final MappingMetamodelImplementor mappingMetamodel = scope.getSessionFactory()
.getRuntimeMetamodels()
.getMappingMetamodel();
final EntityPersister entityDescriptor = mappingMetamodel.findEntityDescriptor(EntityWithOffsetDateTime.class);
final BasicAttributeMapping attributeMapping = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("offsetDateTime");
final JdbcMapping jdbcMapping = attributeMapping.getJdbcMapping();

View File

@ -12,9 +12,9 @@ import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.testing.orm.junit.DomainModel;
@ -35,8 +35,10 @@ public class OffsetTimeMappingTests {
@Test
public void verifyMappings(SessionFactoryScope scope) {
final MappingMetamodel domainModel = scope.getSessionFactory().getDomainModel();
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor(EntityWithOffsetTime.class);
final MappingMetamodelImplementor mappingMetamodel = scope.getSessionFactory()
.getRuntimeMetamodels()
.getMappingMetamodel();
final EntityPersister entityDescriptor = mappingMetamodel.findEntityDescriptor(EntityWithOffsetTime.class);
final BasicAttributeMapping attributeMapping = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("offsetTime");
final JdbcMapping jdbcMapping = attributeMapping.getJdbcMapping();

View File

@ -11,9 +11,9 @@ import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.testing.orm.junit.DomainModel;
@ -38,8 +38,10 @@ public class ShortMappingTests {
@Test
public void testMappings(SessionFactoryScope scope) {
// first, verify the type selections...
final MappingMetamodel domainModel = scope.getSessionFactory().getDomainModel();
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor(EntityOfShorts.class);
final MappingMetamodelImplementor mappingMetamodel = scope.getSessionFactory()
.getRuntimeMetamodels()
.getMappingMetamodel();
final EntityPersister entityDescriptor = mappingMetamodel.findEntityDescriptor(EntityOfShorts.class);
{
final BasicAttributeMapping attribute = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("wrapper");

View File

@ -12,9 +12,9 @@ import jakarta.persistence.Id;
import jakarta.persistence.Lob;
import jakarta.persistence.Table;
import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
@ -39,9 +39,11 @@ public class StringMappingTests {
@Test
public void testMappings(SessionFactoryScope scope) {
// first, verify the type selections...
final MappingMetamodel domainModel = scope.getSessionFactory().getDomainModel();
final JdbcTypeRegistry jdbcRegistry = domainModel.getTypeConfiguration().getJdbcTypeRegistry();
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor(EntityOfStrings.class);
final MappingMetamodelImplementor mappingMetamodel = scope.getSessionFactory()
.getRuntimeMetamodels()
.getMappingMetamodel();
final JdbcTypeRegistry jdbcRegistry = mappingMetamodel.getTypeConfiguration().getJdbcTypeRegistry();
final EntityPersister entityDescriptor = mappingMetamodel.findEntityDescriptor(EntityOfStrings.class);
{
final BasicAttributeMapping attribute = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("string");

View File

@ -14,9 +14,9 @@ import jakarta.persistence.Table;
import org.hibernate.annotations.Nationalized;
import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.NationalizationSupport;
import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
@ -42,9 +42,11 @@ public class StringNationalizedMappingTests {
@Test
public void testMappings(SessionFactoryScope scope) {
// first, verify the type selections...
final MappingMetamodel domainModel = scope.getSessionFactory().getDomainModel();
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor(EntityOfStrings.class);
final JdbcTypeRegistry jdbcTypeRegistry = domainModel.getTypeConfiguration()
final MappingMetamodelImplementor mappingMetamodel = scope.getSessionFactory()
.getRuntimeMetamodels()
.getMappingMetamodel();
final EntityPersister entityDescriptor = mappingMetamodel.findEntityDescriptor(EntityOfStrings.class);
final JdbcTypeRegistry jdbcTypeRegistry = mappingMetamodel.getTypeConfiguration()
.getJdbcTypeRegistry();
final Dialect dialect = scope.getSessionFactory().getJdbcServices().getDialect();

View File

@ -12,9 +12,9 @@ import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
@ -35,9 +35,11 @@ public class TimeZoneMappingTests {
@Test
public void verifyMappings(SessionFactoryScope scope) {
final MappingMetamodel domainModel = scope.getSessionFactory().getDomainModel();
final JdbcTypeRegistry jdbcRegistry = domainModel.getTypeConfiguration().getJdbcTypeRegistry();
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor(EntityWithTimeZone.class);
final MappingMetamodelImplementor mappingMetamodel = scope.getSessionFactory()
.getRuntimeMetamodels()
.getMappingMetamodel();
final JdbcTypeRegistry jdbcRegistry = mappingMetamodel.getTypeConfiguration().getJdbcTypeRegistry();
final EntityPersister entityDescriptor = mappingMetamodel.findEntityDescriptor(EntityWithTimeZone.class);
final BasicAttributeMapping duration = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("timeZone");
final JdbcMapping jdbcMapping = duration.getJdbcMapping();

View File

@ -8,14 +8,13 @@ package org.hibernate.userguide.mapping.basic;
import java.sql.Types;
import java.time.ZoneOffset;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
@ -36,9 +35,11 @@ public class ZoneOffsetMappingTests {
@Test
public void verifyMappings(SessionFactoryScope scope) {
final MappingMetamodel domainModel = scope.getSessionFactory().getDomainModel();
final JdbcTypeRegistry jdbcRegistry = domainModel.getTypeConfiguration().getJdbcTypeRegistry();
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor(EntityWithZoneOffset.class);
final MappingMetamodelImplementor mappingMetamodel = scope.getSessionFactory()
.getRuntimeMetamodels()
.getMappingMetamodel();
final JdbcTypeRegistry jdbcRegistry = mappingMetamodel.getTypeConfiguration().getJdbcTypeRegistry();
final EntityPersister entityDescriptor = mappingMetamodel.findEntityDescriptor(EntityWithZoneOffset.class);
final BasicAttributeMapping duration = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("zoneOffset");
final JdbcMapping jdbcMapping = duration.getJdbcMapping();

View File

@ -12,9 +12,9 @@ import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.testing.orm.junit.DomainModel;
@ -35,8 +35,10 @@ public class ZonedDateTimeMappingTests {
@Test
public void verifyMappings(SessionFactoryScope scope) {
final MappingMetamodel domainModel = scope.getSessionFactory().getDomainModel();
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor(EntityWithZonedDateTime.class);
final MappingMetamodelImplementor mappingMetamodel = scope.getSessionFactory()
.getRuntimeMetamodels()
.getMappingMetamodel();
final EntityPersister entityDescriptor = mappingMetamodel.findEntityDescriptor(EntityWithZonedDateTime.class);
final BasicAttributeMapping attributeMapping = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("zonedDateTime");
final JdbcMapping jdbcMapping = attributeMapping.getJdbcMapping();

View File

@ -8,12 +8,18 @@ package org.hibernate.userguide.mapping.basic.bitset;
import java.sql.Types;
import java.util.BitSet;
import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Convert;
import jakarta.persistence.Converter;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import org.hibernate.annotations.Immutable;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
import org.hibernate.metamodel.model.convert.spi.JpaAttributeConverter;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.type.descriptor.java.ImmutableMutabilityPlan;
import org.hibernate.type.descriptor.java.MutabilityPlan;
@ -23,12 +29,6 @@ import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.junit.jupiter.api.Test;
import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Convert;
import jakarta.persistence.Converter;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import org.assertj.core.api.Assertions;
import static org.hamcrest.MatcherAssert.assertThat;
@ -46,9 +46,11 @@ public class BitSetConverterImmutableTests {
@Test
public void verifyMappings(SessionFactoryScope scope) {
final SessionFactoryImplementor sessionFactory = scope.getSessionFactory();
final MappingMetamodel domainModel = sessionFactory.getDomainModel();
final MappingMetamodelImplementor mappingMetamodel = scope.getSessionFactory()
.getRuntimeMetamodels()
.getMappingMetamodel();
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor(Product.class);
final EntityPersister entityDescriptor = mappingMetamodel.findEntityDescriptor(Product.class);
final BasicAttributeMapping attributeMapping = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("bitSet");
assertThat( attributeMapping.getJavaType().getJavaTypeClass(), equalTo( BitSet.class));

View File

@ -8,12 +8,18 @@ package org.hibernate.userguide.mapping.basic.bitset;
import java.sql.Types;
import java.util.BitSet;
import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Convert;
import jakarta.persistence.Converter;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import org.hibernate.annotations.Mutability;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
import org.hibernate.metamodel.model.convert.spi.JpaAttributeConverter;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.testing.orm.junit.DomainModel;
@ -21,12 +27,6 @@ import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.junit.jupiter.api.Test;
import jakarta.persistence.AttributeConverter;
import jakarta.persistence.Convert;
import jakarta.persistence.Converter;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import org.assertj.core.api.Assertions;
import static org.hamcrest.MatcherAssert.assertThat;
@ -45,9 +45,11 @@ public class BitSetConverterMutabilityTests {
@Test
public void verifyMappings(SessionFactoryScope scope) {
final SessionFactoryImplementor sessionFactory = scope.getSessionFactory();
final MappingMetamodel domainModel = sessionFactory.getDomainModel();
final MappingMetamodelImplementor mappingMetamodel = scope.getSessionFactory()
.getRuntimeMetamodels()
.getMappingMetamodel();
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor(Product.class);
final EntityPersister entityDescriptor = mappingMetamodel.findEntityDescriptor(Product.class);
final BasicAttributeMapping attributeMapping = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("bitSet");
assertThat( attributeMapping.getJavaType().getJavaTypeClass(), equalTo( BitSet.class));

View File

@ -14,12 +14,10 @@ import jakarta.persistence.Converter;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import org.assertj.core.api.Assertions;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
import org.hibernate.metamodel.model.convert.spi.JpaAttributeConverter;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.testing.orm.junit.DomainModel;
@ -27,6 +25,8 @@ import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.junit.jupiter.api.Test;
import org.assertj.core.api.Assertions;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.instanceOf;
@ -41,10 +41,11 @@ public class BitSetConverterTests {
@Test
public void verifyMappings(SessionFactoryScope scope) {
final SessionFactoryImplementor sessionFactory = scope.getSessionFactory();
final MappingMetamodel domainModel = sessionFactory.getDomainModel();
final MappingMetamodelImplementor mappingMetamodel = scope.getSessionFactory()
.getRuntimeMetamodels()
.getMappingMetamodel();
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor(Product.class);
final EntityPersister entityDescriptor = mappingMetamodel.findEntityDescriptor(Product.class);
final BasicAttributeMapping attributeMapping = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("bitSet");
assertThat( attributeMapping.getJavaType().getJavaTypeClass(), equalTo( BitSet.class));

View File

@ -12,9 +12,8 @@ import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.testing.orm.junit.DomainModel;
@ -38,10 +37,11 @@ public class BitSetImplicitTests {
@Test
public void verifyMappings(SessionFactoryScope scope) {
final SessionFactoryImplementor sessionFactory = scope.getSessionFactory();
final MappingMetamodel domainModel = sessionFactory.getDomainModel();
final MappingMetamodelImplementor mappingMetamodel = scope.getSessionFactory()
.getRuntimeMetamodels()
.getMappingMetamodel();
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor(Product.class);
final EntityPersister entityDescriptor = mappingMetamodel.findEntityDescriptor(Product.class);
final BasicAttributeMapping attributeMapping = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("bitSet");
assertThat( attributeMapping.getJavaType().getJavaTypeClass(), equalTo( BitSet.class));

View File

@ -13,9 +13,8 @@ import jakarta.persistence.Id;
import jakarta.persistence.Table;
import org.hibernate.annotations.JdbcTypeCode;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.testing.orm.junit.DomainModel;
@ -40,10 +39,11 @@ public class BitSetJdbcTypeCodeTests {
@Test
public void verifyMappings(SessionFactoryScope scope) {
final SessionFactoryImplementor sessionFactory = scope.getSessionFactory();
final MappingMetamodel domainModel = sessionFactory.getDomainModel();
final MappingMetamodelImplementor mappingMetamodel = scope.getSessionFactory()
.getRuntimeMetamodels()
.getMappingMetamodel();
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor(Product.class);
final EntityPersister entityDescriptor = mappingMetamodel.findEntityDescriptor(Product.class);
final BasicAttributeMapping attributeMapping = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("bitSet");
assertThat( attributeMapping.getJavaType().getJavaTypeClass(), equalTo( BitSet.class));

View File

@ -8,11 +8,13 @@ package org.hibernate.userguide.mapping.basic.bitset;
import java.sql.Types;
import java.util.BitSet;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import org.hibernate.annotations.JdbcTypeRegistration;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.userguide.mapping.basic.CustomBinaryJdbcType;
@ -22,10 +24,6 @@ import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
@ -40,10 +38,11 @@ public class BitSetJdbcTypeRegistrationTests {
@Test
public void verifyMappings(SessionFactoryScope scope) {
final SessionFactoryImplementor sessionFactory = scope.getSessionFactory();
final MappingMetamodel domainModel = sessionFactory.getDomainModel();
final MappingMetamodelImplementor mappingMetamodel = scope.getSessionFactory()
.getRuntimeMetamodels()
.getMappingMetamodel();
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor(Product.class);
final EntityPersister entityDescriptor = mappingMetamodel.findEntityDescriptor(Product.class);
final BasicAttributeMapping attributeMapping = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("bitSet");
assertThat( attributeMapping.getJavaType().getJavaTypeClass(), equalTo( BitSet.class));

View File

@ -13,9 +13,8 @@ import jakarta.persistence.Id;
import jakarta.persistence.Table;
import org.hibernate.annotations.JdbcType;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.mapping.internal.BasicAttributeMapping;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.userguide.mapping.basic.CustomBinaryJdbcType;
@ -39,10 +38,11 @@ public class BitSetJdbcTypeTests {
@Test
public void verifyMappings(SessionFactoryScope scope) {
final SessionFactoryImplementor sessionFactory = scope.getSessionFactory();
final MappingMetamodel domainModel = sessionFactory.getDomainModel();
final MappingMetamodelImplementor mappingMetamodel = scope.getSessionFactory()
.getRuntimeMetamodels()
.getMappingMetamodel();
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor(Product.class);
final EntityPersister entityDescriptor = mappingMetamodel.findEntityDescriptor(Product.class);
final BasicAttributeMapping attributeMapping = (BasicAttributeMapping) entityDescriptor.findAttributeMapping("bitSet");
assertThat( attributeMapping.getJavaType().getJavaTypeClass(), equalTo( BitSet.class));

View File

@ -9,8 +9,8 @@ package org.hibernate.community.dialect;
import java.util.Collections;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.orm.test.jpa.JpaComplianceStub;
import org.hibernate.metamodel.model.domain.internal.JpaMetamodelImpl;
import org.hibernate.orm.test.jpa.JpaComplianceStub;
import org.hibernate.query.criteria.ValueHandlingMode;
import org.hibernate.query.internal.NamedObjectRepositoryImpl;
import org.hibernate.query.spi.QueryEngine;
@ -32,7 +32,6 @@ import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
* Testing of patched support for Informix boolean type; see HHH-9894, HHH-10800

View File

@ -228,9 +228,10 @@ public final class Hibernate {
*/
@SuppressWarnings("unchecked")
public static <E> E createDetachedProxy(SessionFactory sessionFactory, Class<E> entityClass, Object id) {
EntityPersister persister =
sessionFactory.unwrap(SessionFactoryImplementor.class).getMetamodel()
.findEntityDescriptor(entityClass);
final EntityPersister persister = sessionFactory.unwrap(SessionFactoryImplementor.class)
.getRuntimeMetamodels()
.getMappingMetamodel()
.findEntityDescriptor(entityClass);
if (persister==null) {
throw new UnknownEntityTypeException("unknown entity type");
}

View File

@ -25,7 +25,7 @@ import org.hibernate.cache.spi.access.SoftLock;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.event.spi.EventSource;
import org.hibernate.metamodel.spi.MetamodelImplementor;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.query.sqm.tree.SqmDmlStatement;
@ -81,10 +81,11 @@ public class BulkOperationCleanupAction implements Executable, Serializable {
);
}
final Set<String> roles = factory.getMetamodel().getCollectionRolesByEntityParticipant( persister.getEntityName() );
final MappingMetamodelImplementor mappingMetamodel = factory.getRuntimeMetamodels().getMappingMetamodel();
final Set<String> roles = mappingMetamodel.getCollectionRolesByEntityParticipant( persister.getEntityName() );
if ( roles != null ) {
for ( String role : roles ) {
final CollectionPersister collectionPersister = factory.getMetamodel().collectionPersister( role );
final CollectionPersister collectionPersister = mappingMetamodel.getCollectionDescriptor( role );
if ( collectionPersister.hasCache() ) {
collectionCleanups.add(
new CollectionCleanup(
@ -116,47 +117,47 @@ public class BulkOperationCleanupAction implements Executable, Serializable {
final LinkedHashSet<String> spacesList = new LinkedHashSet<>( tableSpaces );
final SessionFactoryImplementor factory = session.getFactory();
final MetamodelImplementor metamodel = factory.getMetamodel();
for ( EntityPersister persister : metamodel.entityPersisters().values() ) {
final String[] entitySpaces = (String[]) persister.getQuerySpaces();
final MappingMetamodelImplementor metamodel = factory.getRuntimeMetamodels().getMappingMetamodel();
metamodel.forEachEntityDescriptor( (entityDescriptor) -> {
final String[] entitySpaces = (String[]) entityDescriptor.getQuerySpaces();
if ( affectedEntity( tableSpaces, entitySpaces ) ) {
Collections.addAll( spacesList, entitySpaces );
if ( persister.canWriteToCache() ) {
entityCleanups.add( new EntityCleanup( persister.getCacheAccessStrategy(), session ) );
if ( entityDescriptor.canWriteToCache() ) {
entityCleanups.add( new EntityCleanup( entityDescriptor.getCacheAccessStrategy(), session ) );
}
if ( persister.hasNaturalIdentifier() && persister.hasNaturalIdCache() ) {
naturalIdCleanups.add( new NaturalIdCleanup( persister.getNaturalIdCacheAccessStrategy(), session ) );
if ( entityDescriptor.hasNaturalIdentifier() && entityDescriptor.hasNaturalIdCache() ) {
naturalIdCleanups.add( new NaturalIdCleanup( entityDescriptor.getNaturalIdCacheAccessStrategy(), session ) );
}
final Set<String> roles = metamodel.getCollectionRolesByEntityParticipant( persister.getEntityName() );
final Set<String> roles = metamodel.getCollectionRolesByEntityParticipant( entityDescriptor.getEntityName() );
if ( roles != null ) {
for ( String role : roles ) {
final CollectionPersister collectionPersister = metamodel.collectionPersister( role );
if ( collectionPersister.hasCache() ) {
final CollectionPersister collectionDescriptor = metamodel.getCollectionDescriptor( role );
if ( collectionDescriptor.hasCache() ) {
collectionCleanups.add(
new CollectionCleanup( collectionPersister.getCacheAccessStrategy(), session )
new CollectionCleanup( collectionDescriptor.getCacheAccessStrategy(), session )
);
}
}
}
}
}
} );
this.affectedTableSpaces = spacesList.toArray( new String[ 0 ] );
}
public static void schedule(SharedSessionContractImplementor session, SqmDmlStatement<?> statement) {
final List<EntityPersister> entityPersisters = new ArrayList<>( 1 );
final MetamodelImplementor metamodel = session.getFactory().getMetamodel();
final MappingMetamodelImplementor metamodel = session.getFactory().getRuntimeMetamodels().getMappingMetamodel();
if ( !( statement instanceof InsertStatement ) ) {
entityPersisters.add( metamodel.entityPersister( statement.getTarget().getEntityName() ) );
entityPersisters.add( metamodel.getEntityDescriptor( statement.getTarget().getEntityName() ) );
}
for ( SqmCteStatement<?> cteStatement : statement.getCteStatements() ) {
final SqmStatement<?> cteDefinition = cteStatement.getCteDefinition();
if ( cteDefinition instanceof SqmDmlStatement<?> && !( cteDefinition instanceof InsertStatement ) ) {
entityPersisters.add(
metamodel.entityPersister( ( (SqmDmlStatement<?>) cteDefinition ).getTarget().getEntityName() )
metamodel.getEntityDescriptor( ( (SqmDmlStatement<?>) cteDefinition ).getTarget().getEntityName() )
);
}
}

View File

@ -64,7 +64,7 @@ public abstract class CollectionAction implements Executable, Serializable, Comp
// guard against NullPointerException
if ( session != null ) {
this.session = session;
this.persister = session.getFactory().getMetamodel().collectionPersister( collectionRole );
this.persister = session.getFactory().getRuntimeMetamodels().getMappingMetamodel().getCollectionDescriptor( collectionRole );
}
}

View File

@ -182,7 +182,7 @@ public abstract class EntityAction
// guard against NullPointerException
if ( session != null ) {
this.session = session;
this.persister = session.getFactory().getMetamodel().entityPersister( entityName );
this.persister = session.getFactory().getRuntimeMetamodels().getMappingMetamodel().getEntityDescriptor( entityName );
this.instance = session.getPersistenceContext().getEntity( session.generateEntityKey( id, persister ) );
}
}

View File

@ -128,7 +128,11 @@ public class UnresolvedEntityInsertActions {
for ( Map.Entry<Object,Set<AbstractEntityInsertAction>> entry : dependentActionsByTransientEntity.entrySet() ) {
final Object transientEntity = entry.getKey();
final String transientEntityName = session.guessEntityName( transientEntity );
final Object transientEntityId = session.getFactory().getMetamodel().entityPersister( transientEntityName ).getIdentifier( transientEntity, session );
final Object transientEntityId = session.getFactory()
.getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( transientEntityName )
.getIdentifier( transientEntity, session );
final String transientEntityString = MessageHelper.infoString( transientEntityName, transientEntityId );
final Set<String> dependentEntityStrings = new TreeSet<>();
final Set<String> nonNullableTransientPropertyPaths = new TreeSet<>();

View File

@ -57,7 +57,10 @@ public class EnhancementAsProxyLazinessInterceptor extends AbstractLazyLoadInter
this.entityKey = entityKey;
final EntityPersister entityPersister = session.getFactory().getMetamodel().entityPersister( entityName );
final EntityPersister entityPersister = session.getFactory()
.getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( entityName );
if ( entityPersister.hasCollections() ) {
Type[] propertyTypes = entityPersister.getPropertyTypes();
collectionAttributeNames = new HashSet<>();
@ -100,8 +103,9 @@ public class EnhancementAsProxyLazinessInterceptor extends AbstractLazyLoadInter
final Object[] writtenValues;
final EntityPersister entityPersister = session.getFactory()
.getMetamodel()
.entityPersister( getEntityName() );
.getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( getEntityName() );
if ( writtenFieldNames != null && !writtenFieldNames.isEmpty() ) {
@ -200,8 +204,9 @@ public class EnhancementAsProxyLazinessInterceptor extends AbstractLazyLoadInter
);
final EntityPersister persister = session.getFactory()
.getMetamodel()
.entityPersister( getEntityName() );
.getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( getEntityName() );
if ( isTemporarySession ) {
// Add an entry for this entity in the PC of the temp Session

View File

@ -76,7 +76,9 @@ public class LazyAttributeLoadingInterceptor extends AbstractLazyLoadInterceptor
return EnhancementHelper.performWork(
this,
(session, isTemporarySession) -> {
final EntityPersister persister = session.getFactory().getMetamodel().entityPersister( getEntityName() );
final EntityPersister persister = session.getFactory()
.getMappingMetamodel()
.getEntityDescriptor( getEntityName() );
if ( isTemporarySession ) {
final Object id = persister.getIdentifier( target, session );

View File

@ -28,7 +28,7 @@ import org.hibernate.event.spi.PostInsertEventListener;
import org.hibernate.event.spi.PostUpdateEvent;
import org.hibernate.event.spi.PostUpdateEventListener;
import org.hibernate.integrator.spi.Integrator;
import org.hibernate.metamodel.spi.MetamodelImplementor;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.service.spi.SessionFactoryServiceRegistry;
@ -104,7 +104,7 @@ public class CollectionCacheInvalidator
try {
SessionFactoryImplementor factory = persister.getFactory();
final MetamodelImplementor metamodel = factory.getMetamodel();
final MappingMetamodelImplementor metamodel = factory.getRuntimeMetamodels().getMappingMetamodel();
Set<String> collectionRoles = metamodel.getCollectionRolesByEntityParticipant( persister.getEntityName() );
if ( collectionRoles == null || collectionRoles.isEmpty() ) {
return;
@ -112,7 +112,7 @@ public class CollectionCacheInvalidator
final EntityMetamodel entityMetamodel = persister.getEntityMetamodel();
final boolean debugEnabled = LOG.isDebugEnabled();
for ( String role : collectionRoles ) {
final CollectionPersister collectionPersister = metamodel.collectionPersister( role );
final CollectionPersister collectionPersister = metamodel.getCollectionDescriptor( role );
if ( !collectionPersister.hasCache() ) {
// ignore collection if no caching is used
continue;
@ -167,7 +167,11 @@ public class CollectionCacheInvalidator
if ( obj != null ) {
id = session.getContextEntityIdentifier( obj );
if ( id == null ) {
id = session.getSessionFactory().getMetamodel().entityPersister( obj.getClass() ).getIdentifier( obj, session );
final EntityPersister persister = session.getFactory()
.getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( obj.getClass() );
id = persister.getIdentifier( obj, session );
}
}
return id;

View File

@ -40,6 +40,7 @@ import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.ArrayHelper;
import org.hibernate.metamodel.model.domain.NavigableRole;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.pretty.MessageHelper;
@ -227,7 +228,10 @@ public class EnabledCaching implements CacheImplementor, DomainDataRegionBuildin
@Override
public boolean containsEntity(String entityName, Object identifier) {
final EntityPersister entityDescriptor = sessionFactory.getMetamodel().entityPersister( entityName );
final EntityPersister entityDescriptor = sessionFactory
.getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( entityName );
final EntityDataAccess cacheAccess = entityDescriptor.getCacheAccessStrategy();
if ( cacheAccess == null ) {
return false;
@ -253,7 +257,10 @@ public class EnabledCaching implements CacheImplementor, DomainDataRegionBuildin
@Override
public void evictEntityData(String entityName, Object identifier) {
final EntityPersister entityDescriptor = sessionFactory.getMetamodel().entityPersister( entityName );
final EntityPersister entityDescriptor = sessionFactory
.getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( entityName );
final EntityDataAccess cacheAccess = entityDescriptor.getCacheAccessStrategy();
if ( cacheAccess == null ) {
return;
@ -277,14 +284,18 @@ public class EnabledCaching implements CacheImplementor, DomainDataRegionBuildin
@Override
public void evictEntityData(String entityName) {
evictEntityData( getSessionFactory().getMetamodel().entityPersister( entityName ) );
final EntityPersister entityDescriptor = sessionFactory
.getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( entityName );
evictEntityData( entityDescriptor );
}
protected void evictEntityData(EntityPersister entityDescriptor) {
EntityPersister rootEntityDescriptor = entityDescriptor;
if ( entityDescriptor.isInherited()
&& ! entityDescriptor.getEntityName().equals( entityDescriptor.getRootEntityName() ) ) {
rootEntityDescriptor = getSessionFactory().getMetamodel().entityPersister( entityDescriptor.getRootEntityName() );
rootEntityDescriptor = entityDescriptor.getRootEntityDescriptor().getEntityPersister();
}
evictEntityData(
@ -307,7 +318,10 @@ public class EnabledCaching implements CacheImplementor, DomainDataRegionBuildin
@Override
public void evictEntityData() {
sessionFactory.getMetamodel().entityPersisters().values().forEach( this::evictEntityData );
final MappingMetamodelImplementor mappingMetamodel = sessionFactory
.getRuntimeMetamodels()
.getMappingMetamodel();
mappingMetamodel.forEachEntityDescriptor( this::evictEntityData );
}
@ -322,9 +336,11 @@ public class EnabledCaching implements CacheImplementor, DomainDataRegionBuildin
@Override
public void evictNaturalIdData(String entityName) {
evictNaturalIdData(
sessionFactory.getMetamodel().entityPersister( entityName )
);
final EntityPersister entityDescriptor = sessionFactory
.getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( entityName );
evictNaturalIdData( entityDescriptor );
}
private void evictNaturalIdData(EntityPersister rootEntityDescriptor) {
@ -355,8 +371,11 @@ public class EnabledCaching implements CacheImplementor, DomainDataRegionBuildin
@Override
public boolean containsCollection(String role, Object ownerIdentifier) {
final CollectionPersister collectionDescriptor = sessionFactory.getMetamodel()
.collectionPersister( role );
final CollectionPersister collectionDescriptor = sessionFactory
.getRuntimeMetamodels()
.getMappingMetamodel()
.getCollectionDescriptor( role );
final CollectionDataAccess cacheAccess = collectionDescriptor.getCacheAccessStrategy();
if ( cacheAccess == null ) {
@ -369,8 +388,10 @@ public class EnabledCaching implements CacheImplementor, DomainDataRegionBuildin
@Override
public void evictCollectionData(String role, Object ownerIdentifier) {
final CollectionPersister collectionDescriptor = sessionFactory.getMetamodel()
.collectionPersister( role );
final CollectionPersister collectionDescriptor = sessionFactory
.getRuntimeMetamodels()
.getMappingMetamodel()
.getCollectionDescriptor( role );
final CollectionDataAccess cacheAccess = collectionDescriptor.getCacheAccessStrategy();
if ( cacheAccess == null ) {
@ -390,8 +411,10 @@ public class EnabledCaching implements CacheImplementor, DomainDataRegionBuildin
@Override
public void evictCollectionData(String role) {
final CollectionPersister collectionDescriptor = sessionFactory.getMetamodel()
.collectionPersister( role );
final CollectionPersister collectionDescriptor = sessionFactory
.getRuntimeMetamodels()
.getMappingMetamodel()
.getCollectionDescriptor( role );
evictCollectionData( collectionDescriptor );
}

View File

@ -11,6 +11,7 @@ import java.util.HashMap;
import java.util.Map;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.entity.EntityPersister;
/**
@ -41,7 +42,12 @@ public class StructuredCacheEntry implements CacheEntryStructure {
final Map map = (Map) structured;
final String subclass = (String) map.get( SUBCLASS_KEY );
final Object version = map.get( VERSION_KEY );
final EntityPersister subclassPersister = factory.getMetamodel().entityPersister(subclass);
final EntityPersister subclassPersister = factory
.getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( subclass );
final String[] names = subclassPersister.getPropertyNames();
final Serializable[] disassembledState = new Serializable[names.length];
for ( int i = 0; i < names.length; i++ ) {

View File

@ -244,10 +244,11 @@ public abstract class AbstractPersistentCollection<E> implements Serializable, P
session.beginTransaction();
}
session.getPersistenceContextInternal().addUninitializedDetachedCollection(
session.getFactory().getMetamodel().collectionPersister(getRole()),
this
);
final CollectionPersister collectionDescriptor = session.getSessionFactory()
.getRuntimeMetamodels()
.getMappingMetamodel()
.getCollectionDescriptor( getRole() );
session.getPersistenceContextInternal().addUninitializedDetachedCollection( collectionDescriptor, this );
}
try {
@ -1214,8 +1215,11 @@ public abstract class AbstractPersistentCollection<E> implements Serializable, P
return oldElements;
}
final EntityPersister entityPersister = session.getFactory().getMetamodel().entityPersister(entityName);
final Type idType = entityPersister.getIdentifierType();
final EntityPersister entityDescriptor = session.getFactory()
.getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( entityName );
final Type idType = entityDescriptor.getIdentifierType();
final boolean useIdDirect = mayUseIdDirect( idType );
// create the collection holding the Orphans
@ -1279,16 +1283,16 @@ public abstract class AbstractPersistentCollection<E> implements Serializable, P
Object entityInstance,
String entityName,
SharedSessionContractImplementor session) {
if ( entityInstance != null && ForeignKeys.isNotTransient( entityName, entityInstance, null, session ) ) {
final EntityPersister entityPersister = session.getFactory().getMetamodel().entityPersister(entityName);
final Type idType = entityPersister.getIdentifierType();
final EntityPersister entityDescriptor = session.getFactory()
.getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( entityName );
final Object idOfCurrent = ForeignKeys.getEntityIdentifierIfNotUnsaved( entityName, entityInstance, session );
final Iterator<?> itr = list.iterator();
while ( itr.hasNext() ) {
final Object idOfOld = ForeignKeys.getEntityIdentifierIfNotUnsaved( entityName, itr.next(), session );
if ( idType.isEqual( idOfCurrent, idOfOld, session.getFactory() ) ) {
if ( entityDescriptor.getIdentifierMapping().areEqual( idOfCurrent, idOfOld, session ) ) {
itr.remove();
break;
}

View File

@ -121,7 +121,12 @@ public abstract class AbstractEntityEntry implements Serializable, EntityEntry {
final boolean existsInDatabase,
final boolean isBeingReplicated,
final PersistenceContext persistenceContext) {
this.persister = ( factory == null ? null : factory.getMetamodel().entityPersister(entityName));
if ( factory == null ) {
this.persister = null;
}
else {
this.persister = factory.getRuntimeMetamodels().getMappingMetamodel().getEntityDescriptor( entityName );
}
this.id = id;
setCompressedValue( EnumState.STATUS, status );
setCompressedValue( EnumState.PREVIOUS_STATUS, previousStatus );

View File

@ -460,7 +460,10 @@ public final class Cascade {
final CascadeStyle style,
final Object anything,
final CollectionType type) {
final CollectionPersister persister = eventSource.getFactory().getMetamodel().collectionPersister(type.getRole());
final CollectionPersister persister = eventSource.getFactory()
.getRuntimeMetamodels()
.getMappingMetamodel()
.getCollectionDescriptor( type.getRole());
final Type elemType = persister.getElementType();
CascadePoint elementsCascadePoint = cascadePoint;

View File

@ -157,7 +157,9 @@ public final class Collections {
}
final SessionFactoryImplementor factory = session.getFactory();
final CollectionPersister persister = factory.getMetamodel().collectionPersister( type.getRole() );
final CollectionPersister persister = factory.getRuntimeMetamodels()
.getMappingMetamodel()
.getCollectionDescriptor( type.getRole() );
ce.setCurrentPersister( persister );
//TODO: better to pass the id in as an argument?

View File

@ -57,7 +57,7 @@ import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.internal.util.collections.ConcurrentReferenceHashMap;
import org.hibernate.internal.util.collections.IdentityMap;
import org.hibernate.metamodel.spi.MetamodelImplementor;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.pretty.MessageHelper;
@ -365,7 +365,7 @@ public class StatefulPersistenceContext implements PersistenceContext {
}
private EntityPersister locateProperPersister(EntityPersister persister) {
return session.getFactory().getMetamodel().entityPersister( persister.getRootEntityName() );
return persister.getRootEntityDescriptor().getEntityPersister();
}
@Override
@ -628,7 +628,10 @@ public class StatefulPersistenceContext implements PersistenceContext {
*/
private void reassociateProxy(LazyInitializer li, HibernateProxy proxy) {
if ( li.getSession() != this.getSession() ) {
final EntityPersister persister = session.getFactory().getMetamodel().entityPersister( li.getEntityName() );
final EntityPersister persister = session.getFactory()
.getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( li.getEntityName() );
final EntityKey key = session.generateEntityKey( li.getInternalIdentifier(), persister );
// any earlier proxy takes precedence
getOrInitializeProxiesByKey().putIfAbsent( key, proxy );
@ -1229,8 +1232,12 @@ public class StatefulPersistenceContext implements PersistenceContext {
@Override
public Object getOwnerId(String entityName, String propertyName, Object childEntity, Map mergeMap) {
final String collectionRole = entityName + '.' + propertyName;
final EntityPersister persister = session.getFactory().getMetamodel().entityPersister( entityName );
final CollectionPersister collectionPersister = session.getFactory().getMetamodel().collectionPersister( collectionRole );
final MappingMetamodelImplementor mappingMetamodel = session.getFactory()
.getRuntimeMetamodels()
.getMappingMetamodel();
final EntityPersister persister = mappingMetamodel.getEntityDescriptor( entityName );
final CollectionPersister collectionPersister = mappingMetamodel.getCollectionDescriptor( collectionRole );
// try cache lookup first
final Object parent = getParentsByChild( childEntity );
@ -1355,9 +1362,9 @@ public class StatefulPersistenceContext implements PersistenceContext {
@Override
public Object getIndexInOwner(String entity, String property, Object childEntity, Map mergeMap) {
final MetamodelImplementor metamodel = session.getFactory().getMetamodel();
final EntityPersister persister = metamodel.entityPersister( entity );
final CollectionPersister cp = metamodel.collectionPersister( entity + '.' + property );
final MappingMetamodelImplementor metamodel = session.getFactory().getRuntimeMetamodels().getMappingMetamodel();
final EntityPersister persister = metamodel.getEntityDescriptor( entity );
final CollectionPersister cp = metamodel.getCollectionDescriptor( entity + '.' + property );
// try cache lookup first
final Object parent = getParentsByChild( childEntity );

View File

@ -47,6 +47,7 @@ import org.hibernate.internal.CoreLogging;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.proxy.HibernateProxy;
import org.hibernate.proxy.LazyInitializer;
import org.hibernate.type.CollectionType;
@ -1164,8 +1165,9 @@ public class ActionQueue {
action.getEntityName(),
action.getSession()
.getFactory()
.getMetamodel()
.entityPersister( action.getEntityName() )
.getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( action.getEntityName() )
.getRootEntityName()
);
@ -1301,11 +1303,14 @@ public class ActionQueue {
BatchIdentifier batchIdentifier,
Type type,
Object value) {
final MappingMetamodelImplementor mappingMetamodel = action.getSession()
.getFactory()
.getRuntimeMetamodels()
.getMappingMetamodel();
if ( type.isEntityType() ) {
final EntityType entityType = (EntityType) type;
final String entityName = entityType.getName();
final String rootEntityName = action.getSession().getFactory().getMetamodel().
entityPersister( entityName ).getRootEntityName();
final String rootEntityName = mappingMetamodel.getEntityDescriptor( entityName ).getRootEntityName();
if ( entityType.isOneToOne() && entityType.getForeignKeyDirection() == ForeignKeyDirection.TO_PARENT ) {
if ( !entityType.isReferenceToPrimaryKey() ) {
@ -1333,11 +1338,10 @@ public class ActionQueue {
else if ( type.isCollectionType() ) {
CollectionType collectionType = (CollectionType) type;
final SessionFactoryImplementor sessionFactory = action.getSession().getSessionFactory();
if ( collectionType.getElementType( sessionFactory ).isEntityType() &&
!sessionFactory.getMetamodel().collectionPersister( collectionType.getRole() ).isManyToMany() ) {
String entityName = collectionType.getAssociatedEntityName( sessionFactory );
String rootEntityName = action.getSession().getFactory().getMetamodel()
.entityPersister( entityName ).getRootEntityName();
if ( collectionType.getElementType( sessionFactory ).isEntityType()
&& !mappingMetamodel.getCollectionDescriptor( collectionType.getRole() ).isManyToMany() ) {
final String entityName = collectionType.getAssociatedEntityName( sessionFactory );
final String rootEntityName = mappingMetamodel.getEntityDescriptor( entityName ).getRootEntityName();
batchIdentifier.getChildEntityNames().add( entityName );
if ( !rootEntityName.equals( entityName ) ) {
batchIdentifier.getChildEntityNames().add( rootEntityName );

View File

@ -118,7 +118,9 @@ public final class CollectionEntry implements Serializable {
ignore = false;
loadedKey = collection.getKey();
setLoadedPersister( factory.getMetamodel().collectionPersister( collection.getRole() ) );
setLoadedPersister(
factory.getRuntimeMetamodels().getMappingMetamodel().getCollectionDescriptor( collection.getRole() )
);
snapshot = collection.getStoredSnapshot();
}
@ -279,7 +281,12 @@ public final class CollectionEntry implements Serializable {
}
void afterDeserialize(SessionFactoryImplementor factory) {
loadedPersister = ( factory == null ? null : factory.getMetamodel().collectionPersister( role ) );
if ( factory == null ) {
loadedPersister = null;
}
else {
loadedPersister = factory.getRuntimeMetamodels().getMappingMetamodel().getCollectionDescriptor( role );
}
}
public boolean wasDereferenced() {

View File

@ -66,8 +66,10 @@ public final class CollectionKey implements Serializable {
@Override
public String toString() {
return "CollectionKey"
+ MessageHelper.collectionInfoString(factory.getMetamodel().collectionPersister(role), key, factory );
final CollectionPersister collectionDescriptor = factory.getRuntimeMetamodels()
.getMappingMetamodel()
.getCollectionDescriptor( role );
return "CollectionKey" + MessageHelper.collectionInfoString( collectionDescriptor, key, factory );
}
@Override

View File

@ -149,7 +149,10 @@ public final class EntityKey implements Serializable {
public static EntityKey deserialize(ObjectInputStream ois, SessionFactoryImplementor sessionFactory) throws IOException, ClassNotFoundException {
final Object id = ois.readObject();
final String entityName = (String) ois.readObject();
final EntityPersister entityPersister = sessionFactory.getMetamodel().entityPersister(entityName);
return new EntityKey(id, entityPersister);
final EntityPersister entityPersister = sessionFactory
.getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( entityName);
return new EntityKey( id, entityPersister );
}
}

View File

@ -12,6 +12,11 @@ import java.util.Map;
import java.util.Set;
import javax.naming.NamingException;
import javax.naming.Reference;
import jakarta.persistence.EntityGraph;
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceUnitUtil;
import jakarta.persistence.Query;
import jakarta.persistence.SynchronizationType;
import org.hibernate.CustomEntityDirtinessStrategy;
import org.hibernate.HibernateException;
@ -33,13 +38,13 @@ import org.hibernate.id.IdentifierGenerator;
import org.hibernate.internal.FastSessionServices;
import org.hibernate.metadata.ClassMetadata;
import org.hibernate.metadata.CollectionMetadata;
import org.hibernate.metamodel.RuntimeMetamodels;
import org.hibernate.query.BindableType;
import org.hibernate.metamodel.model.domain.JpaMetamodel;
import org.hibernate.metamodel.model.domain.spi.JpaMetamodelImplementor;
import org.hibernate.metamodel.spi.MetamodelImplementor;
import org.hibernate.metamodel.spi.RuntimeMetamodelsImplementor;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.proxy.EntityNotFoundDelegate;
import org.hibernate.query.BindableType;
import org.hibernate.query.criteria.HibernateCriteriaBuilder;
import org.hibernate.query.spi.QueryEngine;
import org.hibernate.service.spi.ServiceRegistryImplementor;
@ -48,12 +53,6 @@ import org.hibernate.type.Type;
import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.type.spi.TypeConfiguration;
import jakarta.persistence.EntityGraph;
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceUnitUtil;
import jakarta.persistence.Query;
import jakarta.persistence.SynchronizationType;
/**
* Base delegating implementation of the SessionFactory and SessionFactoryImplementor
* contracts for intended for easier implementation of SessionFactory.
@ -127,7 +126,7 @@ public class SessionFactoryDelegatingImpl implements SessionFactoryImplementor,
}
@Override
public RuntimeMetamodels getRuntimeMetamodels() {
public RuntimeMetamodelsImplementor getRuntimeMetamodels() {
return delegate.getRuntimeMetamodels();
}
@ -198,21 +197,29 @@ public class SessionFactoryDelegatingImpl implements SessionFactoryImplementor,
@Deprecated
public EntityPersister getEntityPersister(String entityName) throws MappingException {
return delegate.getMetamodel().entityPersister(entityName);
return delegate.getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( entityName );
}
@Deprecated
public Map<String, EntityPersister> getEntityPersisters() {
// for the time being, leave this calling `MetamodelImplementor` to avoid
// creating the map
return delegate.getMetamodel().entityPersisters();
}
@Deprecated
public CollectionPersister getCollectionPersister(String role) throws MappingException {
return delegate.getMetamodel().collectionPersister(role);
return delegate.getRuntimeMetamodels()
.getMappingMetamodel()
.getCollectionDescriptor( role );
}
@Deprecated
public Map<String, CollectionPersister> getCollectionPersisters() {
// for the time being, leave this calling `MetamodelImplementor` to avoid
// creating the map
return delegate.getMetamodel().collectionPersisters();
}
@ -228,6 +235,8 @@ public class SessionFactoryDelegatingImpl implements SessionFactoryImplementor,
@Deprecated
public String[] getImplementors(String className) throws MappingException {
// for the time being, leave this calling `MetamodelImplementor` - nothing uses
// this method and this is the only usage of `MetamodelImplementor#getImplementors`
return delegate.getMetamodel().getImplementors(className);
}
@ -248,7 +257,7 @@ public class SessionFactoryDelegatingImpl implements SessionFactoryImplementor,
@Deprecated
public Set<String> getCollectionRolesByEntityParticipant(String entityName) {
return delegate.getMetamodel().getCollectionRolesByEntityParticipant(entityName);
return delegate.getRuntimeMetamodels().getMappingMetamodel().getCollectionRolesByEntityParticipant( entityName );
}
@Override
@ -262,7 +271,7 @@ public class SessionFactoryDelegatingImpl implements SessionFactoryImplementor,
}
@Override
public JpaMetamodel getJpaMetamodel() {
public JpaMetamodelImplementor getJpaMetamodel() {
return delegate.getJpaMetamodel();
}

View File

@ -21,10 +21,10 @@ import org.hibernate.engine.profile.FetchProfile;
import org.hibernate.event.spi.EventEngine;
import org.hibernate.graph.spi.RootGraphImplementor;
import org.hibernate.id.IdentifierGenerator;
import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.RuntimeMetamodels;
import org.hibernate.internal.FastSessionServices;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.metamodel.spi.MetamodelImplementor;
import org.hibernate.metamodel.spi.RuntimeMetamodelsImplementor;
import org.hibernate.proxy.EntityNotFoundDelegate;
import org.hibernate.query.criteria.HibernateCriteriaBuilder;
import org.hibernate.query.spi.QueryEngine;
@ -73,8 +73,8 @@ public interface SessionFactoryImplementor
}
@Override
default MappingMetamodel getDomainModel() {
return getMetamodel();
default MappingMetamodelImplementor getMappingMetamodel() {
return getRuntimeMetamodels().getMappingMetamodel();
}
QueryEngine getQueryEngine();
@ -96,7 +96,7 @@ public interface SessionFactoryImplementor
@Override
StatisticsImplementor getStatistics();
RuntimeMetamodels getRuntimeMetamodels();
RuntimeMetamodelsImplementor getRuntimeMetamodels();
/**
* Access to the ServiceRegistry for this SessionFactory.

View File

@ -56,7 +56,10 @@ public class DefaultEvictEventListener implements EvictEventListener {
throw new IllegalArgumentException( "Could not determine identifier of proxy passed to evict()" );
}
final EntityPersister persister = source.getFactory().getMetamodel().entityPersister(li.getEntityName());
final EntityPersister persister = source.getFactory()
.getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( li.getEntityName() );
final EntityKey key = source.generateEntityKey( id, persister );
persistenceContext.removeProxy( key );
@ -82,7 +85,10 @@ public class DefaultEvictEventListener implements EvictEventListener {
final String entityName = persistenceContext.getSession().guessEntityName( object );
if ( entityName != null ) {
try {
persister = persistenceContext.getSession().getFactory().getMetamodel().entityPersister(entityName);
persister = source.getFactory()
.getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( entityName );
}
catch (Exception ignore) {
}

View File

@ -87,7 +87,11 @@ public class DefaultLoadEventListener implements LoadEventListener {
);
}
else {
return event.getSession().getFactory().getMetamodel().entityPersister( event.getEntityClassName() );
return event.getSession()
.getFactory()
.getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( event.getEntityClassName() );
}
}

View File

@ -103,7 +103,10 @@ public class DefaultPersistEventListener
// entity state again.
// NOTE: entityEntry must be null to get here, so we cannot use any of its values
EntityPersister persister = source.getFactory().getMetamodel().entityPersister(entityName);
final EntityPersister persister = source.getFactory()
.getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( entityName );
if ( persister.getIdentifierGenerator() instanceof ForeignGenerator ) {
if ( LOG.isDebugEnabled() && persister.getIdentifier( entity, source ) != null ) {
LOG.debug( "Resetting entity id attribute to null for foreign generator" );

View File

@ -31,7 +31,7 @@ import org.hibernate.event.spi.RefreshEventListener;
import org.hibernate.internal.CoreLogging;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.loader.ast.spi.CascadingFetchProfile;
import org.hibernate.metamodel.spi.MetamodelImplementor;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.pretty.MessageHelper;
@ -253,10 +253,10 @@ public class DefaultRefreshEventListener implements RefreshEventListener {
throws HibernateException {
final ActionQueue actionQueue = source.getActionQueue();
final SessionFactoryImplementor factory = source.getFactory();
final MetamodelImplementor metamodel = factory.getMetamodel();
final MappingMetamodelImplementor metamodel = factory.getRuntimeMetamodels().getMappingMetamodel();
for ( Type type : types ) {
if ( type.isCollectionType() ) {
CollectionPersister collectionPersister = metamodel.collectionPersister( ( (CollectionType) type ).getRole() );
CollectionPersister collectionPersister = metamodel.getCollectionDescriptor( ( (CollectionType) type ).getRole() );
if ( collectionPersister.hasCache() ) {
final CollectionDataAccess cache = collectionPersister.getCacheAccessStrategy();
final Object ck = cache.generateCacheKey(

View File

@ -35,7 +35,10 @@ public class OnLockVisitor extends ReattachVisitor {
}
final SessionImplementor session = getSession();
final CollectionPersister persister = session.getFactory().getMetamodel().collectionPersister(type.getRole());
final CollectionPersister persister = session.getFactory()
.getRuntimeMetamodels()
.getMappingMetamodel()
.getCollectionDescriptor( type.getRole() );
if ( collection instanceof PersistentCollection ) {
final PersistentCollection<?> persistentCollection = (PersistentCollection<?>) collection;

View File

@ -39,7 +39,10 @@ public class OnReplicateVisitor extends ReattachVisitor {
}
final EventSource session = getSession();
final CollectionPersister persister = session.getFactory().getMetamodel().collectionPersister( type.getRole() );
final CollectionPersister persister = session.getFactory()
.getRuntimeMetamodels()
.getMappingMetamodel()
.getCollectionDescriptor( type.getRole() );
if ( isUpdate ) {
removeCollection( persister, extractCollectionKeyFromOwner( persister ), session );

View File

@ -35,8 +35,12 @@ public class OnUpdateVisitor extends ReattachVisitor {
return null;
}
EventSource session = getSession();
CollectionPersister persister = session.getFactory().getMetamodel().collectionPersister(type.getRole());
final EventSource session = getSession();
final CollectionPersister persister = session.getFactory()
.getRuntimeMetamodels()
.getMappingMetamodel()
.getCollectionDescriptor( type.getRole() );
final Object collectionKey = extractCollectionKeyFromOwner( persister );
if ( ( collection instanceof PersistentCollection ) ) {

View File

@ -61,17 +61,21 @@ public abstract class ProxyVisitor extends AbstractVisitor {
throws HibernateException {
final EventSource session = getSession();
if ( collection.wasInitialized() ) {
CollectionPersister collectionPersister = session.getFactory().getMetamodel().collectionPersister(type.getRole());
session.getPersistenceContext()
.addInitializedDetachedCollection( collectionPersister, collection );
final CollectionPersister persister = session.getFactory()
.getRuntimeMetamodels()
.getMappingMetamodel()
.getCollectionDescriptor( type.getRole() );
session.getPersistenceContext().addInitializedDetachedCollection( persister, collection );
}
else {
if ( !isCollectionSnapshotValid( collection ) ) {
throw new HibernateException( "could not re-associate uninitialized transient collection" );
}
CollectionPersister collectionPersister = session.getFactory().getMetamodel().collectionPersister(collection.getRole());
session.getPersistenceContext()
.addUninitializedDetachedCollection( collectionPersister, collection );
final CollectionPersister persister = session.getFactory()
.getRuntimeMetamodels()
.getMappingMetamodel()
.getCollectionDescriptor( collection.getRole() );
session.getPersistenceContext().addUninitializedDetachedCollection( persister, collection );
}
}

View File

@ -80,7 +80,10 @@ public class WrapVisitor extends ProxyVisitor {
return null;
}
else {
CollectionPersister persister = session.getFactory().getMetamodel().collectionPersister(collectionType.getRole());
final CollectionPersister persister = session.getFactory()
.getRuntimeMetamodels()
.getMappingMetamodel()
.getCollectionDescriptor( collectionType.getRole() );
final PersistenceContext persistenceContext = session.getPersistenceContextInternal();
//TODO: move into collection type, so we can use polymorphism!

View File

@ -80,8 +80,11 @@ public class ForeignGenerator implements StandardGenerator {
@Override
public Object generate(SharedSessionContractImplementor sessionImplementor, Object object) {
final EntityPersister persister = sessionImplementor.getFactory().getMetamodel().entityPersister( entityName );
Object associatedObject = persister.getPropertyValue( object, propertyName );
final EntityPersister entityDescriptor = sessionImplementor.getFactory()
.getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( entityName );
Object associatedObject = entityDescriptor.getPropertyValue( object, propertyName );
if ( associatedObject == null ) {
throw new IdentifierGenerationException(
"attempted to assign id from null one-to-one property [" + getRole() + "]"
@ -89,14 +92,14 @@ public class ForeignGenerator implements StandardGenerator {
}
final EntityType foreignValueSourceType;
final Type propertyType = persister.getPropertyType( propertyName );
final Type propertyType = entityDescriptor.getPropertyType( propertyName );
if ( propertyType.isEntityType() ) {
// the normal case
foreignValueSourceType = (EntityType) propertyType;
}
else {
// try identifier mapper
foreignValueSourceType = (EntityType) persister.getPropertyType( PropertyPath.IDENTIFIER_MAPPER_PROPERTY + "." + propertyName );
foreignValueSourceType = (EntityType) entityDescriptor.getPropertyType( PropertyPath.IDENTIFIER_MAPPER_PROPERTY + "." + propertyName );
}
Object id;

View File

@ -9,6 +9,7 @@ package org.hibernate.internal;
import org.hibernate.EntityNameResolver;
import org.hibernate.Interceptor;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
/**
* @author Steve Ebersole
@ -29,7 +30,8 @@ public class CoordinatingEntityNameResolver implements EntityNameResolver {
return entityName;
}
for ( EntityNameResolver resolver : sessionFactory.getMetamodel().getEntityNameResolvers() ) {
final MappingMetamodelImplementor mappingMetamodel = sessionFactory.getRuntimeMetamodels().getMappingMetamodel();
for ( EntityNameResolver resolver : mappingMetamodel.getEntityNameResolvers() ) {
entityName = resolver.resolveEntityName( entity );
if ( entityName != null ) {
break;

View File

@ -69,16 +69,20 @@ public class FilterConfiguration {
}
private Map<String, String> mergeAliasMaps(SessionFactoryImplementor factory) {
Map<String, String> ret = new HashMap<>();
final Map<String, String> ret = new HashMap<>();
if ( aliasTableMap != null ) {
ret.putAll( aliasTableMap );
}
if ( aliasEntityMap != null ) {
for ( Map.Entry<String, String> entry : aliasEntityMap.entrySet() ) {
Joinable joinable = (Joinable) factory.getMetamodel().entityPersister(entry.getValue());
final Joinable joinable = (Joinable) factory.getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( entry.getValue() );
ret.put( entry.getKey(), joinable.getTableName() );
}
}
return ret;
}
}

View File

@ -91,8 +91,9 @@ import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.RootClass;
import org.hibernate.metadata.ClassMetadata;
import org.hibernate.metadata.CollectionMetadata;
import org.hibernate.metamodel.RuntimeMetamodels;
import org.hibernate.metamodel.internal.RuntimeMetamodelsImpl;
import org.hibernate.metamodel.model.domain.spi.JpaMetamodelImplementor;
import org.hibernate.metamodel.spi.RuntimeMetamodelsImplementor;
import org.hibernate.query.BindableType;
import org.hibernate.metamodel.model.domain.JpaMetamodel;
import org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl;
@ -169,7 +170,7 @@ public class SessionFactoryImpl implements SessionFactoryImplementor {
// todo : org.hibernate.jpa.boot.spi.PersistenceUnitDescriptor too?
private final transient RuntimeMetamodels runtimeMetamodels;
private final transient RuntimeMetamodelsImplementor runtimeMetamodels;
private final PersistenceUnitUtil jpaPersistenceUnitUtil;
private final transient CacheImplementor cacheAccess;
private final transient QueryEngine queryEngine;
@ -564,7 +565,7 @@ public class SessionFactoryImpl implements SessionFactoryImplementor {
@Override
public TypeConfiguration getTypeConfiguration() {
return getMetamodel().getTypeConfiguration();
return runtimeMetamodels.getMappingMetamodel().getTypeConfiguration();
}
@Override
@ -726,10 +727,10 @@ public class SessionFactoryImpl implements SessionFactoryImplementor {
}
public Type getIdentifierType(String className) throws MappingException {
return getMetamodel().entityPersister( className ).getIdentifierType();
return runtimeMetamodels.getMappingMetamodel().getEntityDescriptor( className ).getIdentifierType();
}
public String getIdentifierPropertyName(String className) throws MappingException {
return getMetamodel().entityPersister( className ).getIdentifierPropertyName();
return runtimeMetamodels.getMappingMetamodel().getEntityDescriptor( className ).getIdentifierPropertyName();
}
public ClassMetadata getClassMetadata(@SuppressWarnings("rawtypes") Class persistentClass) throws HibernateException {
@ -737,15 +738,15 @@ public class SessionFactoryImpl implements SessionFactoryImplementor {
}
public CollectionMetadata getCollectionMetadata(String roleName) throws HibernateException {
return (CollectionMetadata) getMetamodel().collectionPersister( roleName );
return (CollectionMetadata) runtimeMetamodels.getMappingMetamodel().getCollectionDescriptor( roleName );
}
public ClassMetadata getClassMetadata(String entityName) throws HibernateException {
return (ClassMetadata) getMetamodel().entityPersister( entityName );
return (ClassMetadata) runtimeMetamodels.getMappingMetamodel().getEntityDescriptor( entityName );
}
public Type getReferencedPropertyType(String className, String propertyName) throws MappingException {
return getMetamodel().entityPersister( className ).getPropertyType( propertyName );
return runtimeMetamodels.getMappingMetamodel().getEntityDescriptor( className ).getPropertyType( propertyName );
}
/**
@ -790,7 +791,7 @@ public class SessionFactoryImpl implements SessionFactoryImplementor {
if ( runtimeMetamodels != null && runtimeMetamodels.getMappingMetamodel() != null ) {
final JdbcConnectionAccess jdbcConnectionAccess = jdbcServices.getBootstrapJdbcConnectionAccess();
runtimeMetamodels.getMappingMetamodel().visitEntityDescriptors(
runtimeMetamodels.getMappingMetamodel().forEachEntityDescriptor(
entityPersister -> {
if ( entityPersister.getSqmMultiTableMutationStrategy() != null ) {
entityPersister.getSqmMultiTableMutationStrategy().release(
@ -930,7 +931,11 @@ public class SessionFactoryImpl implements SessionFactoryImplementor {
return type.cast( cacheAccess );
}
if ( type.isAssignableFrom( JpaMetamodel.class ) ) {
if ( type.isInstance( runtimeMetamodels ) ) {
return type.cast( runtimeMetamodels );
}
if ( type.isInstance( runtimeMetamodels.getJpaMetamodel() ) ) {
return type.cast( runtimeMetamodels.getJpaMetamodel() );
}
@ -1030,13 +1035,13 @@ public class SessionFactoryImpl implements SessionFactoryImplementor {
}
@Override
public RuntimeMetamodels getRuntimeMetamodels() {
public RuntimeMetamodelsImplementor getRuntimeMetamodels() {
return runtimeMetamodels;
}
@Override
public JpaMetamodel getJpaMetamodel() {
public JpaMetamodelImplementor getJpaMetamodel() {
return runtimeMetamodels.getJpaMetamodel();
}
@ -1083,7 +1088,7 @@ public class SessionFactoryImpl implements SessionFactoryImplementor {
@Override
public <T> BindableType<T> resolveParameterBindType(Class<T> javaType) {
return getMetamodel().resolveQueryParameterType( javaType );
return getRuntimeMetamodels().getMappingMetamodel().resolveQueryParameterType( javaType );
}
/**

View File

@ -1011,7 +1011,9 @@ public class SessionImpl
@Override
public Object immediateLoad(String entityName, Object id) throws HibernateException {
if ( log.isDebugEnabled() ) {
EntityPersister persister = getFactory().getMetamodel().entityPersister( entityName );
final EntityPersister persister = getFactory().getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( entityName );
log.debugf( "Initializing proxy: %s", MessageHelper.infoString( persister, id, getFactory() ) );
}
LoadEvent event = loadEvent;
@ -1421,7 +1423,10 @@ public class SessionImpl
@Override
public Object instantiate(String entityName, Object id) throws HibernateException {
return instantiate( getFactory().getMetamodel().entityPersister( entityName ), id );
final EntityPersister persister = getFactory().getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( entityName );
return instantiate( persister, id );
}
/**
@ -1447,7 +1452,9 @@ public class SessionImpl
public EntityPersister getEntityPersister(final String entityName, final Object object) {
checkOpenOrWaitingForAutoClose();
if ( entityName == null ) {
return getFactory().getMetamodel().entityPersister( guessEntityName( object ) );
return getFactory().getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( guessEntityName( object ) );
}
else {
// try block is a hack around fact that currently tuplizers are not
@ -1456,7 +1463,10 @@ public class SessionImpl
// influence this decision if we were not able to based on the
// given entityName
try {
return getFactory().getMetamodel().entityPersister( entityName ).getSubclassEntityPersister( object, getFactory() );
return getFactory().getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( entityName )
.getSubclassEntityPersister( object, getFactory() );
}
catch (HibernateException e) {
try {
@ -1554,7 +1564,9 @@ public class SessionImpl
if ( entityName == null ) {
throw new IllegalArgumentException( "Could not resolve entity-name [" + object + "]" );
}
getSessionFactory().getMetamodel().entityPersister( entityName );
getFactory().getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( entityName );
}
catch (HibernateException e) {
throw new IllegalArgumentException( "Not an entity [" + object.getClass() + "]", e );
@ -1588,7 +1600,9 @@ public class SessionImpl
if ( !HibernateProxy.class.isInstance( object ) && persistenceContext.getEntry( object ) == null ) {
// check if it is an entity -> if not throw an exception (per JPA)
try {
getSessionFactory().getMetamodel().entityPersister( entityName );
getFactory().getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( entityName );
}
catch (HibernateException e) {
throw new IllegalArgumentException( "Not an entity [" + entityName + "] : " + object );
@ -2154,11 +2168,15 @@ public class SessionImpl
}
private EntityPersister requireEntityPersister(Class<?> entityClass) {
return getFactory().getMetamodel().locateEntityPersister( entityClass );
return getFactory().getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( entityClass );
}
private EntityPersister requireEntityPersister(String entityName) {
return getFactory().getMetamodel().locateEntityPersister( entityName );
return getFactory().getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( entityName );
}
@Override

View File

@ -173,8 +173,11 @@ public class StatelessSessionImpl extends AbstractSharedSessionContract implemen
public Object get(String entityName, Object id, LockMode lockMode) {
checkOpen();
Object result = getFactory().getMetamodel().entityPersister( entityName )
.load( id, null, getNullSafeLockMode( lockMode ), this );
final EntityPersister entityDescriptor = getFactory().getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( entityName );
final Object result = entityDescriptor.load( id, null, getNullSafeLockMode( lockMode ), this );
if ( temporaryPersistenceContext.isLoadFinished() ) {
temporaryPersistenceContext.clear();
}
@ -261,7 +264,10 @@ public class StatelessSessionImpl extends AbstractSharedSessionContract implemen
public Object instantiate(
String entityName,
Object id) throws HibernateException {
return instantiate( getFactory().getMetamodel().entityPersister( entityName ), id );
final EntityPersister entityDescriptor = getFactory().getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( entityName );
return instantiate( entityDescriptor, id );
}
@Override
@ -278,8 +284,10 @@ public class StatelessSessionImpl extends AbstractSharedSessionContract implemen
boolean nullable) throws HibernateException {
checkOpen();
final EntityPersister persister = getFactory().getMetamodel().entityPersister( entityName );
final EntityKey entityKey = generateEntityKey( id, persister );
final EntityPersister entityDescriptor = getFactory().getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( entityName );
final EntityKey entityKey = generateEntityKey( id, entityDescriptor );
// first, try to load it from the temp PC associated to this SS
final PersistenceContext persistenceContext = getPersistenceContext();
@ -296,13 +304,13 @@ public class StatelessSessionImpl extends AbstractSharedSessionContract implemen
// first, check to see if we can use "bytecode proxies"
final EntityMetamodel entityMetamodel = persister.getEntityMetamodel();
final EntityMetamodel entityMetamodel = entityDescriptor.getEntityMetamodel();
final BytecodeEnhancementMetadata bytecodeEnhancementMetadata = entityMetamodel.getBytecodeEnhancementMetadata();
if ( bytecodeEnhancementMetadata.isEnhancedForLazyLoading() ) {
// if the entity defines a HibernateProxy factory, see if there is an
// existing proxy associated with the PC - and if so, use it
if ( persister.getRepresentationStrategy().getProxyFactory() != null ) {
if ( entityDescriptor.getRepresentationStrategy().getProxyFactory() != null ) {
final Object proxy = persistenceContext.getProxy( entityKey );
if ( proxy != null ) {
@ -313,7 +321,7 @@ public class StatelessSessionImpl extends AbstractSharedSessionContract implemen
LOG.debug( "Ignoring NO_PROXY to honor laziness" );
}
return persistenceContext.narrowProxy( proxy, persister, entityKey, null );
return persistenceContext.narrowProxy( proxy, entityDescriptor, entityKey, null );
}
// specialized handling for entities with subclasses with a HibernateProxy factory
@ -332,10 +340,10 @@ public class StatelessSessionImpl extends AbstractSharedSessionContract implemen
// The entity will get loaded below.
}
else {
if ( persister.hasProxy() ) {
if ( entityDescriptor.hasProxy() ) {
final Object existingProxy = persistenceContext.getProxy( entityKey );
if ( existingProxy != null ) {
return persistenceContext.narrowProxy( existingProxy, persister, entityKey, null );
return persistenceContext.narrowProxy( existingProxy, entityDescriptor, entityKey, null );
}
else {
return createProxy( entityKey );
@ -412,13 +420,15 @@ public class StatelessSessionImpl extends AbstractSharedSessionContract implemen
else if ( association instanceof PersistentCollection ) {
PersistentCollection<?> persistentCollection = (PersistentCollection<?>) association;
if ( !persistentCollection.wasInitialized() ) {
CollectionPersister persister =
getFactory().getMetamodel().collectionPersister( persistentCollection.getRole() );
final CollectionPersister collectionDescriptor = getFactory().getRuntimeMetamodels()
.getMappingMetamodel()
.getCollectionDescriptor( persistentCollection.getRole() );
Object key = persistentCollection.getKey();
persistenceContext.addUninitializedCollection( persister, persistentCollection, key );
persistenceContext.addUninitializedCollection( collectionDescriptor, persistentCollection, key );
persistentCollection.setCurrentSession(this);
try {
persister.initialize( key, this );
collectionDescriptor.initialize( key, this );
}
finally {
persistentCollection.unsetSession(this);
@ -520,10 +530,15 @@ public class StatelessSessionImpl extends AbstractSharedSessionContract implemen
throws HibernateException {
checkOpen();
if ( entityName == null ) {
return getFactory().getMetamodel().entityPersister( guessEntityName( object ) );
return getFactory().getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( guessEntityName( object ) );
}
else {
return getFactory().getMetamodel().entityPersister( entityName ).getSubclassEntityPersister( object, getFactory() );
return getFactory().getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( entityName )
.getSubclassEntityPersister( object, getFactory() );
}
}

View File

@ -39,8 +39,9 @@ public final class EntityPrinter {
* @return the entity rendered to a string
*/
public String toString(String entityName, Object entity) throws HibernateException {
EntityPersister entityPersister = factory.getMetamodel().entityPersister(entityName);
final EntityPersister entityPersister = factory.getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( entityName );
if ( entityPersister == null || !entityPersister.isInstance( entity ) ) {
return entity.getClass().getName();
}

View File

@ -95,7 +95,9 @@ public class PersistenceUnitUtilImpl implements PersistenceUnitUtil, Serializabl
Class<?> entityClass = Hibernate.getClass( entity );
final EntityPersister persister;
try {
persister = sessionFactory.getMetamodel().entityPersister( entityClass );
persister = sessionFactory.getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( entityClass );
if ( persister == null ) {
throw new IllegalArgumentException( entityClass.getName() + " is not an entity" );
}

View File

@ -141,7 +141,10 @@ public class CacheEntityLoaderHelper {
}
if ( options.isAllowNulls() ) {
final EntityPersister persister = event.getSession()
.getFactory().getMetamodel().entityPersister(keyToLoad.getEntityName());
.getFactory()
.getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( keyToLoad.getEntityName() );
if ( !persister.isInstance( old ) ) {
LOG.debug(
"Load request found matching entity in context, but the matched entity was of an inconsistent return type; returning null"
@ -365,7 +368,9 @@ public class CacheEntityLoaderHelper {
final Object entity;
subclassPersister = factory.getMetamodel().entityPersister(entry.getSubclass());
subclassPersister = factory.getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( entry.getSubclass() );
entity = instanceToLoad == null
? source.instantiate( subclassPersister, entityId )
: instanceToLoad;

View File

@ -9,9 +9,11 @@ package org.hibernate.metamodel;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Stream;
import org.hibernate.Incubating;
import org.hibernate.graph.RootGraph;
import org.hibernate.graph.spi.RootGraphImplementor;
import org.hibernate.metamodel.mapping.MappingModelExpressible;
import org.hibernate.query.BindableType;
import org.hibernate.metamodel.model.domain.EntityDomainType;
@ -63,7 +65,8 @@ public interface MappingMetamodel {
/**
* Visit all entity mapping descriptors defined in the model
*/
void visitEntityDescriptors(Consumer<EntityPersister> action);
void forEachEntityDescriptor(Consumer<EntityPersister> action);
Stream<EntityPersister> streamEntityDescriptors();
/**
* Given a JPA entity domain type, get the associated Hibernate entity descriptor
@ -154,7 +157,8 @@ public interface MappingMetamodel {
/**
* Visit the mapping descriptors for all collections defined in the model
*/
void visitCollectionDescriptors(Consumer<CollectionPersister> action);
void forEachCollectionDescriptor(Consumer<CollectionPersister> action);
Stream<CollectionPersister> streamCollectionDescriptors();
/**
* Get a collection mapping descriptor based on its role
@ -195,8 +199,8 @@ public interface MappingMetamodel {
// JPA entity graphs
RootGraph<?> findNamedGraph(String name);
void visitNamedGraphs(Consumer<RootGraph<?>> action);
<T> void addNamedEntityGraph(String graphName, RootGraphImplementor<T> entityGraph);
void forEachNamedGraph(Consumer<RootGraph<?>> action);
RootGraph<?> defaultGraph(String entityName);
RootGraph<?> defaultGraph(Class entityJavaType);
RootGraph<?> defaultGraph(EntityPersister entityDescriptor);

View File

@ -10,29 +10,29 @@ import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.boot.spi.BootstrapContext;
import org.hibernate.boot.spi.MetadataImplementor;
import org.hibernate.internal.SessionFactoryImpl;
import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.RuntimeMetamodels;
import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart;
import org.hibernate.metamodel.model.domain.JpaMetamodel;
import org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl;
import org.hibernate.metamodel.model.domain.spi.JpaMetamodelImplementor;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.metamodel.spi.RuntimeMetamodelsImplementor;
/**
* @author Steve Ebersole
*/
public class RuntimeMetamodelsImpl implements RuntimeMetamodels {
private JpaMetamodel jpaMetamodel;
private MappingMetamodel mappingMetamodel;
public class RuntimeMetamodelsImpl implements RuntimeMetamodelsImplementor {
private JpaMetamodelImplementor jpaMetamodel;
private MappingMetamodelImplementor mappingMetamodel;
public RuntimeMetamodelsImpl() {
}
@Override
public JpaMetamodel getJpaMetamodel() {
public JpaMetamodelImplementor getJpaMetamodel() {
return jpaMetamodel;
}
@Override
public MappingMetamodel getMappingMetamodel() {
public MappingMetamodelImplementor getMappingMetamodel() {
return mappingMetamodel;
}

View File

@ -151,7 +151,7 @@ public abstract class AbstractDiscriminatorMapping implements EntityDiscriminato
return expressionResolver.resolveSqlSelection(
resolveSqlExpression( navigablePath, jdbcMappingToUse, tableGroup, creationState ),
jdbcMappingToUse.getJavaTypeDescriptor(),
creationState.getCreationContext().getDomainModel().getTypeConfiguration()
creationState.getCreationContext().getSessionFactory().getTypeConfiguration()
);
}
@ -303,7 +303,7 @@ public abstract class AbstractDiscriminatorMapping implements EntityDiscriminato
Function<R,String> subtypeResolver,
BasicType underlyingDiscriminatorType,
final SessionFactoryImplementor sessionFactory) {
final TypeConfiguration typeConfiguration = sessionFactory.getDomainModel().getTypeConfiguration();
final TypeConfiguration typeConfiguration = sessionFactory.getTypeConfiguration();
final JavaTypeRegistry jtdRegistry = typeConfiguration.getJavaTypeRegistry();
final JavaType<Object> domainJtd;

View File

@ -245,7 +245,7 @@ public class BasicAttributeMapping
)
),
valueConverter == null ? getMappedType().getMappedJavaType() : valueConverter.getRelationalJavaType(),
creationState.getSqlAstCreationState().getCreationContext().getDomainModel().getTypeConfiguration()
creationState.getSqlAstCreationState().getCreationContext().getSessionFactory().getTypeConfiguration()
);
}

View File

@ -177,7 +177,7 @@ public class BasicValuedCollectionPart
)
),
getJavaType(),
creationState.getSqlAstCreationState().getCreationContext().getDomainModel().getTypeConfiguration()
creationState.getSqlAstCreationState().getCreationContext().getSessionFactory().getTypeConfiguration()
);
}

View File

@ -106,7 +106,7 @@ public class EntityRowIdMappingImpl implements EntityRowIdMapping, SelectableMap
)
),
rowIdType.getJavaTypeDescriptor(),
sqlAstCreationState.getCreationContext().getDomainModel().getTypeConfiguration()
sqlAstCreationState.getCreationContext().getSessionFactory().getTypeConfiguration()
);
return new BasicResult(

View File

@ -193,7 +193,7 @@ public class EntityVersionMappingImpl implements EntityVersionMapping, FetchOpti
)
),
versionBasicType.getJdbcMapping().getJavaTypeDescriptor(),
sqlAstCreationState.getCreationContext().getDomainModel().getTypeConfiguration()
sqlAstCreationState.getCreationContext().getSessionFactory().getTypeConfiguration()
);
return new BasicFetch<>(
@ -267,7 +267,7 @@ public class EntityVersionMappingImpl implements EntityVersionMapping, FetchOpti
)
),
versionBasicType.getJdbcMapping().getJavaTypeDescriptor(),
sqlAstCreationState.getCreationContext().getDomainModel().getTypeConfiguration()
sqlAstCreationState.getCreationContext().getSessionFactory().getTypeConfiguration()
);
}

View File

@ -193,7 +193,9 @@ public class IdClassEmbeddable extends AbstractEmbeddableMapping implements Iden
@Override
public void setIdentifier(Object entity, Object id, SharedSessionContractImplementor session) {
final SessionFactoryImplementor factory = session.getFactory();
final EntityPersister entityDescriptor = factory.getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( entity.getClass() );
final Object[] propertyValues = new Object[attributeMappings.size()];
virtualIdEmbeddable.forEachAttribute(
(position, virtualIdAttribute) -> {
@ -212,9 +214,10 @@ public class IdClassEmbeddable extends AbstractEmbeddableMapping implements Iden
propertyValues[position] = persistenceContext.getEntity( entityKey );
if ( propertyValues[position] == null ) {
// get the association out of the entity itself
propertyValues[position] = factory.getMetamodel()
.findEntityDescriptor( entity.getClass() )
.getPropertyValue( entity, toOneAttributeMapping.getAttributeName() );
propertyValues[position] = entityDescriptor.getPropertyValue(
entity,
toOneAttributeMapping.getAttributeName()
);
}
}
}

View File

@ -254,6 +254,10 @@ public class NonAggregatedIdentifierMappingImpl extends AbstractCompositeIdentif
final List<AttributeMapping> mappedIdAttributeMappings = identifierValueMapper.getAttributeMappings();
final Object[] propertyValues = new Object[mappedIdAttributeMappings.size()];
final SessionFactoryImplementor factory = session.getFactory();
final EntityPersister entityDescriptor = factory.getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( entity.getClass() );
getEmbeddableTypeDescriptor().forEachAttributeMapping(
(position, attribute) -> {
final AttributeMapping mappedIdAttributeMapping = mappedIdAttributeMappings.get( position );
@ -271,9 +275,10 @@ public class NonAggregatedIdentifierMappingImpl extends AbstractCompositeIdentif
propertyValues[position] = persistenceContext.getEntity( entityKey );
if ( propertyValues[position] == null ) {
// get the association out of the entity itself
propertyValues[position] = factory.getMetamodel()
.findEntityDescriptor( entity.getClass() )
.getPropertyValue( entity, toOneAttributeMapping.getAttributeName() );
propertyValues[position] = entityDescriptor.getPropertyValue(
entity,
toOneAttributeMapping.getAttributeName()
);
}
}
}

View File

@ -251,7 +251,7 @@ public class SimpleForeignKeyDescriptor implements ForeignKeyDescriptor, BasicVa
)
),
selectableMapping.getJdbcMapping().getJavaTypeDescriptor(),
sqlAstCreationState.getCreationContext().getDomainModel().getTypeConfiguration()
sqlAstCreationState.getCreationContext().getSessionFactory().getTypeConfiguration()
);
//noinspection unchecked

View File

@ -23,8 +23,10 @@ import org.hibernate.type.spi.TypeConfiguration;
/**
* Hibernate extension to the JPA {@link jakarta.persistence.metamodel.Metamodel} contract
*
* @author Steve Ebersole
* @see MappingMetamodel
*
* @since 6.0
* @author Steve Ebersole
*/
@Incubating
public interface JpaMetamodel extends jakarta.persistence.metamodel.Metamodel {

View File

@ -24,6 +24,7 @@ import org.hibernate.metamodel.model.domain.JpaMetamodel;
import org.hibernate.metamodel.model.domain.PersistentAttribute;
import org.hibernate.metamodel.model.domain.SingularPersistentAttribute;
import org.hibernate.persister.entity.DiscriminatorMetadata;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.Queryable;
import org.hibernate.query.sqm.SqmPathSource;
import org.hibernate.query.sqm.tree.domain.SqmPath;
@ -59,11 +60,12 @@ public class EntityTypeImpl<J>
this.jpaEntityName = persistentClass.getJpaEntityName();
final Queryable entityPersister = (Queryable) jpaMetamodel.getTypeConfiguration()
final Queryable entityDescriptor = (Queryable) jpaMetamodel.getTypeConfiguration()
.getSessionFactory()
.getMetamodel()
.entityPersister( getHibernateEntityName() );
final DiscriminatorMetadata discriminatorMetadata = entityPersister.getTypeDiscriminatorMetadata();
.getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( getHibernateEntityName() );
final DiscriminatorMetadata discriminatorMetadata = entityDescriptor.getTypeDiscriminatorMetadata();
final DomainType discriminatorType;
if ( discriminatorMetadata != null ) {
discriminatorType = (DomainType) discriminatorMetadata.getResolutionType();
@ -77,7 +79,7 @@ public class EntityTypeImpl<J>
this.discriminatorPathSource = new DiscriminatorSqmPathSource(
discriminatorType,
this,
entityPersister
entityDescriptor
);
}

View File

@ -55,6 +55,7 @@ import org.hibernate.metamodel.model.domain.JpaMetamodel;
import org.hibernate.metamodel.model.domain.ManagedDomainType;
import org.hibernate.metamodel.model.domain.MappedSuperclassDomainType;
import org.hibernate.metamodel.model.domain.PersistentAttribute;
import org.hibernate.metamodel.model.domain.spi.JpaMetamodelImplementor;
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
import org.hibernate.persister.entity.Queryable;
import org.hibernate.query.sqm.tree.domain.SqmPolymorphicRootDescriptor;
@ -64,9 +65,10 @@ import org.hibernate.type.descriptor.java.spi.EntityJavaType;
import org.hibernate.type.spi.TypeConfiguration;
/**
*
* @author Steve Ebersole
*/
public class JpaMetamodelImpl implements JpaMetamodel, Serializable {
public class JpaMetamodelImpl implements JpaMetamodelImplementor, Serializable {
private static final EntityManagerMessageLogger log = HEMLogging.messageLogger( JpaMetamodel.class );
private static final ImportInfo<?> INVALID_IMPORT = new ImportInfo<>( null, null );
@ -430,7 +432,8 @@ public class JpaMetamodelImpl implements JpaMetamodel, Serializable {
if ( superType instanceof EntityDomainType<?>
&& javaType.isAssignableFrom( superType.getJavaType() ) ) {
final Queryable entityPersister = (Queryable) typeConfiguration.getSessionFactory()
.getMetamodel()
.getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( ( (EntityDomainType<?>) superType ).getHibernateEntityName() );
// But only skip adding this type if the parent doesn't require explicit polymorphism
if ( !entityPersister.isExplicitPolymorphism() ) {
@ -438,7 +441,8 @@ public class JpaMetamodelImpl implements JpaMetamodel, Serializable {
}
}
final Queryable entityPersister = (Queryable) typeConfiguration.getSessionFactory()
.getMetamodel()
.getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( entityDomainType.getHibernateEntityName() );
if ( !entityPersister.isExplicitPolymorphism() ) {
matchingDescriptors.add( entityDomainType );

View File

@ -17,6 +17,7 @@ import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Stream;
import jakarta.persistence.metamodel.EmbeddableType;
import jakarta.persistence.metamodel.EntityType;
import jakarta.persistence.metamodel.ManagedType;
@ -50,20 +51,21 @@ import org.hibernate.metamodel.internal.JpaMetaModelPopulationSetting;
import org.hibernate.metamodel.internal.JpaStaticMetaModelPopulationSetting;
import org.hibernate.metamodel.mapping.MappingModelExpressible;
import org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess;
import org.hibernate.query.BindableType;
import org.hibernate.metamodel.model.domain.EmbeddableDomainType;
import org.hibernate.metamodel.model.domain.EntityDomainType;
import org.hibernate.metamodel.model.domain.JpaMetamodel;
import org.hibernate.metamodel.model.domain.ManagedDomainType;
import org.hibernate.metamodel.model.domain.NavigableRole;
import org.hibernate.metamodel.model.domain.TupleType;
import org.hibernate.metamodel.model.domain.spi.JpaMetamodelImplementor;
import org.hibernate.metamodel.spi.EntityRepresentationStrategy;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.metamodel.spi.MetamodelImplementor;
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.Queryable;
import org.hibernate.persister.spi.PersisterFactory;
import org.hibernate.query.BindableType;
import org.hibernate.query.spi.NavigablePath;
import org.hibernate.query.sqm.SqmExpressible;
import org.hibernate.query.sqm.tree.domain.SqmPath;
@ -90,7 +92,7 @@ import static org.hibernate.metamodel.internal.JpaStaticMetaModelPopulationSetti
* @author Emmanuel Bernard
* @author Andrea Boriero
*/
public class MappingMetamodelImpl implements MappingMetamodel, MetamodelImplementor, Serializable {
public class MappingMetamodelImpl implements MappingMetamodelImplementor, MetamodelImplementor, Serializable {
// todo : Integrate EntityManagerLogger into CoreMessageLogger
private static final EntityManagerMessageLogger log = HEMLogging.messageLogger( MappingMetamodelImpl.class );
@ -101,7 +103,7 @@ public class MappingMetamodelImpl implements MappingMetamodel, MetamodelImplemen
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// JpaMetamodel
private final JpaMetamodel jpaMetamodel;
private final JpaMetamodelImplementor jpaMetamodel;
private final Map<Class<?>, String> entityProxyInterfaceMap = new ConcurrentHashMap<>();
@ -163,7 +165,7 @@ public class MappingMetamodelImpl implements MappingMetamodel, MetamodelImplemen
this.jpaMetamodel = new JpaMetamodelImpl( typeConfiguration, sessionFactory.getSessionFactoryOptions().getJpaCompliance() );
}
public JpaMetamodel getJpaMetamodel() {
public JpaMetamodelImplementor getJpaMetamodel() {
return jpaMetamodel;
}
@ -369,10 +371,15 @@ public class MappingMetamodelImpl implements MappingMetamodel, MetamodelImplemen
}
@Override
public void visitEntityDescriptors(Consumer<EntityPersister> action) {
public void forEachEntityDescriptor(Consumer<EntityPersister> action) {
entityPersisterMap.values().forEach( action );
}
@Override
public Stream<EntityPersister> streamEntityDescriptors() {
return entityPersisterMap.values().stream();
}
@Override
public EntityPersister resolveEntityDescriptor(EntityDomainType<?> entityDomainType) {
throw new NotYetImplementedFor6Exception( getClass() );
@ -382,7 +389,7 @@ public class MappingMetamodelImpl implements MappingMetamodel, MetamodelImplemen
public EntityPersister getEntityDescriptor(String entityName) {
final EntityPersister entityPersister = entityPersisterMap.get( entityName );
if ( entityPersister == null ) {
throw new IllegalArgumentException( "Unable to locate persister: " + entityName );
throw new UnknownEntityTypeException( "Unable to locate persister: " + entityName );
}
return entityPersister;
}
@ -423,7 +430,7 @@ public class MappingMetamodelImpl implements MappingMetamodel, MetamodelImplemen
}
if ( entityPersister == null ) {
throw new IllegalArgumentException( "Unable to locate persister: " + entityJavaType.getName() );
throw new UnknownEntityTypeException( "Unable to locate entity descriptor: " + entityJavaType.getName() );
}
return entityPersister;
@ -559,7 +566,7 @@ public class MappingMetamodelImpl implements MappingMetamodel, MetamodelImplemen
@Override
public EntityPersister entityPersister(Class<?> entityClass) {
return entityPersister( entityClass.getName() );
return getEntityDescriptor( entityClass.getName() );
}
@Override
@ -587,10 +594,15 @@ public class MappingMetamodelImpl implements MappingMetamodel, MetamodelImplemen
}
@Override
public void visitCollectionDescriptors(Consumer<CollectionPersister> action) {
public void forEachCollectionDescriptor(Consumer<CollectionPersister> action) {
collectionPersisterMap.values().forEach( action );
}
@Override
public Stream<CollectionPersister> streamCollectionDescriptors() {
return collectionPersisterMap.values().stream();
}
@Override
public CollectionPersister getCollectionDescriptor(String role) {
CollectionPersister collectionPersister = collectionPersisterMap.get( role );
@ -656,7 +668,7 @@ public class MappingMetamodelImpl implements MappingMetamodel, MetamodelImplemen
}
@Override
public void visitNamedGraphs(Consumer<RootGraph<?>> action) {
public void forEachNamedGraph(Consumer<RootGraph<?>> action) {
throw new NotYetImplementedFor6Exception( getClass() );
}
@ -721,7 +733,7 @@ public class MappingMetamodelImpl implements MappingMetamodel, MetamodelImplemen
if ( mappedClass != null && clazz.isAssignableFrom( mappedClass ) ) {
final boolean assignableSuperclass;
if ( checkQueryable.isInherited() ) {
Class<?> mappedSuperclass = entityPersister( checkQueryable.getMappedSuperclass() ).getMappedClass();
Class<?> mappedSuperclass = getEntityDescriptor( checkQueryable.getMappedSuperclass() ).getMappedClass();
assignableSuperclass = clazz.isAssignableFrom( mappedSuperclass );
}
else {

View File

@ -0,0 +1,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
*/
package org.hibernate.metamodel.model.domain.spi;
import org.hibernate.metamodel.model.domain.JpaMetamodel;
/**
* SPI extension of JpaMetamodel
*
* @author Steve Ebersole
*/
public interface JpaMetamodelImplementor extends JpaMetamodel {
}

View File

@ -0,0 +1,38 @@
/*
* 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.metamodel.spi;
import java.util.Collection;
import java.util.Set;
import org.hibernate.EntityNameResolver;
import org.hibernate.metamodel.MappingMetamodel;
/**
* @author Steve Ebersole
*/
public interface MappingMetamodelImplementor extends MappingMetamodel {
/**
* Retrieves a set of all the collection roles in which the given entity is a participant, as either an
* index or an element.
*
* @param entityName The entity name for which to get the collection roles.
*
* @return set of all the collection roles in which the given entityName participates.
*/
Set<String> getCollectionRolesByEntityParticipant(String entityName);
/**
* Access to the EntityNameResolver instance that Hibernate is configured to
* use for determining the entity descriptor from an instance of an entity
*/
Collection<EntityNameResolver> getEntityNameResolvers();
}

View File

@ -9,6 +9,7 @@ package org.hibernate.metamodel.spi;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
import java.util.function.Consumer;
import org.hibernate.EntityNameResolver;
import org.hibernate.MappingException;
@ -23,7 +24,8 @@ import org.hibernate.persister.entity.EntityPersister;
*
* @author Steve Ebersole
*
* @deprecated - Prefer {@link MappingMetamodel}
* @deprecated - Use {@link MappingMetamodel} or {@link org.hibernate.metamodel.model.domain.JpaMetamodel}
* instead. See {@link org.hibernate.metamodel.RuntimeMetamodels}
*/
@Deprecated(since = "6.0")
public interface MetamodelImplementor extends MappingMetamodel, Metamodel {
@ -31,6 +33,10 @@ public interface MetamodelImplementor extends MappingMetamodel, Metamodel {
@Override
SessionFactoryImplementor getSessionFactory();
/**
* @deprecated Use {@link MappingMetamodelImplementor#getEntityNameResolvers} instead
*/
@Deprecated(since = "6.0")
Collection<EntityNameResolver> getEntityNameResolvers();
/**
@ -41,7 +47,10 @@ public interface MetamodelImplementor extends MappingMetamodel, Metamodel {
* @return The entity persister
*
* @throws MappingException Indicates persister for that class could not be found.
*
* @deprecated Use {@link MappingMetamodel#getEntityDescriptor} instead
*/
@Deprecated(since = "6.0")
default EntityPersister entityPersister(Class<?> entityClass) {
return getEntityDescriptor(entityClass);
}
@ -54,7 +63,10 @@ public interface MetamodelImplementor extends MappingMetamodel, Metamodel {
* @return The persister
*
* @throws MappingException Indicates persister could not be found with that name.
*
* @deprecated Use {@link MappingMetamodel#getEntityDescriptor} instead
*/
@Deprecated(since = "6.0")
default EntityPersister entityPersister(String entityName) {
return getEntityDescriptor(entityName);
}
@ -63,7 +75,11 @@ public interface MetamodelImplementor extends MappingMetamodel, Metamodel {
* Get all entity persisters as a Map, which entity name its the key and the persister is the value.
*
* @return The Map contains all entity persisters.
*
* @deprecated With no direct replacement; see {@link MappingMetamodel#forEachEntityDescriptor}
* and {@link MappingMetamodel#streamEntityDescriptors()} instead
*/
@Deprecated(since = "6.0")
Map<String,EntityPersister> entityPersisters();
/**
@ -74,7 +90,10 @@ public interface MetamodelImplementor extends MappingMetamodel, Metamodel {
* @return The persister
*
* @throws MappingException Indicates persister could not be found with that role.
*
* @deprecated Use {@link MappingMetamodel#getCollectionDescriptor} instead
*/
@Deprecated(since = "6.0")
default CollectionPersister collectionPersister(String role) {
return getCollectionDescriptor(role);
}
@ -83,7 +102,11 @@ public interface MetamodelImplementor extends MappingMetamodel, Metamodel {
* Get all collection persisters as a Map, which collection role as the key and the persister is the value.
*
* @return The Map contains all collection persisters.
*
* @deprecated With no direct replacement; see {@link MappingMetamodel#forEachCollectionDescriptor}
* and {@link MappingMetamodel#streamCollectionDescriptors()} instead
*/
@Deprecated(since = "6.0")
Map<String,CollectionPersister> collectionPersisters();
/**
@ -93,7 +116,11 @@ public interface MetamodelImplementor extends MappingMetamodel, Metamodel {
* @param entityName The entity name for which to get the collection roles.
*
* @return set of all the collection roles in which the given entityName participates.
*
* @deprecated Use {@link MappingMetamodelImplementor#getCollectionRolesByEntityParticipant}
* and {@link MappingMetamodel#streamCollectionDescriptors()} instead
*/
@Deprecated(since = "6.0")
Set<String> getCollectionRolesByEntityParticipant(String entityName);
/**

View File

@ -0,0 +1,21 @@
/*
* 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.metamodel.spi;
import org.hibernate.metamodel.RuntimeMetamodels;
import org.hibernate.metamodel.model.domain.spi.JpaMetamodelImplementor;
/**
* @author Steve Ebersole
*/
public interface RuntimeMetamodelsImplementor extends RuntimeMetamodels {
@Override
MappingMetamodelImplementor getMappingMetamodel();
@Override
JpaMetamodelImplementor getJpaMetamodel();
}

View File

@ -1542,7 +1542,9 @@ public abstract class AbstractEntityPersister
// we have a condition where a collection attribute is being access via enhancement:
// we can circumvent all the rest and just return the PersistentCollection
final CollectionType collectionType = (CollectionType) type;
final CollectionPersister persister = factory.getMetamodel().collectionPersister( collectionType.getRole() );
final CollectionPersister persister = factory.getRuntimeMetamodels()
.getMappingMetamodel()
.getCollectionDescriptor( collectionType.getRole() );
// Get/create the collection, and make sure it is initialized! This initialized part is
// different from proxy-based scenarios where we have to create the PersistentCollection
@ -6639,7 +6641,9 @@ public abstract class AbstractEntityPersister
continue;
}
try {
final EntityPersister subClassEntityPersister = factory.getMetamodel().getEntityDescriptor( subClassEntityName );
final EntityPersister subClassEntityPersister = factory.getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( subClassEntityName );
collectAttributeDefinitions( attributeDefinitionsByName, subClassEntityPersister.getEntityMetamodel() );
}
catch (MappingException e) {

View File

@ -133,25 +133,31 @@ public class DiscriminatorType<T> extends AbstractType implements BasicType<T>,
Object value,
int index,
SharedSessionContractImplementor session) throws HibernateException, SQLException {
String entityName = session.getFactory().getClassMetadata((Class<?>) value).getEntityName();
Loadable entityPersister = (Loadable) session.getFactory().getMetamodel().entityPersister(entityName);
underlyingType.nullSafeSet(st, entityPersister.getDiscriminatorValue(), index, session);
final Loadable loadable = (Loadable) session.getFactory()
.getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( (Class<?>) value );
underlyingType.nullSafeSet(st, loadable.getDiscriminatorValue(), index, session);
}
@Override
public void bind(PreparedStatement st, T value, int index, WrapperOptions options) throws SQLException {
final SessionFactoryImplementor factory = options.getSession().getFactory();
final String entityName = factory.getClassMetadata( (Class<?>) value).getEntityName();
final Loadable entityPersister = (Loadable) factory.getMetamodel().entityPersister(entityName);
underlyingType.getJdbcValueBinder().bind( st, entityPersister.getDiscriminatorValue(), index, options );
final Loadable loadable = (Loadable) factory
.getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( (Class<?>) value );
underlyingType.getJdbcValueBinder().bind( st, loadable.getDiscriminatorValue(), index, options );
}
@Override
public void bind(CallableStatement st, T value, String name, WrapperOptions options) throws SQLException {
final SessionFactoryImplementor factory = options.getSession().getFactory();
final String entityName = factory.getClassMetadata( (Class<?>) value).getEntityName();
final Loadable entityPersister = (Loadable) factory.getMetamodel().entityPersister(entityName);
underlyingType.getJdbcValueBinder().bind( st, entityPersister.getDiscriminatorValue(), name, options );
final Loadable loadable = (Loadable) factory
.getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( (Class<?>) value );
underlyingType.getJdbcValueBinder().bind( st, loadable.getDiscriminatorValue(), name, options );
}
@Override

View File

@ -636,7 +636,10 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
private String[] decodeTreatAsRequests(Set<String> treatAsDeclarations) {
final List<String> values = new ArrayList<>();
for ( String subclass : treatAsDeclarations ) {
final Queryable queryable = (Queryable) getFactory().getMetamodel().entityPersister( subclass );
final Queryable queryable = (Queryable) getFactory()
.getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( subclass );
if ( !queryable.isAbstract() ) {
values.add( queryable.getDiscriminatorSQLValue() );
}
@ -649,7 +652,10 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
continue;
}
Queryable actualQueryable = (Queryable) getFactory().getMetamodel().entityPersister( actualSubClass );
final Queryable actualQueryable = (Queryable) getFactory()
.getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( actualSubClass );
if ( !actualQueryable.hasSubclasses() ) {
values.add( actualQueryable.getDiscriminatorSQLValue() );
}
@ -667,7 +673,9 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
// first access; build it
final List<String> values = new ArrayList<>();
for ( String subclass : getSubclassClosure() ) {
final Queryable queryable = (Queryable) getFactory().getMetamodel().entityPersister( subclass );
final Queryable queryable = (Queryable) getFactory().getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( subclass );
if ( !queryable.isAbstract() ) {
values.add( queryable.getDiscriminatorSQLValue() );
}
@ -686,7 +694,9 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
// first access; build it
final List<Object> values = new ArrayList<>();
for ( String subclass : getSubclassClosure() ) {
final Queryable queryable = (Queryable) getFactory().getMetamodel().entityPersister( subclass );
final Queryable queryable = (Queryable) getFactory().getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( subclass );
if ( !queryable.isAbstract() ) {
values.add( queryable.getDiscriminatorValue() );
}
@ -744,7 +754,9 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
concreteEntityPersister = this;
}
else {
concreteEntityPersister = getFactory().getMetamodel().entityPersister( entityName );
concreteEntityPersister = getFactory().getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( entityName );
}
Type type = concreteEntityPersister.getPropertyType( propertyName );
if ( type.isAssociationType() && ( (AssociationType) type ).useLHSPrimaryKey() ) {

View File

@ -58,11 +58,9 @@ public class FunctionReturnImpl<T> implements FunctionReturnImplementor<T> {
parameterExtractor = null;
}
else {
final TypeConfiguration typeConfiguration = persistenceContext.getFactory().getMetamodel().getTypeConfiguration();
final JdbcType sqlTypeDescriptor = typeConfiguration.getJdbcTypeRegistry()
.getDescriptor( getJdbcTypeCode() );
final BasicJavaType<?> javaTypeMapping = sqlTypeDescriptor
.getJdbcRecommendedJavaTypeMapping( null, null, typeConfiguration );
final TypeConfiguration typeConfiguration = persistenceContext.getFactory().getTypeConfiguration();
final JdbcType sqlTypeDescriptor = typeConfiguration.getJdbcTypeRegistry().getDescriptor( getJdbcTypeCode() );
final BasicJavaType<?> javaTypeMapping = sqlTypeDescriptor.getJdbcRecommendedJavaTypeMapping( null, null, typeConfiguration );
//noinspection unchecked
ormType = (BindableType<T>) typeConfiguration.standardBasicTypeForJavaType( javaTypeMapping.getJavaTypeClass() );
parameterExtractor = new JdbcCallParameterExtractorImpl<>( procedureCall.getProcedureName(), null, 1, ormType );

View File

@ -33,6 +33,7 @@ import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.Queryable;
import org.hibernate.procedure.NoSuchParameterException;
import org.hibernate.procedure.ParameterStrategyException;
import org.hibernate.procedure.ProcedureCall;
@ -456,9 +457,7 @@ public class ProcedureCallImpl<R>
@Override
public <T> ProcedureParameter<T> registerParameter(int position, Class<T> javaType, ParameterMode mode) {
final BindableType<T> parameterType = getSessionFactory()
.getDomainModel()
.resolveQueryParameterType( javaType );
final BindableType<T> parameterType = getSessionFactory().resolveParameterBindType( javaType );
final Class<T> expressibleJavaType;
if ( parameterType == null ) {
@ -511,9 +510,8 @@ public class ProcedureCallImpl<R>
@Override
public <T> ProcedureParameterImplementor<T> registerParameter(String name, Class<T> javaType, ParameterMode mode) {
final BindableType<T> parameterType = getSessionFactory().getDomainModel().resolveQueryParameterType(
javaType
);
final BindableType<T> parameterType = getSessionFactory().resolveParameterBindType( javaType );
final ProcedureParameterImpl<T> parameter = new ProcedureParameterImpl<>(
name,
mode,
@ -745,7 +743,10 @@ public class ProcedureCallImpl<R>
@Override
public ProcedureCallImplementor<R> addSynchronizedEntityName(String entityName) {
addSynchronizedQuerySpaces( getSession().getFactory().getMetamodel().entityPersister( entityName ) );
final EntityPersister entityDescriptor = getSession().getFactory().getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( entityName );
addSynchronizedQuerySpaces( entityDescriptor );
return this;
}
@ -755,7 +756,10 @@ public class ProcedureCallImpl<R>
@Override
public ProcedureCallImplementor<R> addSynchronizedEntityClass(@SuppressWarnings("rawtypes") Class entityClass) {
addSynchronizedQuerySpaces( getSession().getFactory().getMetamodel().entityPersister( entityClass.getName() ) );
final EntityPersister entityDescriptor = getSession().getFactory().getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( entityClass );
addSynchronizedQuerySpaces( entityDescriptor );
return this;
}

View File

@ -9,7 +9,7 @@ package org.hibernate.procedure.internal;
import java.util.function.Consumer;
import org.hibernate.internal.util.collections.ArrayHelper;
import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.query.internal.ResultSetMappingResolutionContext;
import org.hibernate.query.named.NamedObjectRepository;
@ -70,11 +70,11 @@ public class Util {
ResultSetMapping resultSetMapping,
Consumer<String> querySpaceConsumer,
ResultSetMappingResolutionContext context) {
final MappingMetamodel domainModel = context.getSessionFactory().getDomainModel();
final JavaTypeRegistry javaTypeRegistry = domainModel.getTypeConfiguration().getJavaTypeRegistry();
final MappingMetamodelImplementor mappingMetamodel = context.getSessionFactory().getRuntimeMetamodels().getMappingMetamodel();
final JavaTypeRegistry javaTypeRegistry = mappingMetamodel.getTypeConfiguration().getJavaTypeRegistry();
for ( Class<?> resultSetMappingClass : resultSetMappingClasses ) {
final EntityPersister entityDescriptor = domainModel.findEntityDescriptor( resultSetMappingClass );
final EntityPersister entityDescriptor = mappingMetamodel.findEntityDescriptor( resultSetMappingClass );
if ( entityDescriptor != null ) {
resultSetMapping.addResultBuilder( new EntityDomainResultBuilder( entityDescriptor ) );
for ( String querySpace : entityDescriptor.getSynchronizedQuerySpaces() ) {

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