mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-03-01 15:29:11 +00:00
6 - SQM based on JPA type system
Completed rebase on master (from the point just after HHH-11147 work) - fixed compilation failures
This commit is contained in:
parent
a4fa6430f3
commit
0acd11fae3
@ -9,13 +9,11 @@
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Currency;
|
||||
import java.util.Locale;
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Embedded;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
|
||||
import org.hibernate.annotations.ColumnTransformer;
|
||||
import org.hibernate.annotations.Columns;
|
||||
import org.hibernate.annotations.Type;
|
||||
import org.hibernate.dialect.H2Dialect;
|
||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||
|
||||
@ -63,11 +61,7 @@ public static class Savings {
|
||||
@Id
|
||||
private Long id;
|
||||
|
||||
@Type(type = "org.hibernate.userguide.mapping.basic.MonetaryAmountUserType")
|
||||
@Columns(columns = {
|
||||
@Column(name = "money"),
|
||||
@Column(name = "currency")
|
||||
})
|
||||
@Embedded
|
||||
@ColumnTransformer(
|
||||
forColumn = "money",
|
||||
read = "money / 100",
|
||||
|
@ -1,113 +0,0 @@
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
//$Id$
|
||||
package org.hibernate.userguide.mapping.basic;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Currency;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
import org.hibernate.type.Type;
|
||||
import org.hibernate.usertype.CompositeUserType;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
public class MonetaryAmountUserType implements CompositeUserType {
|
||||
|
||||
public String[] getPropertyNames() {
|
||||
return new String[]{"amount", "currency"};
|
||||
}
|
||||
|
||||
public Type[] getPropertyTypes() {
|
||||
return new Type[]{ StandardBasicTypes.BIG_DECIMAL, StandardBasicTypes.CURRENCY };
|
||||
}
|
||||
|
||||
public Object getPropertyValue(Object component, int property) throws HibernateException {
|
||||
MonetaryAmount ma = (MonetaryAmount) component;
|
||||
return property == 0 ? ma.getAmount() : ma.getCurrency();
|
||||
}
|
||||
|
||||
public void setPropertyValue(Object component, int property, Object value)
|
||||
throws HibernateException {
|
||||
MonetaryAmount ma = (MonetaryAmount) component;
|
||||
if ( property == 0 ) {
|
||||
ma.setAmount( (BigDecimal) value );
|
||||
}
|
||||
else {
|
||||
ma.setCurrency( (Currency) value );
|
||||
}
|
||||
}
|
||||
|
||||
public Class returnedClass() {
|
||||
return String.class;
|
||||
}
|
||||
|
||||
public boolean equals(Object x, Object y) throws HibernateException {
|
||||
if ( x == y ) return true;
|
||||
if ( x == null || y == null ) return false;
|
||||
MonetaryAmount mx = (MonetaryAmount) x;
|
||||
MonetaryAmount my = (MonetaryAmount) y;
|
||||
return mx.getAmount().equals( my.getAmount() ) &&
|
||||
mx.getCurrency().equals( my.getCurrency() );
|
||||
}
|
||||
|
||||
public int hashCode(Object x) throws HibernateException {
|
||||
return ( (MonetaryAmount) x ).getAmount().hashCode();
|
||||
}
|
||||
|
||||
public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner)
|
||||
throws HibernateException, SQLException {
|
||||
BigDecimal amt = StandardBasicTypes.BIG_DECIMAL.nullSafeGet( rs, names[0], session);
|
||||
Currency cur = StandardBasicTypes.CURRENCY.nullSafeGet( rs, names[1], session );
|
||||
if ( amt == null ) return null;
|
||||
return new MonetaryAmount( amt, cur );
|
||||
}
|
||||
|
||||
public void nullSafeSet(
|
||||
PreparedStatement st, Object value, int index,
|
||||
SharedSessionContractImplementor session
|
||||
) throws HibernateException, SQLException {
|
||||
MonetaryAmount ma = (MonetaryAmount) value;
|
||||
BigDecimal amt = ma == null ? null : ma.getAmount();
|
||||
Currency cur = ma == null ? null : ma.getCurrency();
|
||||
StandardBasicTypes.BIG_DECIMAL.nullSafeSet( st, amt, index, session );
|
||||
StandardBasicTypes.CURRENCY.nullSafeSet( st, cur, index + 1, session );
|
||||
}
|
||||
|
||||
public Object deepCopy(Object value) throws HibernateException {
|
||||
MonetaryAmount ma = (MonetaryAmount) value;
|
||||
return new MonetaryAmount( ma.getAmount(), ma.getCurrency() );
|
||||
}
|
||||
|
||||
public boolean isMutable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public Serializable disassemble(Object value, SharedSessionContractImplementor session)
|
||||
throws HibernateException {
|
||||
return (Serializable) deepCopy( value );
|
||||
}
|
||||
|
||||
public Object assemble(Serializable cached, SharedSessionContractImplementor session, Object owner)
|
||||
throws HibernateException {
|
||||
return deepCopy( cached );
|
||||
}
|
||||
|
||||
public Object replace(Object original, Object target, SharedSessionContractImplementor session, Object owner)
|
||||
throws HibernateException {
|
||||
return deepCopy( original ); //TODO: improve
|
||||
}
|
||||
|
||||
}
|
@ -1041,15 +1041,6 @@ default <T> List<EntityGraph<? super T>> getEntityGraphs(Class<T> entityClass) {
|
||||
*/
|
||||
void disableFetchProfile(String name) throws UnknownProfileException;
|
||||
|
||||
/**
|
||||
* Convenience access to the {@link TypeHelper} associated with this session's {@link SessionFactory}.
|
||||
* <p/>
|
||||
* Equivalent to calling {@link #getSessionFactory()}.{@link SessionFactory#getTypeHelper getTypeHelper()}
|
||||
*
|
||||
* @return The {@link TypeHelper} associated with this session's {@link SessionFactory}
|
||||
*/
|
||||
TypeHelper getTypeHelper();
|
||||
|
||||
/**
|
||||
* Retrieve this session's helper/delegate for creating LOB instances.
|
||||
*
|
||||
|
@ -268,13 +268,6 @@ default <R> R fromTransaction(Function<Session,R> action) {
|
||||
*/
|
||||
boolean containsFetchProfileDefinition(String name);
|
||||
|
||||
/**
|
||||
* Retrieve this factory's {@link TypeHelper}.
|
||||
*
|
||||
* @return The factory's {@link TypeHelper}
|
||||
*/
|
||||
TypeHelper getTypeHelper();
|
||||
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Deprecations
|
||||
|
@ -1,109 +0,0 @@
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.hibernate.type.BasicType;
|
||||
import org.hibernate.type.Type;
|
||||
|
||||
/**
|
||||
* Provides access to the various {@link Type} instances associated with the {@link SessionFactory}.
|
||||
* <p/>
|
||||
* This is intended for use by application developers.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface TypeHelper {
|
||||
// todo : deprecate all these BasicType methods with overloaded forms taking:
|
||||
// * Java type
|
||||
// * Converter
|
||||
// * Java type + sql-type indicator (type code/SqlTypeDescriptor)
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve the basic type registered against the given name.
|
||||
*
|
||||
* @param name The name of the basic type to retrieve
|
||||
*
|
||||
* @return The basic type, or null.
|
||||
*/
|
||||
public BasicType basic(String name);
|
||||
|
||||
/**
|
||||
* Convenience form of {@link #basic(String)}. The intended use of this is something like
|
||||
* {@code basic(Integer.class)} or {@code basic(int.class)}
|
||||
*
|
||||
* @param javaType The java type for which to retrieve the type instance.
|
||||
*
|
||||
* @return The basic type, or null.
|
||||
*/
|
||||
public BasicType basic(Class javaType);
|
||||
|
||||
/**
|
||||
* Uses heuristics to deduce the proper {@link Type} given a string naming the type or Java class.
|
||||
* <p/>
|
||||
* See {@link org.hibernate.type.TypeResolver#heuristicType(java.lang.String)} for a discussion of the
|
||||
* heuristic algorithm.
|
||||
*
|
||||
* @param name The name of the type or Java class
|
||||
*
|
||||
* @return The deduced type, or null.
|
||||
*
|
||||
* @see org.hibernate.type.TypeResolver#heuristicType(java.lang.String)
|
||||
*/
|
||||
public Type heuristicType(String name);
|
||||
|
||||
/**
|
||||
* Retrieve a type representing the given entity.
|
||||
*
|
||||
* @param entityClass The entity Java type.
|
||||
*
|
||||
* @return The type, or null
|
||||
*/
|
||||
public Type entity(Class entityClass);
|
||||
|
||||
/**
|
||||
* Retrieve a type representing the given entity.
|
||||
*
|
||||
* @param entityName The entity name.
|
||||
*
|
||||
* @return The type, or null
|
||||
*/
|
||||
public Type entity(String entityName);
|
||||
|
||||
/**
|
||||
* Retrieve the type for the given user-type class ({@link org.hibernate.usertype.UserType} or
|
||||
* {@link org.hibernate.usertype.CompositeUserType}).
|
||||
*
|
||||
* @param userTypeClass The user type class
|
||||
*
|
||||
* @return The type, or null
|
||||
*/
|
||||
public Type custom(Class userTypeClass);
|
||||
|
||||
/**
|
||||
* Retrieve the type for the given user-type class ({@link org.hibernate.usertype.UserType} or
|
||||
* {@link org.hibernate.usertype.CompositeUserType}).
|
||||
*
|
||||
* @param userTypeClass The user type class
|
||||
* @param properties Configuration properties.
|
||||
*
|
||||
* @return The type, or null
|
||||
*/
|
||||
public Type custom(Class userTypeClass, Properties properties);
|
||||
|
||||
/**
|
||||
* Retrieve the type representing an ANY mapping.
|
||||
*
|
||||
* @param metaType The meta type for the ANY
|
||||
* @param identifierType The identifier type for the ANY
|
||||
*
|
||||
* @return The type, or null
|
||||
*/
|
||||
public Type any(Type metaType, Type identifierType);
|
||||
}
|
@ -25,9 +25,12 @@
|
||||
String name();
|
||||
|
||||
/**
|
||||
* The type being defined, Typically this is the fully-qualified name of the {@link org.hibernate.type.Type},
|
||||
* {@link org.hibernate.usertype.UserType} or {@link org.hibernate.usertype.CompositeUserType} implementation
|
||||
* class.
|
||||
* The type to be used for the parameter. See {@link Type#type} for a list of
|
||||
* expected values
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
String type();
|
||||
}
|
||||
|
@ -18,7 +18,6 @@
|
||||
*
|
||||
* @see org.hibernate.type.Type
|
||||
* @see org.hibernate.usertype.UserType
|
||||
* @see org.hibernate.usertype.CompositeUserType
|
||||
*
|
||||
* @see TypeDef
|
||||
*
|
||||
@ -29,10 +28,12 @@
|
||||
@Retention(RUNTIME)
|
||||
public @interface Type {
|
||||
/**
|
||||
* The Hibernate type name. Usually the fully qualified name of an implementation class for
|
||||
* {@link org.hibernate.type.Type}, {@link org.hibernate.usertype.UserType} or
|
||||
* {@link org.hibernate.usertype.CompositeUserType}. May also refer to a type definition by name
|
||||
* {@link TypeDef#name()}
|
||||
* The Hibernate type name. This should be one of: <ul>
|
||||
* <li>Registration key for a basic type (see {@link org.hibernate.type.BasicTypeRegistry)}</li>
|
||||
* <li>Type-definition name (see {@link TypeDef#name()})</li>
|
||||
* <li>FQN for a {@link org.hibernate.type.Type} implementation class</li>
|
||||
* <li>FQN for a {@link org.hibernate.usertype.UserType} implementation class</li>
|
||||
* </ul>
|
||||
*/
|
||||
String type();
|
||||
|
||||
|
@ -22,7 +22,6 @@
|
||||
*
|
||||
* @see org.hibernate.type.Type
|
||||
* @see org.hibernate.usertype.UserType
|
||||
* @see org.hibernate.usertype.CompositeUserType
|
||||
*
|
||||
* @see Type
|
||||
*
|
||||
@ -39,7 +38,8 @@
|
||||
String name() default "";
|
||||
|
||||
/**
|
||||
* The type implementation class.
|
||||
* The FQN for the {@link org.hibernate.type.Type} or {@link org.hibernate.usertype.UserType}
|
||||
* implementation class
|
||||
*/
|
||||
Class<?> typeClass();
|
||||
|
||||
|
@ -9,13 +9,13 @@
|
||||
import javax.persistence.AttributeConverter;
|
||||
import javax.persistence.SharedCacheMode;
|
||||
|
||||
import org.hibernate.annotations.common.reflection.ReflectionManager;
|
||||
import org.hibernate.boot.archive.scan.spi.ScanEnvironment;
|
||||
import org.hibernate.boot.archive.scan.spi.ScanOptions;
|
||||
import org.hibernate.boot.archive.scan.spi.Scanner;
|
||||
import org.hibernate.boot.archive.spi.ArchiveDescriptorFactory;
|
||||
import org.hibernate.boot.model.IdGeneratorStrategyInterpreter;
|
||||
import org.hibernate.boot.model.TypeContributor;
|
||||
import org.hibernate.boot.model.convert.spi.ConverterDescriptor;
|
||||
import org.hibernate.boot.model.naming.ImplicitNamingStrategy;
|
||||
import org.hibernate.boot.model.naming.PhysicalNamingStrategy;
|
||||
import org.hibernate.boot.model.relational.AuxiliaryDatabaseObject;
|
||||
@ -24,7 +24,6 @@
|
||||
import org.hibernate.cfg.MetadataSourceType;
|
||||
import org.hibernate.dialect.function.SQLFunction;
|
||||
import org.hibernate.type.BasicType;
|
||||
import org.hibernate.usertype.CompositeUserType;
|
||||
import org.hibernate.usertype.UserType;
|
||||
|
||||
import org.jboss.jandex.IndexView;
|
||||
@ -315,16 +314,6 @@ public interface MetadataBuilder {
|
||||
*/
|
||||
MetadataBuilder applyBasicType(UserType type, String... keys);
|
||||
|
||||
/**
|
||||
* Register an additional or overridden composite custom type mapping.
|
||||
*
|
||||
* @param type The composite custom type
|
||||
* @param keys The keys under which to register the composite custom type.
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
MetadataBuilder applyBasicType(CompositeUserType type, String... keys);
|
||||
|
||||
/**
|
||||
* Apply an explicit TypeContributor (implicit application via ServiceLoader will still happen too)
|
||||
*
|
||||
@ -388,18 +377,8 @@ public interface MetadataBuilder {
|
||||
*
|
||||
* @return {@code this} for method chaining
|
||||
*
|
||||
* @deprecated (since 5.3) AttributeConverterDefinition forces early
|
||||
* access to the AttributeConverter instance which precludes the
|
||||
* possibility to resolve the converter from CDI, etc. Instead use
|
||||
* one of:
|
||||
*
|
||||
* * {@link #applyAttributeConverter(Class)}
|
||||
* * {@link #applyAttributeConverter(Class, boolean)}
|
||||
* * {@link #applyAttributeConverter(AttributeConverter)}
|
||||
* * {@link #applyAttributeConverter(AttributeConverter, boolean)}
|
||||
*/
|
||||
@Deprecated
|
||||
MetadataBuilder applyAttributeConverter(AttributeConverterDefinition definition);
|
||||
MetadataBuilder applyAttributeConverter(ConverterDescriptor definition);
|
||||
|
||||
/**
|
||||
* Adds an AttributeConverter by its Class.
|
||||
@ -408,7 +387,7 @@ public interface MetadataBuilder {
|
||||
*
|
||||
* @return {@code this} for method chaining
|
||||
*/
|
||||
MetadataBuilder applyAttributeConverter(Class<? extends AttributeConverter> attributeConverterClass);
|
||||
<O,R> MetadataBuilder applyAttributeConverter(Class<? extends AttributeConverter<O,R>> attributeConverterClass);
|
||||
|
||||
/**
|
||||
* Adds an AttributeConverter by its Class plus a boolean indicating whether to auto apply it.
|
||||
@ -418,10 +397,8 @@ public interface MetadataBuilder {
|
||||
* by its "entity attribute" parameterized type?
|
||||
*
|
||||
* @return {@code this} for method chaining
|
||||
*
|
||||
* @see org.hibernate.cfg.AttributeConverterDefinition#from(Class, boolean)
|
||||
*/
|
||||
MetadataBuilder applyAttributeConverter(Class<? extends AttributeConverter> attributeConverterClass, boolean autoApply);
|
||||
<O,R> MetadataBuilder applyAttributeConverter(Class<? extends AttributeConverter<O,R>> attributeConverterClass, boolean autoApply);
|
||||
|
||||
/**
|
||||
* Adds an AttributeConverter instance.
|
||||
@ -429,10 +406,8 @@ public interface MetadataBuilder {
|
||||
* @param attributeConverter The AttributeConverter instance.
|
||||
*
|
||||
* @return {@code this} for method chaining
|
||||
*
|
||||
* @see org.hibernate.cfg.AttributeConverterDefinition#from(AttributeConverter)
|
||||
*/
|
||||
MetadataBuilder applyAttributeConverter(AttributeConverter attributeConverter);
|
||||
<O,R> MetadataBuilder applyAttributeConverter(AttributeConverter<O,R> attributeConverter);
|
||||
|
||||
/**
|
||||
* Adds an AttributeConverter instance, explicitly indicating whether to auto-apply.
|
||||
@ -442,8 +417,6 @@ public interface MetadataBuilder {
|
||||
* by its "entity attribute" parameterized type?
|
||||
*
|
||||
* @return {@code this} for method chaining
|
||||
*
|
||||
* @see org.hibernate.cfg.AttributeConverterDefinition#from(AttributeConverter, boolean)
|
||||
*/
|
||||
MetadataBuilder applyAttributeConverter(AttributeConverter attributeConverter, boolean autoApply);
|
||||
|
||||
|
@ -18,13 +18,13 @@
|
||||
import org.hibernate.annotations.common.reflection.ReflectionManager;
|
||||
import org.hibernate.annotations.common.reflection.java.JavaReflectionManager;
|
||||
import org.hibernate.annotations.common.util.StandardClassLoaderDelegateImpl;
|
||||
import org.hibernate.boot.AttributeConverterInfo;
|
||||
import org.hibernate.boot.CacheRegionDefinition;
|
||||
import org.hibernate.boot.archive.scan.internal.StandardScanOptions;
|
||||
import org.hibernate.boot.archive.scan.spi.ScanEnvironment;
|
||||
import org.hibernate.boot.archive.scan.spi.ScanOptions;
|
||||
import org.hibernate.boot.archive.scan.spi.Scanner;
|
||||
import org.hibernate.boot.archive.spi.ArchiveDescriptorFactory;
|
||||
import org.hibernate.boot.model.convert.spi.ConverterDescriptor;
|
||||
import org.hibernate.boot.model.relational.AuxiliaryDatabaseObject;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||
@ -74,7 +74,7 @@ public class BootstrapContextImpl implements BootstrapContext {
|
||||
|
||||
private HashMap<String,SQLFunction> sqlFunctionMap;
|
||||
private ArrayList<AuxiliaryDatabaseObject> auxiliaryDatabaseObjectList;
|
||||
private HashMap<Class,AttributeConverterInfo> attributeConverterInfoMap;
|
||||
private HashMap<Class, ConverterDescriptor> attributeConverterDescriptorMap;
|
||||
private ArrayList<CacheRegionDefinition> cacheRegionDefinitions;
|
||||
|
||||
public BootstrapContextImpl(
|
||||
@ -198,9 +198,9 @@ public Collection<AuxiliaryDatabaseObject> getAuxiliaryDatabaseObjectList() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<AttributeConverterInfo> getAttributeConverters() {
|
||||
return attributeConverterInfoMap != null
|
||||
? new ArrayList<>( attributeConverterInfoMap.values() )
|
||||
public Collection<ConverterDescriptor> getAttributeConverters() {
|
||||
return attributeConverterDescriptorMap != null
|
||||
? attributeConverterDescriptorMap.values()
|
||||
: Collections.emptyList();
|
||||
}
|
||||
|
||||
@ -228,8 +228,8 @@ public void release() {
|
||||
auxiliaryDatabaseObjectList.clear();
|
||||
}
|
||||
|
||||
if ( attributeConverterInfoMap != null ) {
|
||||
attributeConverterInfoMap.clear();
|
||||
if ( attributeConverterDescriptorMap != null ) {
|
||||
attributeConverterDescriptorMap.clear();
|
||||
}
|
||||
|
||||
if ( cacheRegionDefinitions != null ) {
|
||||
@ -240,19 +240,18 @@ public void release() {
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Mutations
|
||||
|
||||
|
||||
public void addAttributeConverterInfo(AttributeConverterInfo info) {
|
||||
if ( this.attributeConverterInfoMap == null ) {
|
||||
this.attributeConverterInfoMap = new HashMap<>();
|
||||
public void addAttributeConverterDescriptor(ConverterDescriptor descriptor) {
|
||||
if ( this.attributeConverterDescriptorMap == null ) {
|
||||
this.attributeConverterDescriptorMap = new HashMap<>();
|
||||
}
|
||||
|
||||
final Object old = this.attributeConverterInfoMap.put( info.getConverterClass(), info );
|
||||
final Object old = this.attributeConverterDescriptorMap.put( descriptor.getAttributeConverterClass(), descriptor );
|
||||
|
||||
if ( old != null ) {
|
||||
throw new AssertionFailure(
|
||||
String.format(
|
||||
"AttributeConverter class [%s] registered multiple times",
|
||||
info.getConverterClass()
|
||||
descriptor.getAttributeConverterClass()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -104,8 +104,6 @@
|
||||
import org.hibernate.mapping.Table;
|
||||
import org.hibernate.mapping.UniqueKey;
|
||||
import org.hibernate.query.named.NamedQueryRepository;
|
||||
import org.hibernate.type.Type;
|
||||
import org.hibernate.type.TypeResolver;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
/**
|
||||
@ -207,18 +205,6 @@ public TypeConfiguration getTypeConfiguration() {
|
||||
return bootstrapContext.getTypeConfiguration();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the {@link Type} resolver associated with this factory.
|
||||
*
|
||||
* @return The type resolver
|
||||
*
|
||||
* @deprecated (since 5.3) No replacement, access to and handling of Types will be much different in 6.0
|
||||
*/
|
||||
@Deprecated
|
||||
public TypeResolver getTypeResolver() {
|
||||
return bootstrapContext.getTypeConfiguration().getTypeResolver();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Database getDatabase() {
|
||||
// important to delay this instantiation until as late as possible.
|
||||
|
@ -9,7 +9,6 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
import javax.persistence.AttributeConverter;
|
||||
import javax.persistence.SharedCacheMode;
|
||||
@ -18,7 +17,6 @@
|
||||
import org.hibernate.MultiTenancyStrategy;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
import org.hibernate.annotations.common.reflection.ReflectionManager;
|
||||
import org.hibernate.boot.AttributeConverterInfo;
|
||||
import org.hibernate.boot.CacheRegionDefinition;
|
||||
import org.hibernate.boot.MetadataBuilder;
|
||||
import org.hibernate.boot.MetadataSources;
|
||||
@ -52,13 +50,11 @@
|
||||
import org.hibernate.boot.spi.MappingDefaults;
|
||||
import org.hibernate.boot.spi.MetadataBuilderImplementor;
|
||||
import org.hibernate.boot.spi.MetadataBuilderInitializer;
|
||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||
import org.hibernate.boot.spi.MetadataBuildingOptions;
|
||||
import org.hibernate.boot.spi.MetadataImplementor;
|
||||
import org.hibernate.boot.spi.MetadataSourcesContributor;
|
||||
import org.hibernate.cache.spi.RegionFactory;
|
||||
import org.hibernate.cache.spi.access.AccessType;
|
||||
import org.hibernate.cfg.AttributeConverterDefinition;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.cfg.MetadataSourceType;
|
||||
import org.hibernate.dialect.function.SQLFunction;
|
||||
@ -73,7 +69,6 @@
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
import org.hibernate.usertype.CompositeUserType;
|
||||
import org.hibernate.usertype.UserType;
|
||||
|
||||
import org.jboss.jandex.IndexView;
|
||||
@ -256,13 +251,7 @@ public MetadataBuilder applyBasicType(BasicType type, String... keys) {
|
||||
|
||||
@Override
|
||||
public MetadataBuilder applyBasicType(UserType type, String... keys) {
|
||||
options.basicTypeRegistrations.add( new BasicTypeRegistration( type, keys ) );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetadataBuilder applyBasicType(CompositeUserType type, String... keys) {
|
||||
options.basicTypeRegistrations.add( new BasicTypeRegistration( type, keys ) );
|
||||
options.basicTypeRegistrations.add( new BasicTypeRegistration( type, keys, getTypeConfiguration() ) );
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -284,12 +273,7 @@ public void contributeType(BasicType type, String... keys) {
|
||||
|
||||
@Override
|
||||
public void contributeType(UserType type, String[] keys) {
|
||||
options.basicTypeRegistrations.add( new BasicTypeRegistration( type, keys ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contributeType(CompositeUserType type, String[] keys) {
|
||||
options.basicTypeRegistrations.add( new BasicTypeRegistration( type, keys ) );
|
||||
options.basicTypeRegistrations.add( new BasicTypeRegistration( type, keys, getTypeConfiguration() ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -343,95 +327,43 @@ public MetadataBuilder applyAuxiliaryDatabaseObject(AuxiliaryDatabaseObject auxi
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetadataBuilder applyAttributeConverter(AttributeConverterDefinition definition) {
|
||||
this.bootstrapContext.addAttributeConverterInfo( definition );
|
||||
public MetadataBuilder applyAttributeConverter(ConverterDescriptor descriptor) {
|
||||
this.bootstrapContext.addAttributeConverterDescriptor( descriptor );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetadataBuilder applyAttributeConverter(Class<? extends AttributeConverter> attributeConverterClass) {
|
||||
this.bootstrapContext.addAttributeConverterInfo(
|
||||
new AttributeConverterInfo() {
|
||||
@Override
|
||||
public Class<? extends AttributeConverter> getConverterClass() {
|
||||
return attributeConverterClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConverterDescriptor toConverterDescriptor(MetadataBuildingContext context) {
|
||||
return new ClassBasedConverterDescriptor(
|
||||
attributeConverterClass,
|
||||
null,
|
||||
context.getBootstrapContext().getClassmateContext()
|
||||
);
|
||||
}
|
||||
}
|
||||
public <O,R> MetadataBuilder applyAttributeConverter(Class<? extends AttributeConverter<O,R>> attributeConverterClass) {
|
||||
bootstrapContext.addAttributeConverterDescriptor(
|
||||
new ClassBasedConverterDescriptor( attributeConverterClass, bootstrapContext.getClassmateContext() )
|
||||
);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetadataBuilder applyAttributeConverter(Class<? extends AttributeConverter> attributeConverterClass, boolean autoApply) {
|
||||
this.bootstrapContext.addAttributeConverterInfo(
|
||||
new AttributeConverterInfo() {
|
||||
@Override
|
||||
public Class<? extends AttributeConverter> getConverterClass() {
|
||||
return attributeConverterClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConverterDescriptor toConverterDescriptor(MetadataBuildingContext context) {
|
||||
return new ClassBasedConverterDescriptor(
|
||||
attributeConverterClass,
|
||||
autoApply,
|
||||
context.getBootstrapContext().getClassmateContext()
|
||||
);
|
||||
}
|
||||
}
|
||||
public <O,R> MetadataBuilder applyAttributeConverter(Class<? extends AttributeConverter<O,R>> attributeConverterClass, boolean autoApply) {
|
||||
this.bootstrapContext.addAttributeConverterDescriptor(
|
||||
new ClassBasedConverterDescriptor(
|
||||
attributeConverterClass,
|
||||
autoApply,
|
||||
bootstrapContext.getClassmateContext()
|
||||
)
|
||||
);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetadataBuilder applyAttributeConverter(AttributeConverter attributeConverter) {
|
||||
this.bootstrapContext.addAttributeConverterInfo(
|
||||
new AttributeConverterInfo() {
|
||||
@Override
|
||||
public Class<? extends AttributeConverter> getConverterClass() {
|
||||
return attributeConverter.getClass();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConverterDescriptor toConverterDescriptor(MetadataBuildingContext context) {
|
||||
return new InstanceBasedConverterDescriptor(
|
||||
attributeConverter,
|
||||
null,
|
||||
context.getBootstrapContext().getClassmateContext()
|
||||
);
|
||||
}
|
||||
}
|
||||
public <O,R> MetadataBuilder applyAttributeConverter(AttributeConverter<O,R> attributeConverter) {
|
||||
bootstrapContext.addAttributeConverterDescriptor(
|
||||
new InstanceBasedConverterDescriptor( attributeConverter, bootstrapContext.getClassmateContext() )
|
||||
);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetadataBuilder applyAttributeConverter(AttributeConverter attributeConverter, boolean autoApply) {
|
||||
this.bootstrapContext.addAttributeConverterInfo(
|
||||
new AttributeConverterInfo() {
|
||||
@Override
|
||||
public Class<? extends AttributeConverter> getConverterClass() {
|
||||
return attributeConverter.getClass();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConverterDescriptor toConverterDescriptor(MetadataBuildingContext context) {
|
||||
return new InstanceBasedConverterDescriptor(
|
||||
attributeConverter,
|
||||
autoApply,
|
||||
context.getBootstrapContext().getClassmateContext()
|
||||
);
|
||||
}
|
||||
}
|
||||
bootstrapContext.addAttributeConverterDescriptor(
|
||||
new InstanceBasedConverterDescriptor( attributeConverter, autoApply, bootstrapContext.getClassmateContext() )
|
||||
);
|
||||
return this;
|
||||
}
|
||||
@ -887,21 +819,6 @@ public List<MetadataSourceType> getSourceProcessOrdering() {
|
||||
return sourceProcessOrdering;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, SQLFunction> getSqlFunctions() {
|
||||
return bootstrapContext.getSqlFunctions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AuxiliaryDatabaseObject> getAuxiliaryDatabaseObjectList() {
|
||||
return new ArrayList<>( bootstrapContext.getAuxiliaryDatabaseObjectList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AttributeConverterInfo> getAttributeConverters() {
|
||||
return new ArrayList<>( bootstrapContext.getAttributeConverters() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSchemaCharset() {
|
||||
return schemaCharset;
|
||||
|
@ -6,6 +6,7 @@
|
||||
*/
|
||||
package org.hibernate.boot.internal;
|
||||
|
||||
import org.hibernate.boot.model.TypeDefinitionRegistry;
|
||||
import org.hibernate.boot.model.naming.ObjectNameNormalizer;
|
||||
import org.hibernate.boot.spi.BootstrapContext;
|
||||
import org.hibernate.boot.spi.ClassLoaderAccess;
|
||||
@ -23,6 +24,7 @@ public class MetadataBuildingContextRootImpl implements MetadataBuildingContext
|
||||
private final MappingDefaults mappingDefaults;
|
||||
private final InFlightMetadataCollector metadataCollector;
|
||||
private final ObjectNameNormalizer objectNameNormalizer;
|
||||
private final TypeDefinitionRegistry typeDefinitionRegistry;
|
||||
|
||||
public MetadataBuildingContextRootImpl(
|
||||
BootstrapContext bootstrapContext,
|
||||
@ -38,6 +40,7 @@ protected MetadataBuildingContext getBuildingContext() {
|
||||
return MetadataBuildingContextRootImpl.this;
|
||||
}
|
||||
};
|
||||
this.typeDefinitionRegistry = new TypeDefinitionRegistry();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -69,4 +72,9 @@ public ClassLoaderAccess getClassLoaderAccess() {
|
||||
public ObjectNameNormalizer getObjectNameNormalizer() {
|
||||
return objectNameNormalizer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDefinitionRegistry getTypeDefinitionRegistry() {
|
||||
return typeDefinitionRegistry;
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,6 @@
|
||||
import org.hibernate.query.named.NamedResultSetMappingMemento;
|
||||
import org.hibernate.query.sql.spi.NamedNativeQueryMemento;
|
||||
import org.hibernate.type.Type;
|
||||
import org.hibernate.type.TypeResolver;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
/**
|
||||
@ -137,18 +136,6 @@ public TypeConfiguration getTypeConfiguration() {
|
||||
return bootstrapContext.getTypeConfiguration();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the {@link Type} resolver associated with this factory.
|
||||
*
|
||||
* @return The type resolver
|
||||
*
|
||||
* @deprecated (since 5.3) No replacement, access to and handling of Types will be much different in 6.0
|
||||
*/
|
||||
@Deprecated
|
||||
public TypeResolver getTypeResolver() {
|
||||
return bootstrapContext.getTypeConfiguration().getTypeResolver();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SessionFactoryBuilder getSessionFactoryBuilder() {
|
||||
final SessionFactoryBuilderImpl defaultBuilder = new SessionFactoryBuilderImpl( this, bootstrapContext );
|
||||
|
@ -12,7 +12,6 @@
|
||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
import org.hibernate.usertype.CompositeUserType;
|
||||
import org.hibernate.usertype.UserType;
|
||||
|
||||
/**
|
||||
@ -62,15 +61,4 @@ public interface TypeContributions {
|
||||
*/
|
||||
@Deprecated
|
||||
void contributeType(UserType type, String... keys);
|
||||
|
||||
/**
|
||||
* @deprecated (since 5.3) Use {@link #contributeType(BasicType)} instead.
|
||||
* {@link CompositeUserType}, as currently defined, will be done very differently
|
||||
* in 6.0. {@link CompositeUserType} should be replaced with a normal Hibernate
|
||||
* component or JPA embeddable (different names, same thing. This embeddable
|
||||
* may contain, in turn, custom types that should be handled as described on these
|
||||
* methods
|
||||
*/
|
||||
@Deprecated
|
||||
void contributeType(CompositeUserType type, String... keys);
|
||||
}
|
||||
|
@ -8,11 +8,27 @@
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.hibernate.NotYetImplementedFor6Exception;
|
||||
import org.hibernate.boot.model.process.internal.UserTypeResolution;
|
||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||
import org.hibernate.mapping.BasicValue;
|
||||
import org.hibernate.metamodel.model.convert.spi.BasicValueConverter;
|
||||
import org.hibernate.resource.beans.spi.ManagedBean;
|
||||
import org.hibernate.resource.beans.spi.ManagedBeanRegistry;
|
||||
import org.hibernate.type.BasicType;
|
||||
import org.hibernate.type.CustomType;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.java.MutabilityPlan;
|
||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
import org.hibernate.usertype.ParameterizedType;
|
||||
import org.hibernate.usertype.UserType;
|
||||
|
||||
/**
|
||||
* Models the information pertaining to a custom type definition supplied by the user. Used
|
||||
@ -30,51 +46,28 @@
|
||||
* @author John Verhaeg
|
||||
*/
|
||||
public class TypeDefinition implements Serializable {
|
||||
private static final AtomicInteger nameCounter = new AtomicInteger();
|
||||
|
||||
private final String name;
|
||||
private final Class typeImplementorClass;
|
||||
private final String[] registrationKeys;
|
||||
private final Map<String, String> parameters;
|
||||
private final Properties parameters;
|
||||
private final TypeConfiguration typeConfiguration;
|
||||
|
||||
private BasicValue.Resolution<?> reusableResolution;
|
||||
|
||||
|
||||
public TypeDefinition(
|
||||
String name,
|
||||
Class typeImplementorClass,
|
||||
String[] registrationKeys,
|
||||
Map<String, String> parameters) {
|
||||
Properties parameters,
|
||||
TypeConfiguration typeConfiguration) {
|
||||
this.name = name;
|
||||
this.typeImplementorClass = typeImplementorClass;
|
||||
this.registrationKeys= registrationKeys;
|
||||
this.parameters = parameters == null
|
||||
? Collections.<String, String>emptyMap()
|
||||
: Collections.unmodifiableMap( parameters );
|
||||
}
|
||||
|
||||
public TypeDefinition(
|
||||
String name,
|
||||
Class typeImplementorClass,
|
||||
String[] registrationKeys,
|
||||
Properties parameters) {
|
||||
this.name = name;
|
||||
this.typeImplementorClass = typeImplementorClass;
|
||||
this.registrationKeys= registrationKeys;
|
||||
this.parameters = parameters == null
|
||||
? Collections.<String, String>emptyMap()
|
||||
: extractStrings( parameters );
|
||||
}
|
||||
|
||||
private Map<String, String> extractStrings(Properties properties) {
|
||||
final Map<String, String> parameters = new HashMap<String, String>();
|
||||
|
||||
for ( Map.Entry entry : properties.entrySet() ) {
|
||||
if ( String.class.isInstance( entry.getKey() )
|
||||
&& String.class.isInstance( entry.getValue() ) ) {
|
||||
parameters.put(
|
||||
(String) entry.getKey(),
|
||||
(String) entry.getValue()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return parameters;
|
||||
this.parameters = parameters;
|
||||
this.typeConfiguration = typeConfiguration;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
@ -89,7 +82,7 @@ public String[] getRegistrationKeys() {
|
||||
return registrationKeys;
|
||||
}
|
||||
|
||||
public Map<String, String> getParameters() {
|
||||
public Properties getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
@ -99,6 +92,212 @@ public Properties getParametersAsProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public BasicValue.Resolution<?> resolve(
|
||||
JavaTypeDescriptor<?> explicitJtd,
|
||||
SqlTypeDescriptor explicitStd,
|
||||
Properties localConfigParameters,
|
||||
MutabilityPlan explicitMutabilityPlan,
|
||||
MetadataBuildingContext context) {
|
||||
if ( CollectionHelper.isEmpty( localConfigParameters ) ) {
|
||||
// we can use the re-usable resolution...
|
||||
if ( reusableResolution == null ) {
|
||||
final ManagedBean typeBean = context.getBootstrapContext()
|
||||
.getServiceRegistry()
|
||||
.getService( ManagedBeanRegistry.class )
|
||||
.getBean( typeImplementorClass );
|
||||
|
||||
final Object typeInstance = typeBean.getBeanInstance();
|
||||
|
||||
injectParameters( typeInstance, () -> parameters );
|
||||
|
||||
reusableResolution = createReusableResolution( typeInstance, name, context );
|
||||
}
|
||||
|
||||
return reusableResolution;
|
||||
}
|
||||
else {
|
||||
final String name = this.name + ":" + nameCounter.getAndIncrement();
|
||||
|
||||
final ManagedBean typeBean = context.getBootstrapContext()
|
||||
.getServiceRegistry()
|
||||
.getService( ManagedBeanRegistry.class )
|
||||
.getBean( name, typeImplementorClass );
|
||||
|
||||
final Object typeInstance = typeBean.getBeanInstance();
|
||||
|
||||
injectParameters(
|
||||
typeInstance,
|
||||
() -> mergeParameters( parameters, localConfigParameters )
|
||||
);
|
||||
|
||||
|
||||
return createResolution(
|
||||
name,
|
||||
typeInstance,
|
||||
explicitJtd,
|
||||
explicitStd,
|
||||
explicitMutabilityPlan,
|
||||
context
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private static Properties mergeParameters(Properties parameters, Properties localConfigParameters) {
|
||||
final Properties mergedParameters = new Properties();
|
||||
|
||||
if ( parameters != null ) {
|
||||
mergedParameters.putAll( parameters );
|
||||
}
|
||||
|
||||
if ( localConfigParameters != null && ! localConfigParameters.isEmpty() ) {
|
||||
mergedParameters.putAll( localConfigParameters );
|
||||
}
|
||||
|
||||
return mergedParameters;
|
||||
}
|
||||
|
||||
private static void injectParameters(Object customType, Supplier<Properties> parameterSupplier) {
|
||||
if ( customType instanceof ParameterizedType ) {
|
||||
final Properties parameterValues = parameterSupplier.get();
|
||||
if ( parameterValues != null ) {
|
||||
( (ParameterizedType) customType ).setParameterValues( parameterValues );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static BasicValue.Resolution<?> createReusableResolution(
|
||||
Object namedTypeInstance,
|
||||
String name,
|
||||
MetadataBuildingContext buildingContext) {
|
||||
if ( namedTypeInstance instanceof UserType ) {
|
||||
final UserType userType = (UserType) namedTypeInstance;
|
||||
final CustomType customType = new CustomType( userType, buildingContext.getBootstrapContext().getTypeConfiguration() );
|
||||
|
||||
return new UserTypeResolution( customType, null );
|
||||
}
|
||||
else if ( namedTypeInstance instanceof BasicType ) {
|
||||
final BasicType resolvedBasicType = (BasicType) namedTypeInstance;
|
||||
return new BasicValue.Resolution<Object>() {
|
||||
@Override
|
||||
public BasicType getResolvedBasicType() {
|
||||
return resolvedBasicType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaTypeDescriptor<Object> getDomainJavaDescriptor() {
|
||||
return resolvedBasicType.getMappedJavaTypeDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaTypeDescriptor<?> getRelationalJavaDescriptor() {
|
||||
return resolvedBasicType.getMappedJavaTypeDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqlTypeDescriptor getRelationalSqlTypeDescriptor() {
|
||||
return resolvedBasicType.getSqlTypeDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasicValueConverter getValueConverter() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutabilityPlan<Object> getMutabilityPlan() {
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException(
|
||||
"Named type [" + namedTypeInstance + "] did not implement BasicType nor UserType"
|
||||
);
|
||||
}
|
||||
|
||||
public static BasicValue.Resolution<?> createLocalResolution(
|
||||
String name,
|
||||
Class typeImplementorClass,
|
||||
JavaTypeDescriptor<?> explicitJtd,
|
||||
SqlTypeDescriptor explicitStd,
|
||||
MutabilityPlan explicitMutabilityPlan,
|
||||
Properties localTypeParams,
|
||||
MetadataBuildingContext buildingContext) {
|
||||
name = name + ':' + nameCounter.getAndIncrement();
|
||||
|
||||
final ManagedBean typeBean = buildingContext.getBootstrapContext()
|
||||
.getServiceRegistry()
|
||||
.getService( ManagedBeanRegistry.class )
|
||||
.getBean( name, typeImplementorClass );
|
||||
|
||||
final Object typeInstance = typeBean.getBeanInstance();
|
||||
|
||||
injectParameters( typeInstance, () -> localTypeParams );
|
||||
|
||||
return createResolution(
|
||||
name,
|
||||
typeInstance,
|
||||
explicitJtd,
|
||||
explicitStd,
|
||||
explicitMutabilityPlan,
|
||||
buildingContext
|
||||
);
|
||||
}
|
||||
|
||||
private static BasicValue.Resolution<?> createResolution(
|
||||
String name,
|
||||
Object namedTypeInstance,
|
||||
JavaTypeDescriptor<?> explicitJtd,
|
||||
SqlTypeDescriptor explicitStd,
|
||||
MutabilityPlan explicitMutabilityPlan,
|
||||
MetadataBuildingContext metadataBuildingContext) {
|
||||
if ( namedTypeInstance instanceof UserType ) {
|
||||
return new UserTypeResolution(
|
||||
new CustomType( (UserType) namedTypeInstance, metadataBuildingContext.getBootstrapContext().getTypeConfiguration() ),
|
||||
null
|
||||
);
|
||||
}
|
||||
else if ( namedTypeInstance instanceof org.hibernate.type.BasicType ) {
|
||||
final BasicType resolvedBasicType = (BasicType) namedTypeInstance;
|
||||
return new BasicValue.Resolution<Object>() {
|
||||
@Override
|
||||
public BasicType getResolvedBasicType() {
|
||||
return resolvedBasicType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaTypeDescriptor<Object> getDomainJavaDescriptor() {
|
||||
return resolvedBasicType.getMappedJavaTypeDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaTypeDescriptor<?> getRelationalJavaDescriptor() {
|
||||
return resolvedBasicType.getMappedJavaTypeDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqlTypeDescriptor getRelationalSqlTypeDescriptor() {
|
||||
return resolvedBasicType.getSqlTypeDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasicValueConverter getValueConverter() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutabilityPlan<Object> getMutabilityPlan() {
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException(
|
||||
"Named type [" + name + " : " + namedTypeInstance
|
||||
+ "] did not implement BasicType nor UserType"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if ( this == o ) {
|
||||
|
@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.boot.model;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
/**
|
||||
* @author Chris Cranford
|
||||
*/
|
||||
public class TypeDefinitionRegistry {
|
||||
private static final Logger log = Logger.getLogger( TypeDefinitionRegistry.class );
|
||||
private final TypeDefinitionRegistry parent;
|
||||
|
||||
public enum DuplicationStrategy {
|
||||
KEEP,
|
||||
OVERWRITE,
|
||||
DISALLOW
|
||||
}
|
||||
|
||||
private final Map<String, TypeDefinition> typeDefinitionMap = new HashMap<>();
|
||||
|
||||
public TypeDefinitionRegistry() {
|
||||
this( null );
|
||||
}
|
||||
|
||||
public TypeDefinitionRegistry(TypeDefinitionRegistry parent) {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public TypeDefinition resolve(String typeName) {
|
||||
final TypeDefinition localDefinition = typeDefinitionMap.get( typeName );
|
||||
if ( localDefinition != null ) {
|
||||
return localDefinition;
|
||||
}
|
||||
|
||||
if ( parent != null ) {
|
||||
return parent.resolve( typeName );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public TypeDefinitionRegistry register(TypeDefinition typeDefinition) {
|
||||
return register( typeDefinition, DuplicationStrategy.OVERWRITE );
|
||||
}
|
||||
|
||||
public TypeDefinitionRegistry register(TypeDefinition typeDefinition, DuplicationStrategy duplicationStrategy) {
|
||||
if ( typeDefinition == null ) {
|
||||
throw new IllegalArgumentException( "TypeDefinition to register cannot be null" );
|
||||
}
|
||||
|
||||
if ( typeDefinition.getTypeImplementorClass() == null ) {
|
||||
throw new IllegalArgumentException( "TypeDefinition to register cannot define null #typeImplementorClass" );
|
||||
}
|
||||
|
||||
if ( !StringHelper.isEmpty( typeDefinition.getName() ) ) {
|
||||
register( typeDefinition.getName(), typeDefinition, duplicationStrategy );
|
||||
}
|
||||
|
||||
if ( typeDefinition.getRegistrationKeys() != null ) {
|
||||
for ( String registrationKey : typeDefinition.getRegistrationKeys() ) {
|
||||
register( registrationKey, typeDefinition, duplicationStrategy );
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
private void register(String name, TypeDefinition typeDefinition, DuplicationStrategy duplicationStrategy) {
|
||||
if ( duplicationStrategy == DuplicationStrategy.KEEP ) {
|
||||
if ( !typeDefinitionMap.containsKey( name ) ) {
|
||||
typeDefinitionMap.put( name, typeDefinition );
|
||||
}
|
||||
}
|
||||
else {
|
||||
final TypeDefinition existing = typeDefinitionMap.put( name, typeDefinition );
|
||||
if ( existing != null && existing != typeDefinition ) {
|
||||
if ( duplicationStrategy == DuplicationStrategy.OVERWRITE ) {
|
||||
log.debugf( "Overwrote existing registration [%s] for type definition.", name );
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException(
|
||||
String.format(
|
||||
Locale.ROOT,
|
||||
"Attempted to ovewrite registration [%s] for type definition.",
|
||||
name
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -18,6 +18,8 @@
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface ConverterDescriptor {
|
||||
String TYPE_NAME_PREFIX = "converted::";
|
||||
|
||||
/**
|
||||
* The AttributeConverter class
|
||||
*/
|
||||
|
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.boot.model.process.internal;
|
||||
|
||||
import org.hibernate.mapping.BasicValue;
|
||||
import org.hibernate.metamodel.model.convert.spi.BasicValueConverter;
|
||||
import org.hibernate.type.BasicType;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.java.MutabilityPlan;
|
||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class InferredBasicValueResolution<J> implements BasicValue.Resolution<J> {
|
||||
private final BasicType<J> basicType;
|
||||
|
||||
private JavaTypeDescriptor<J> domainJtd;
|
||||
private JavaTypeDescriptor<J> relationalJtd;
|
||||
private SqlTypeDescriptor relationalStd;
|
||||
|
||||
private BasicValueConverter valueConverter;
|
||||
private MutabilityPlan mutabilityPlan;
|
||||
|
||||
public InferredBasicValueResolution(
|
||||
BasicType<J> basicType,
|
||||
JavaTypeDescriptor<J> domainJtd,
|
||||
JavaTypeDescriptor<J> relationalJtd,
|
||||
SqlTypeDescriptor relationalStd,
|
||||
BasicValueConverter valueConverter,
|
||||
MutabilityPlan mutabilityPlan) {
|
||||
this.basicType = basicType;
|
||||
this.domainJtd = domainJtd;
|
||||
this.relationalJtd = relationalJtd;
|
||||
this.relationalStd = relationalStd;
|
||||
this.valueConverter = valueConverter;
|
||||
this.mutabilityPlan = mutabilityPlan;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasicType getResolvedBasicType() {
|
||||
return basicType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaTypeDescriptor<J> getDomainJavaDescriptor() {
|
||||
return domainJtd;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaTypeDescriptor<?> getRelationalJavaDescriptor() {
|
||||
return relationalJtd;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqlTypeDescriptor getRelationalSqlTypeDescriptor() {
|
||||
return relationalStd;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasicValueConverter getValueConverter() {
|
||||
return valueConverter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutabilityPlan<J> getMutabilityPlan() {
|
||||
return mutabilityPlan;
|
||||
}
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.boot.model.process.internal;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.hibernate.mapping.BasicValue;
|
||||
import org.hibernate.metamodel.model.convert.spi.BasicValueConverter;
|
||||
import org.hibernate.type.BasicType;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.java.MutabilityPlan;
|
||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class InferredBasicValueResolver<J> {
|
||||
private final TypeConfiguration typeConfiguration;
|
||||
|
||||
private JavaTypeDescriptor<J> domainJtd;
|
||||
private JavaTypeDescriptor<?> relationalJtd;
|
||||
private SqlTypeDescriptor relationalStd;
|
||||
private BasicValueConverter valueConverter;
|
||||
private MutabilityPlan<J> mutabilityPlan;
|
||||
|
||||
private InferredBasicValueResolution<J> resolution;
|
||||
|
||||
public InferredBasicValueResolver(
|
||||
Function<TypeConfiguration,JavaTypeDescriptor<J>> explicitJtdAccess,
|
||||
Function<TypeConfiguration,SqlTypeDescriptor> explicitStdAccess,
|
||||
TypeConfiguration typeConfiguration) {
|
||||
this.typeConfiguration = typeConfiguration;
|
||||
|
||||
this.domainJtd = explicitJtdAccess != null ? explicitJtdAccess.apply( typeConfiguration ) : null;
|
||||
this.relationalStd = explicitStdAccess != null ? explicitStdAccess.apply( typeConfiguration ) : null;
|
||||
}
|
||||
|
||||
public BasicValue.Resolution<J> build() {
|
||||
if ( resolution == null ) {
|
||||
final BasicType<?> basicType = typeConfiguration.getBasicTypeRegistry().resolve( relationalJtd, relationalStd );
|
||||
|
||||
//noinspection unchecked
|
||||
resolution = new InferredBasicValueResolution( basicType, domainJtd, relationalJtd, relationalStd, valueConverter, mutabilityPlan );
|
||||
}
|
||||
|
||||
return resolution;
|
||||
}
|
||||
|
||||
public void injectResolution(InferredBasicValueResolution<J> resolution) {
|
||||
this.resolution = resolution;
|
||||
}
|
||||
|
||||
public TypeConfiguration getTypeConfiguration() {
|
||||
return typeConfiguration;
|
||||
}
|
||||
|
||||
public JavaTypeDescriptor<?> getDomainJtd() {
|
||||
return domainJtd;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setDomainJtd(JavaTypeDescriptor domainJtd) {
|
||||
this.domainJtd = domainJtd;
|
||||
}
|
||||
|
||||
public JavaTypeDescriptor<?> getRelationalJtd() {
|
||||
return relationalJtd;
|
||||
}
|
||||
|
||||
public void setRelationalJtd(JavaTypeDescriptor<?> relationalJtd) {
|
||||
this.relationalJtd = relationalJtd;
|
||||
}
|
||||
|
||||
public SqlTypeDescriptor getRelationalStd() {
|
||||
return relationalStd;
|
||||
}
|
||||
|
||||
public void setRelationalStd(SqlTypeDescriptor relationalStd) {
|
||||
this.relationalStd = relationalStd;
|
||||
}
|
||||
|
||||
public BasicValueConverter getValueConverter() {
|
||||
return valueConverter;
|
||||
}
|
||||
|
||||
public void setValueConverter(BasicValueConverter valueConverter) {
|
||||
this.valueConverter = valueConverter;
|
||||
}
|
||||
|
||||
public MutabilityPlan getMutabilityPlan() {
|
||||
return mutabilityPlan;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setMutabilityPlan(MutabilityPlan mutabilityPlan) {
|
||||
this.mutabilityPlan = mutabilityPlan;
|
||||
}
|
||||
}
|
@ -15,23 +15,21 @@
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hibernate.boot.AttributeConverterInfo;
|
||||
import org.hibernate.boot.MetadataSources;
|
||||
import org.hibernate.boot.jaxb.spi.Binding;
|
||||
import org.hibernate.boot.model.convert.spi.ConverterDescriptor;
|
||||
import org.hibernate.boot.model.process.spi.ManagedResources;
|
||||
import org.hibernate.boot.spi.BootstrapContext;
|
||||
import org.hibernate.boot.spi.MetadataBuildingOptions;
|
||||
import org.hibernate.cfg.AttributeConverterDefinition;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class ManagedResourcesImpl implements ManagedResources {
|
||||
private Map<Class, AttributeConverterInfo> attributeConverterInfoMap = new HashMap<>();
|
||||
private Set<Class> annotatedClassReferences = new LinkedHashSet<Class>();
|
||||
private Set<String> annotatedClassNames = new LinkedHashSet<String>();
|
||||
private Set<String> annotatedPackageNames = new LinkedHashSet<String>();
|
||||
private List<Binding> mappingFileBindings = new ArrayList<Binding>();
|
||||
private Map<Class, ConverterDescriptor> attributeConverterDescriptorMap = new HashMap<>();
|
||||
private Set<Class> annotatedClassReferences = new LinkedHashSet<>();
|
||||
private Set<String> annotatedClassNames = new LinkedHashSet<>();
|
||||
private Set<String> annotatedPackageNames = new LinkedHashSet<>();
|
||||
private List<Binding> mappingFileBindings = new ArrayList<>();
|
||||
|
||||
public static ManagedResourcesImpl baseline(MetadataSources sources, BootstrapContext bootstrapContext) {
|
||||
final ManagedResourcesImpl impl = new ManagedResourcesImpl();
|
||||
@ -47,8 +45,8 @@ private ManagedResourcesImpl() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<AttributeConverterInfo> getAttributeConverterDefinitions() {
|
||||
return Collections.unmodifiableCollection( attributeConverterInfoMap.values() );
|
||||
public Collection<ConverterDescriptor> getAttributeConverterDescriptors() {
|
||||
return Collections.unmodifiableCollection( attributeConverterDescriptorMap.values() );
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -75,8 +73,8 @@ public Collection<Binding> getXmlMappingBindings() {
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// package private
|
||||
|
||||
void addAttributeConverterDefinition(AttributeConverterInfo converterInfo) {
|
||||
attributeConverterInfoMap.put( converterInfo.getConverterClass(), converterInfo );
|
||||
void addAttributeConverterDefinition(ConverterDescriptor descriptor) {
|
||||
attributeConverterDescriptorMap.put( descriptor.getAttributeConverterClass(), descriptor );
|
||||
}
|
||||
|
||||
void addAnnotatedClassReference(Class annotatedClassReference) {
|
||||
|
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.boot.model.process.internal;
|
||||
|
||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||
import org.hibernate.mapping.BasicValue;
|
||||
import org.hibernate.metamodel.model.convert.spi.BasicValueConverter;
|
||||
import org.hibernate.type.BasicType;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.java.MutabilityPlan;
|
||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class NamedBasicTypeResolution<J> implements BasicValue.Resolution<J> {
|
||||
private final JavaTypeDescriptor<J> domainJtd;
|
||||
|
||||
private final BasicType basicType;
|
||||
|
||||
private final BasicValueConverter valueConverter;
|
||||
private final MutabilityPlan<J> mutabilityPlan;
|
||||
|
||||
public NamedBasicTypeResolution(
|
||||
JavaTypeDescriptor<J> domainJtd,
|
||||
BasicType basicType,
|
||||
BasicValueConverter valueConverter,
|
||||
MutabilityPlan<J> mutabilityPlan,
|
||||
MetadataBuildingContext context) {
|
||||
this.domainJtd = domainJtd;
|
||||
|
||||
this.basicType = basicType;
|
||||
|
||||
this.valueConverter = valueConverter;
|
||||
this.mutabilityPlan = mutabilityPlan;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasicType getResolvedBasicType() {
|
||||
return basicType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaTypeDescriptor<J> getDomainJavaDescriptor() {
|
||||
return domainJtd;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaTypeDescriptor<?> getRelationalJavaDescriptor() {
|
||||
return basicType.getJavaTypeDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqlTypeDescriptor getRelationalSqlTypeDescriptor() {
|
||||
return basicType.getSqlTypeDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasicValueConverter getValueConverter() {
|
||||
return valueConverter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutabilityPlan<J> getMutabilityPlan() {
|
||||
return mutabilityPlan;
|
||||
}
|
||||
}
|
@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.boot.model.process.internal;
|
||||
|
||||
import java.util.function.Function;
|
||||
import javax.persistence.AttributeConverter;
|
||||
|
||||
import org.hibernate.boot.model.convert.internal.ClassBasedConverterDescriptor;
|
||||
import org.hibernate.boot.model.convert.spi.ConverterDescriptor;
|
||||
import org.hibernate.boot.model.convert.spi.JpaAttributeConverterCreationContext;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||
import org.hibernate.mapping.BasicValue;
|
||||
import org.hibernate.metamodel.model.convert.spi.BasicValueConverter;
|
||||
import org.hibernate.metamodel.model.convert.spi.JpaAttributeConverter;
|
||||
import org.hibernate.type.BasicType;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.java.MutabilityPlan;
|
||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptorIndicators;
|
||||
import org.hibernate.type.internal.StandardBasicTypeImpl;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class NamedConverterResolution<J> implements BasicValue.Resolution<J> {
|
||||
|
||||
public static NamedConverterResolution from(
|
||||
String name,
|
||||
Function<TypeConfiguration, JavaTypeDescriptor<?>> explicitJtdAccess,
|
||||
Function<TypeConfiguration, SqlTypeDescriptor> explicitStdAccess,
|
||||
JpaAttributeConverterCreationContext converterCreationContext,
|
||||
MutabilityPlan explicitMutabilityPlan,
|
||||
SqlTypeDescriptorIndicators sqlTypeIndicators,
|
||||
MetadataBuildingContext context) {
|
||||
assert name.startsWith( ConverterDescriptor.TYPE_NAME_PREFIX );
|
||||
final String converterClassName = name.substring( ConverterDescriptor.TYPE_NAME_PREFIX.length() );
|
||||
|
||||
final StandardServiceRegistry serviceRegistry = context.getBootstrapContext().getServiceRegistry();
|
||||
final ClassLoaderService classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
|
||||
|
||||
final Class<? extends AttributeConverter> converterClass = classLoaderService.classForName( converterClassName );
|
||||
final ClassBasedConverterDescriptor converterDescriptor = new ClassBasedConverterDescriptor(
|
||||
converterClass,
|
||||
context.getBootstrapContext().getClassmateContext()
|
||||
);
|
||||
final JpaAttributeConverter converter = converterDescriptor.createJpaAttributeConverter( converterCreationContext );
|
||||
|
||||
final JavaTypeDescriptor explicitJtd = explicitJtdAccess != null
|
||||
? explicitJtdAccess.apply( context.getBootstrapContext().getTypeConfiguration() )
|
||||
: null;
|
||||
final JavaTypeDescriptor domainJtd = explicitJtd != null
|
||||
? explicitJtd
|
||||
: converter.getDomainJavaDescriptor();
|
||||
|
||||
final SqlTypeDescriptor explicitStd = explicitStdAccess != null
|
||||
? explicitStdAccess.apply( context.getBootstrapContext().getTypeConfiguration() )
|
||||
: null;
|
||||
final JavaTypeDescriptor relationalJtd = converter.getRelationalJavaDescriptor();
|
||||
final SqlTypeDescriptor relationalStd = explicitStd != null
|
||||
? explicitStd
|
||||
: relationalJtd.getJdbcRecommendedSqlType( sqlTypeIndicators );
|
||||
|
||||
//noinspection unchecked
|
||||
return new NamedConverterResolution(
|
||||
name,
|
||||
new StandardBasicTypeImpl( relationalJtd, relationalStd ),
|
||||
converter,
|
||||
explicitMutabilityPlan != null
|
||||
? explicitMutabilityPlan
|
||||
: converter.getDomainJavaDescriptor().getMutabilityPlan()
|
||||
);
|
||||
}
|
||||
|
||||
private final String name;
|
||||
|
||||
private final BasicType basicType;
|
||||
|
||||
private final BasicValueConverter valueConverter;
|
||||
private final MutabilityPlan mutabilityPlan;
|
||||
|
||||
private NamedConverterResolution(
|
||||
String name,
|
||||
BasicType basicType,
|
||||
JpaAttributeConverter valueConverter,
|
||||
MutabilityPlan mutabilityPlan) {
|
||||
this.name = name;
|
||||
this.basicType = basicType;
|
||||
this.valueConverter = valueConverter;
|
||||
this.mutabilityPlan = mutabilityPlan;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasicType getResolvedBasicType() {
|
||||
return basicType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaTypeDescriptor<J> getDomainJavaDescriptor() {
|
||||
//noinspection unchecked
|
||||
return valueConverter.getDomainJavaDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaTypeDescriptor<?> getRelationalJavaDescriptor() {
|
||||
return valueConverter.getRelationalJavaDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqlTypeDescriptor getRelationalSqlTypeDescriptor() {
|
||||
return basicType.getSqlTypeDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasicValueConverter getValueConverter() {
|
||||
return valueConverter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutabilityPlan<J> getMutabilityPlan() {
|
||||
return mutabilityPlan;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "NamedConverterResolution(" + name + ')';
|
||||
}
|
||||
}
|
@ -12,7 +12,6 @@
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import javax.persistence.AttributeConverter;
|
||||
|
||||
import org.hibernate.boot.MappingException;
|
||||
import org.hibernate.boot.archive.internal.StandardArchiveDescriptorFactory;
|
||||
@ -29,12 +28,11 @@
|
||||
import org.hibernate.boot.internal.ClassLoaderAccessImpl;
|
||||
import org.hibernate.boot.jaxb.Origin;
|
||||
import org.hibernate.boot.jaxb.SourceType;
|
||||
import org.hibernate.boot.model.convert.internal.ClassBasedConverterDescriptor;
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.boot.spi.BootstrapContext;
|
||||
import org.hibernate.boot.spi.ClassLoaderAccess;
|
||||
import org.hibernate.boot.spi.MetadataBuildingOptions;
|
||||
import org.hibernate.boot.spi.XmlMappingBinderAccess;
|
||||
import org.hibernate.cfg.AttributeConverterDefinition;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
@ -232,8 +230,9 @@ public void applyScanResultsToManagedResources(
|
||||
// converter classes are safe to load because we never enhance them,
|
||||
// and notice we use the ClassLoaderService specifically, not the temp ClassLoader (if any)
|
||||
managedResources.addAttributeConverterDefinition(
|
||||
AttributeConverterDefinition.from(
|
||||
classLoaderService.<AttributeConverter>classForName( classDescriptor.getName() )
|
||||
new ClassBasedConverterDescriptor(
|
||||
classLoaderService.classForName( classDescriptor.getName() ),
|
||||
bootstrapContext.getClassmateContext()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.boot.model.process.internal;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.hibernate.type.descriptor.java.MutabilityPlan;
|
||||
import org.hibernate.usertype.UserType;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class UserTypeMutabilityPlanAdapter<T> implements MutabilityPlan<T> {
|
||||
private final UserType userType;
|
||||
|
||||
public UserTypeMutabilityPlanAdapter(UserType userType) {
|
||||
this.userType = userType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMutable() {
|
||||
return userType.isMutable();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public T deepCopy(T value) {
|
||||
return (T) userType.deepCopy( value );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Serializable disassemble(T value) {
|
||||
return userType.disassemble( value );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public T assemble(Serializable cached) {
|
||||
return (T) userType.assemble( cached, null );
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.boot.model.process.internal;
|
||||
|
||||
import org.hibernate.mapping.BasicValue;
|
||||
import org.hibernate.metamodel.model.convert.spi.BasicValueConverter;
|
||||
import org.hibernate.type.BasicType;
|
||||
import org.hibernate.type.CustomType;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.java.MutabilityPlan;
|
||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class UserTypeResolution implements BasicValue.Resolution {
|
||||
private final CustomType userTypeAdapter;
|
||||
private final MutabilityPlan mutabilityPlan;
|
||||
|
||||
public UserTypeResolution(
|
||||
CustomType userTypeAdapter,
|
||||
MutabilityPlan explicitMutabilityPlan) {
|
||||
this.userTypeAdapter = userTypeAdapter;
|
||||
this.mutabilityPlan = explicitMutabilityPlan != null
|
||||
? explicitMutabilityPlan
|
||||
: new UserTypeMutabilityPlanAdapter( userTypeAdapter.getUserType() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaTypeDescriptor<?> getDomainJavaDescriptor() {
|
||||
return userTypeAdapter.getJavaTypeDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaTypeDescriptor<?> getRelationalJavaDescriptor() {
|
||||
return userTypeAdapter.getJavaTypeDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqlTypeDescriptor getRelationalSqlTypeDescriptor() {
|
||||
return userTypeAdapter.getSqlTypeDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasicValueConverter getValueConverter() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutabilityPlan getMutabilityPlan() {
|
||||
return mutabilityPlan;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasicType getResolvedBasicType() {
|
||||
return userTypeAdapter;
|
||||
}
|
||||
}
|
@ -10,6 +10,7 @@
|
||||
|
||||
import org.hibernate.boot.AttributeConverterInfo;
|
||||
import org.hibernate.boot.jaxb.spi.Binding;
|
||||
import org.hibernate.boot.model.convert.spi.ConverterDescriptor;
|
||||
import org.hibernate.cfg.AttributeConverterDefinition;
|
||||
|
||||
/**
|
||||
@ -32,7 +33,7 @@ public interface ManagedResources {
|
||||
*
|
||||
* @return The AttributeConverter definitions.
|
||||
*/
|
||||
Collection<AttributeConverterInfo> getAttributeConverterDefinitions();
|
||||
Collection<ConverterDescriptor> getAttributeConverterDescriptors();
|
||||
|
||||
/**
|
||||
* Informational access to any entity and component classes in the user domain model known by Class
|
||||
|
@ -10,7 +10,6 @@
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hibernate.boot.AttributeConverterInfo;
|
||||
import org.hibernate.boot.MetadataSources;
|
||||
import org.hibernate.boot.internal.InFlightMetadataCollectorImpl;
|
||||
import org.hibernate.boot.internal.MetadataBuildingContextRootImpl;
|
||||
@ -40,7 +39,6 @@
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
import org.hibernate.usertype.CompositeUserType;
|
||||
import org.hibernate.usertype.UserType;
|
||||
|
||||
import org.jboss.jandex.IndexView;
|
||||
@ -130,11 +128,7 @@ public static MetadataImplementor complete(
|
||||
metadataCollector
|
||||
);
|
||||
|
||||
for ( AttributeConverterInfo converterInfo : managedResources.getAttributeConverterDefinitions() ) {
|
||||
metadataCollector.addAttributeConverter(
|
||||
converterInfo.toConverterDescriptor( rootMetadataBuildingContext )
|
||||
);
|
||||
}
|
||||
managedResources.getAttributeConverterDescriptors().forEach( metadataCollector::addAttributeConverter );
|
||||
|
||||
bootstrapContext.getTypeConfiguration().scope( rootMetadataBuildingContext );
|
||||
|
||||
@ -345,11 +339,6 @@ public void contributeType(UserType type, String[] keys) {
|
||||
getBasicTypeRegistry().register( type, keys );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contributeType(CompositeUserType type, String[] keys) {
|
||||
getBasicTypeRegistry().register( type, keys );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void contributeJavaTypeDescriptor(JavaTypeDescriptor descriptor) {
|
||||
bootstrapContext.getTypeConfiguration().getJavaTypeDescriptorRegistry().addDescriptor( descriptor );
|
||||
|
@ -10,6 +10,7 @@
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.hibernate.boot.jaxb.hbm.spi.ConfigParameterContainer;
|
||||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmConfigParameterType;
|
||||
@ -23,6 +24,12 @@ public static Map<String, String> extractConfigParameters(ConfigParameterContain
|
||||
return extractConfigParameters( container.getConfigParameters() );
|
||||
}
|
||||
|
||||
public static Properties extractConfigParametersAsProperties(ConfigParameterContainer container) {
|
||||
final Properties properties = new Properties();
|
||||
properties.putAll( extractConfigParameters( container.getConfigParameters() ) );
|
||||
return properties;
|
||||
}
|
||||
|
||||
private static Map<String, String> extractConfigParameters(List<JaxbHbmConfigParameterType> paramElementList) {
|
||||
if ( CollectionHelper.isEmpty( paramElementList ) ) {
|
||||
return Collections.emptyMap();
|
||||
|
@ -23,7 +23,7 @@
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class FilterDefinitionBinder {
|
||||
class FilterDefinitionBinder {
|
||||
private static final Logger log = Logger.getLogger( FilterDefinitionBinder.class );
|
||||
|
||||
/**
|
||||
@ -33,14 +33,14 @@ public class FilterDefinitionBinder {
|
||||
* @param jaxbFilterDefinitionMapping The {@code <filter-def/>} JAXB mapping
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void processFilterDefinition(
|
||||
static void processFilterDefinition(
|
||||
HbmLocalMetadataBuildingContext context,
|
||||
JaxbHbmFilterDefinitionType jaxbFilterDefinitionMapping) {
|
||||
Map<String,Type> parameterMap = null;
|
||||
String condition = jaxbFilterDefinitionMapping.getCondition();
|
||||
|
||||
for ( Serializable content : jaxbFilterDefinitionMapping.getContent() ) {
|
||||
if ( String.class.isInstance( content ) ) {
|
||||
if ( content instanceof String ) {
|
||||
final String contentString = content.toString().trim();
|
||||
if ( StringHelper.isNotEmpty( contentString ) ) {
|
||||
if ( condition != null ) {
|
||||
@ -54,10 +54,10 @@ public static void processFilterDefinition(
|
||||
}
|
||||
else {
|
||||
final JaxbHbmFilterParameterType jaxbParameterMapping;
|
||||
if ( JaxbHbmFilterParameterType.class.isInstance( content ) ) {
|
||||
if ( content instanceof JaxbHbmFilterParameterType ) {
|
||||
jaxbParameterMapping = (JaxbHbmFilterParameterType) content;
|
||||
}
|
||||
else if ( JAXBElement.class.isInstance( content ) ) {
|
||||
else if ( content instanceof JAXBElement ) {
|
||||
final JAXBElement<JaxbHbmFilterParameterType> jaxbElement = (JAXBElement<JaxbHbmFilterParameterType>) content;
|
||||
jaxbParameterMapping = jaxbElement.getValue();
|
||||
}
|
||||
@ -69,12 +69,12 @@ else if ( JAXBElement.class.isInstance( content ) ) {
|
||||
}
|
||||
|
||||
if ( parameterMap == null ) {
|
||||
parameterMap = new HashMap<String, Type>();
|
||||
parameterMap = new HashMap<>();
|
||||
}
|
||||
|
||||
parameterMap.put(
|
||||
jaxbParameterMapping.getParameterName(),
|
||||
context.getMetadataCollector().getTypeResolver().heuristicType( jaxbParameterMapping.getParameterValueTypeName() )
|
||||
context.getMetadataCollector().getTypeConfiguration().getBasicTypeRegistry().getRegisteredType( jaxbParameterMapping.getParameterValueTypeName() )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmNamedQueryType;
|
||||
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmTypeDefinitionType;
|
||||
import org.hibernate.boot.jaxb.hbm.spi.ResultSetMappingBindingDefinition;
|
||||
import org.hibernate.boot.model.TypeDefinitionRegistry;
|
||||
import org.hibernate.boot.model.naming.ObjectNameNormalizer;
|
||||
import org.hibernate.boot.model.source.internal.OverriddenMappingDefaults;
|
||||
import org.hibernate.boot.model.source.spi.MetadataSourceProcessor;
|
||||
@ -51,6 +52,8 @@ public class MappingDocument implements HbmLocalMetadataBuildingContext, Metadat
|
||||
|
||||
private final ToolingHintContext toolingHintContext;
|
||||
|
||||
private final TypeDefinitionRegistry typeDefinitionRegistry;
|
||||
|
||||
|
||||
public MappingDocument(
|
||||
JaxbHbmHibernateMapping documentRoot,
|
||||
@ -74,6 +77,8 @@ public MappingDocument(
|
||||
.build();
|
||||
|
||||
this.toolingHintContext = Helper.collectToolingHints( null, documentRoot );
|
||||
|
||||
this.typeDefinitionRegistry = new TypeDefinitionRegistry( rootBuildingContext.getTypeDefinitionRegistry() );
|
||||
}
|
||||
|
||||
public JaxbHbmHibernateMapping getDocumentRoot() {
|
||||
@ -153,6 +158,11 @@ public ObjectNameNormalizer getObjectNameNormalizer() {
|
||||
return rootBuildingContext.getObjectNameNormalizer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeDefinitionRegistry getTypeDefinitionRegistry() {
|
||||
return typeDefinitionRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepare() {
|
||||
// nothing to do here
|
||||
|
@ -113,6 +113,7 @@
|
||||
import org.hibernate.mapping.AttributeContainer;
|
||||
import org.hibernate.mapping.Backref;
|
||||
import org.hibernate.mapping.Bag;
|
||||
import org.hibernate.mapping.BasicValue;
|
||||
import org.hibernate.mapping.Collection;
|
||||
import org.hibernate.mapping.Column;
|
||||
import org.hibernate.mapping.Component;
|
||||
@ -150,7 +151,6 @@
|
||||
import org.hibernate.type.DiscriminatorType;
|
||||
import org.hibernate.type.ForeignKeyDirection;
|
||||
import org.hibernate.type.NClobType;
|
||||
import org.hibernate.type.TypeResolver;
|
||||
|
||||
/**
|
||||
* Responsible for coordinating the binding of all information inside entity tags ({@code <class/>}, etc).
|
||||
@ -704,7 +704,7 @@ private void bindSimpleEntityIdentifier(
|
||||
RootClass rootEntityDescriptor) {
|
||||
final IdentifierSourceSimple idSource = (IdentifierSourceSimple) hierarchySource.getIdentifierSource();
|
||||
|
||||
final SimpleValue idValue = new SimpleValue(
|
||||
final BasicValue idValue = new BasicValue(
|
||||
sourceDocument,
|
||||
rootEntityDescriptor.getTable()
|
||||
);
|
||||
@ -999,7 +999,7 @@ private void bindEntityVersion(
|
||||
RootClass rootEntityDescriptor) {
|
||||
final VersionAttributeSource versionAttributeSource = hierarchySource.getVersionAttributeSource();
|
||||
|
||||
final SimpleValue versionValue = new SimpleValue(
|
||||
final BasicValue versionValue = new BasicValue(
|
||||
sourceDocument,
|
||||
rootEntityDescriptor.getTable()
|
||||
);
|
||||
@ -1061,7 +1061,7 @@ private void bindEntityDiscriminator(
|
||||
MappingDocument sourceDocument,
|
||||
final EntityHierarchySourceImpl hierarchySource,
|
||||
RootClass rootEntityDescriptor) {
|
||||
final SimpleValue discriminatorValue = new SimpleValue(
|
||||
final BasicValue discriminatorValue = new BasicValue(
|
||||
sourceDocument,
|
||||
rootEntityDescriptor.getTable()
|
||||
);
|
||||
@ -1163,7 +1163,7 @@ private void bindAllEntityAttributes(
|
||||
final Property attribute = createBasicAttribute(
|
||||
mappingDocument,
|
||||
basicAttributeSource,
|
||||
new SimpleValue( mappingDocument, table ),
|
||||
new BasicValue( mappingDocument, table ),
|
||||
entityDescriptor.getClassName()
|
||||
);
|
||||
|
||||
@ -1961,10 +1961,13 @@ private void resolveLob(final SingularAttributeSourceBasic attributeSource, Simp
|
||||
// Resolves whether the property is LOB based on the type attribute on the attribute property source.
|
||||
// Essentially this expects the type to map to a CLOB/NCLOB/BLOB sql type internally and compares.
|
||||
if ( !value.isLob() && value.getTypeName() != null ) {
|
||||
final TypeResolver typeResolver = attributeSource.getBuildingContext().getMetadataCollector().getTypeResolver();
|
||||
final BasicType basicType = typeResolver.basic( value.getTypeName() );
|
||||
final BasicType<?> basicType = attributeSource.getBuildingContext()
|
||||
.getMetadataCollector()
|
||||
.getTypeConfiguration()
|
||||
.getBasicTypeRegistry()
|
||||
.getRegisteredType( value.getTypeName() );
|
||||
if ( basicType instanceof AbstractSingleColumnStandardBasicType ) {
|
||||
if ( isLob( ( (AbstractSingleColumnStandardBasicType) basicType ).getSqlTypeDescriptor().getSqlType(), null ) ) {
|
||||
if ( isLob( basicType.getSqlTypeDescriptor().getSqlType(), null ) ) {
|
||||
value.makeLob();
|
||||
}
|
||||
}
|
||||
@ -1974,7 +1977,7 @@ private void resolveLob(final SingularAttributeSourceBasic attributeSource, Simp
|
||||
// if this maps to CLOB/NCLOB/BLOB then the value will be marked as lob.
|
||||
if ( !value.isLob() ) {
|
||||
for ( RelationalValueSource relationalValueSource : attributeSource.getRelationalValueSources() ) {
|
||||
if ( ColumnSource.class.isInstance( relationalValueSource ) ) {
|
||||
if ( relationalValueSource instanceof ColumnSource ) {
|
||||
if ( isLob( null, ( (ColumnSource) relationalValueSource ).getSqlType() ) ) {
|
||||
value.makeLob();
|
||||
}
|
||||
@ -2362,17 +2365,18 @@ private void bindAny(
|
||||
anyBinding.setMetaType( discriminatorTypeResolution.typeName );
|
||||
try {
|
||||
final DiscriminatorType metaType = (DiscriminatorType) sourceDocument.getMetadataCollector()
|
||||
.getTypeResolver()
|
||||
.heuristicType( discriminatorTypeResolution.typeName );
|
||||
.getTypeConfiguration()
|
||||
.getBasicTypeRegistry()
|
||||
.getRegisteredType( discriminatorTypeResolution.typeName );
|
||||
|
||||
final HashMap anyValueBindingMap = new HashMap();
|
||||
final HashMap discriminatorValueToEntityNameMap = new HashMap();
|
||||
for ( Map.Entry<String,String> discriminatorValueMappings : anyMapping.getDiscriminatorSource().getValueMappings().entrySet() ) {
|
||||
try {
|
||||
final Object discriminatorValue = metaType.stringToObject( discriminatorValueMappings.getKey() );
|
||||
final String mappedEntityName = sourceDocument.qualifyClassName( discriminatorValueMappings.getValue() );
|
||||
|
||||
//noinspection unchecked
|
||||
anyValueBindingMap.put( discriminatorValue, mappedEntityName );
|
||||
discriminatorValueToEntityNameMap.put( discriminatorValue, mappedEntityName );
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new MappingException(
|
||||
@ -2389,7 +2393,7 @@ private void bindAny(
|
||||
}
|
||||
|
||||
}
|
||||
anyBinding.setMetaValues( anyValueBindingMap );
|
||||
anyBinding.setMetaValues( discriminatorValueToEntityNameMap );
|
||||
}
|
||||
catch (ClassCastException e) {
|
||||
throw new MappingException(
|
||||
@ -2410,14 +2414,9 @@ private void bindAny(
|
||||
anyMapping.getDiscriminatorSource().getRelationalValueSource(),
|
||||
anyBinding,
|
||||
true,
|
||||
new RelationalObjectBinder.ColumnNamingDelegate() {
|
||||
@Override
|
||||
public Identifier determineImplicitName(LocalMetadataBuildingContext context) {
|
||||
return implicitNamingStrategy.determineAnyDiscriminatorColumnName(
|
||||
anyMapping.getDiscriminatorSource()
|
||||
);
|
||||
}
|
||||
}
|
||||
context -> implicitNamingStrategy.determineAnyDiscriminatorColumnName(
|
||||
anyMapping.getDiscriminatorSource()
|
||||
)
|
||||
);
|
||||
|
||||
relationalObjectBinder.bindColumnsAndFormulas(
|
||||
@ -2425,14 +2424,9 @@ public Identifier determineImplicitName(LocalMetadataBuildingContext context) {
|
||||
anyMapping.getKeySource().getRelationalValueSources(),
|
||||
anyBinding,
|
||||
true,
|
||||
new RelationalObjectBinder.ColumnNamingDelegate() {
|
||||
@Override
|
||||
public Identifier determineImplicitName(LocalMetadataBuildingContext context) {
|
||||
return implicitNamingStrategy.determineAnyKeyColumnName(
|
||||
anyMapping.getKeySource()
|
||||
);
|
||||
}
|
||||
}
|
||||
context -> implicitNamingStrategy.determineAnyKeyColumnName(
|
||||
anyMapping.getKeySource()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@ -2730,7 +2724,7 @@ private void bindAllCompositeAttributes(
|
||||
attribute = createBasicAttribute(
|
||||
sourceDocument,
|
||||
(SingularAttributeSourceBasic) attributeSource,
|
||||
new SimpleValue( sourceDocument, component.getTable() ),
|
||||
new BasicValue( sourceDocument, component.getTable() ),
|
||||
component.getComponentClassName()
|
||||
);
|
||||
}
|
||||
@ -3352,7 +3346,7 @@ protected void bindCollectionIdentifier() {
|
||||
final CollectionIdSource idSource = getPluralAttributeSource().getCollectionIdSource();
|
||||
if ( idSource != null ) {
|
||||
final IdentifierCollection idBagBinding = (IdentifierCollection) getCollectionBinding();
|
||||
final SimpleValue idBinding = new SimpleValue(
|
||||
final BasicValue idBinding = new BasicValue(
|
||||
mappingDocument,
|
||||
idBagBinding.getCollectionTable()
|
||||
);
|
||||
@ -3399,7 +3393,7 @@ protected void bindCollectionElement() {
|
||||
if ( getPluralAttributeSource().getElementSource() instanceof PluralAttributeElementSourceBasic ) {
|
||||
final PluralAttributeElementSourceBasic elementSource =
|
||||
(PluralAttributeElementSourceBasic) getPluralAttributeSource().getElementSource();
|
||||
final SimpleValue elementBinding = new SimpleValue(
|
||||
final BasicValue elementBinding = new BasicValue(
|
||||
getMappingDocument(),
|
||||
getCollectionBinding().getCollectionTable()
|
||||
);
|
||||
@ -3884,7 +3878,7 @@ public void bindListOrArrayIndex(
|
||||
final PluralAttributeSequentialIndexSource indexSource =
|
||||
(PluralAttributeSequentialIndexSource) attributeSource.getIndexSource();
|
||||
|
||||
final SimpleValue indexBinding = new SimpleValue(
|
||||
final BasicValue indexBinding = new BasicValue(
|
||||
mappingDocument,
|
||||
collectionBinding.getCollectionTable()
|
||||
);
|
||||
@ -3931,7 +3925,7 @@ private void bindMapKey(
|
||||
if ( pluralAttributeSource.getIndexSource() instanceof PluralAttributeMapKeySourceBasic ) {
|
||||
final PluralAttributeMapKeySourceBasic mapKeySource =
|
||||
(PluralAttributeMapKeySourceBasic) pluralAttributeSource.getIndexSource();
|
||||
final SimpleValue value = new SimpleValue(
|
||||
final BasicValue value = new BasicValue(
|
||||
mappingDocument,
|
||||
collectionBinding.getCollectionTable()
|
||||
);
|
||||
|
@ -93,13 +93,10 @@ public static NativeSQLQueryScalarReturn extractReturnDescription(
|
||||
final String typeName = rtnSource.getType();
|
||||
Type type = null;
|
||||
if ( typeName != null ) {
|
||||
type = context.getMetadataCollector().getTypeResolver().heuristicType( typeName );
|
||||
type = context.getMetadataCollector().getTypeConfiguration().getBasicTypeRegistry().getRegisteredType( typeName );
|
||||
if ( type == null ) {
|
||||
throw new MappingException(
|
||||
String.format(
|
||||
"Unable to resolve type [%s] specified for native query scalar return",
|
||||
typeName
|
||||
),
|
||||
String.format( "Unable to resolve type [%s] specified for native query scalar return", typeName ),
|
||||
context.getOrigin()
|
||||
);
|
||||
}
|
||||
|
@ -33,7 +33,8 @@ public static void processTypeDefinition(
|
||||
typeDefinitionBinding.getName(),
|
||||
cls.classForName( typeDefinitionBinding.getClazz() ),
|
||||
null,
|
||||
ConfigParameterHelper.extractConfigParameters( typeDefinitionBinding )
|
||||
ConfigParameterHelper.extractConfigParametersAsProperties( typeDefinitionBinding ),
|
||||
context.getMetadataCollector().getTypeConfiguration()
|
||||
);
|
||||
|
||||
log.debugf(
|
||||
|
@ -29,7 +29,6 @@
|
||||
import org.hibernate.mapping.Table;
|
||||
import org.hibernate.query.named.NamedQueryRepository;
|
||||
import org.hibernate.type.Type;
|
||||
import org.hibernate.type.TypeResolver;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
/**
|
||||
@ -210,18 +209,6 @@ public TypeConfiguration getTypeConfiguration() {
|
||||
return delegate.getTypeConfiguration();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the {@link Type} resolver associated with this factory.
|
||||
*
|
||||
* @return The type resolver
|
||||
*
|
||||
* @deprecated (since 5.3) No replacement, access to and handling of Types will be much different in 6.0
|
||||
*/
|
||||
@Deprecated
|
||||
public TypeResolver getTypeResolver() {
|
||||
return delegate.getTypeResolver();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate() throws MappingException {
|
||||
delegate.validate();
|
||||
|
@ -9,7 +9,6 @@
|
||||
import javax.persistence.AttributeConverter;
|
||||
import javax.persistence.SharedCacheMode;
|
||||
|
||||
import org.hibernate.annotations.common.reflection.ReflectionManager;
|
||||
import org.hibernate.boot.CacheRegionDefinition;
|
||||
import org.hibernate.boot.Metadata;
|
||||
import org.hibernate.boot.MetadataBuilder;
|
||||
@ -19,15 +18,14 @@
|
||||
import org.hibernate.boot.archive.spi.ArchiveDescriptorFactory;
|
||||
import org.hibernate.boot.model.IdGeneratorStrategyInterpreter;
|
||||
import org.hibernate.boot.model.TypeContributor;
|
||||
import org.hibernate.boot.model.convert.spi.ConverterDescriptor;
|
||||
import org.hibernate.boot.model.naming.ImplicitNamingStrategy;
|
||||
import org.hibernate.boot.model.naming.PhysicalNamingStrategy;
|
||||
import org.hibernate.boot.model.relational.AuxiliaryDatabaseObject;
|
||||
import org.hibernate.cache.spi.access.AccessType;
|
||||
import org.hibernate.cfg.AttributeConverterDefinition;
|
||||
import org.hibernate.cfg.MetadataSourceType;
|
||||
import org.hibernate.dialect.function.SQLFunction;
|
||||
import org.hibernate.type.BasicType;
|
||||
import org.hibernate.usertype.CompositeUserType;
|
||||
import org.hibernate.usertype.UserType;
|
||||
|
||||
import org.jboss.jandex.IndexView;
|
||||
@ -184,12 +182,6 @@ public MetadataBuilder applyBasicType(UserType type, String... keys) {
|
||||
return getThis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetadataBuilder applyBasicType(CompositeUserType type, String... keys) {
|
||||
delegate.applyBasicType( type, keys );
|
||||
return getThis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetadataBuilder applyTypes(TypeContributor typeContributor) {
|
||||
delegate.applyTypes( typeContributor );
|
||||
@ -227,19 +219,19 @@ public MetadataBuilder applyAuxiliaryDatabaseObject(AuxiliaryDatabaseObject auxi
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetadataBuilder applyAttributeConverter(AttributeConverterDefinition definition) {
|
||||
delegate.applyAttributeConverter( definition );
|
||||
public MetadataBuilder applyAttributeConverter(ConverterDescriptor descriptor) {
|
||||
delegate.applyAttributeConverter( descriptor );
|
||||
return getThis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetadataBuilder applyAttributeConverter(Class<? extends AttributeConverter> attributeConverterClass) {
|
||||
public <O, R> MetadataBuilder applyAttributeConverter(Class<? extends AttributeConverter<O, R>> attributeConverterClass) {
|
||||
delegate.applyAttributeConverter( attributeConverterClass );
|
||||
return getThis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetadataBuilder applyAttributeConverter(Class<? extends AttributeConverter> attributeConverterClass, boolean autoApply) {
|
||||
public <O,R> MetadataBuilder applyAttributeConverter(Class<? extends AttributeConverter<O,R>> attributeConverterClass, boolean autoApply) {
|
||||
delegate.applyAttributeConverter( attributeConverterClass, autoApply );
|
||||
return getThis();
|
||||
}
|
||||
|
@ -163,21 +163,6 @@ public List<MetadataSourceType> getSourceProcessOrdering() {
|
||||
return delegate.getSourceProcessOrdering();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, SQLFunction> getSqlFunctions() {
|
||||
return delegate.getSqlFunctions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AuxiliaryDatabaseObject> getAuxiliaryDatabaseObjectList() {
|
||||
return delegate.getAuxiliaryDatabaseObjectList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AttributeConverterInfo> getAttributeConverters() {
|
||||
return delegate.getAttributeConverters();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(JpaOrmXmlPersistenceUnitDefaults jpaOrmXmlPersistenceUnitDefaults) {
|
||||
if ( delegate instanceof JpaOrmXmlPersistenceUnitDefaultAware ) {
|
||||
|
@ -7,9 +7,8 @@
|
||||
package org.hibernate.boot.spi;
|
||||
|
||||
import org.hibernate.type.BasicType;
|
||||
import org.hibernate.type.CompositeCustomType;
|
||||
import org.hibernate.type.CustomType;
|
||||
import org.hibernate.usertype.CompositeUserType;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
import org.hibernate.usertype.UserType;
|
||||
|
||||
/**
|
||||
@ -28,12 +27,8 @@ public BasicTypeRegistration(BasicType basicType, String[] registrationKeys) {
|
||||
this.registrationKeys = registrationKeys;
|
||||
}
|
||||
|
||||
public BasicTypeRegistration(UserType type, String[] keys) {
|
||||
this( new CustomType( type, keys ), keys );
|
||||
}
|
||||
|
||||
public BasicTypeRegistration(CompositeUserType type, String[] keys) {
|
||||
this( new CompositeCustomType( type, keys ), keys );
|
||||
public BasicTypeRegistration(UserType type, String[] keys, TypeConfiguration typeConfiguration) {
|
||||
this( new CustomType( type, keys, typeConfiguration ), keys );
|
||||
}
|
||||
|
||||
public BasicType getBasicType() {
|
||||
|
@ -9,13 +9,14 @@
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.Incubating;
|
||||
import org.hibernate.annotations.common.reflection.ReflectionManager;
|
||||
import org.hibernate.boot.AttributeConverterInfo;
|
||||
import org.hibernate.boot.CacheRegionDefinition;
|
||||
import org.hibernate.boot.archive.scan.spi.ScanEnvironment;
|
||||
import org.hibernate.boot.archive.scan.spi.ScanOptions;
|
||||
import org.hibernate.boot.archive.spi.ArchiveDescriptorFactory;
|
||||
import org.hibernate.boot.internal.ClassmateContext;
|
||||
import org.hibernate.boot.model.convert.spi.ConverterDescriptor;
|
||||
import org.hibernate.boot.model.relational.AuxiliaryDatabaseObject;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||
import org.hibernate.dialect.function.SQLFunction;
|
||||
@ -31,6 +32,7 @@
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@Incubating
|
||||
public interface BootstrapContext {
|
||||
StandardServiceRegistry getServiceRegistry();
|
||||
|
||||
@ -148,7 +150,7 @@ public interface BootstrapContext {
|
||||
*
|
||||
* @return The AttributeConverterInfo registered through MetadataBuilder
|
||||
*/
|
||||
Collection<AttributeConverterInfo> getAttributeConverters();
|
||||
Collection<ConverterDescriptor> getAttributeConverters();
|
||||
|
||||
/**
|
||||
* Access to all explicit cache region mappings.
|
||||
|
@ -6,7 +6,10 @@
|
||||
*/
|
||||
package org.hibernate.boot.spi;
|
||||
|
||||
import org.hibernate.boot.model.TypeDefinition;
|
||||
import org.hibernate.boot.model.TypeDefinitionRegistry;
|
||||
import org.hibernate.boot.model.naming.ObjectNameNormalizer;
|
||||
import org.hibernate.internal.util.config.ConfigurationHelper;
|
||||
|
||||
/**
|
||||
* Describes the context in which the process of building Metadata out of MetadataSources occurs.
|
||||
@ -20,6 +23,7 @@
|
||||
*/
|
||||
public interface MetadataBuildingContext {
|
||||
BootstrapContext getBootstrapContext();
|
||||
|
||||
/**
|
||||
* Access to the options specified by the {@link org.hibernate.boot.MetadataBuilder}
|
||||
*
|
||||
@ -57,4 +61,10 @@ public interface MetadataBuildingContext {
|
||||
* @return
|
||||
*/
|
||||
ObjectNameNormalizer getObjectNameNormalizer();
|
||||
|
||||
default int getPreferredSqlTypeCodeForBoolean() {
|
||||
return ConfigurationHelper.getPreferredSqlTypeCodeForBoolean( getBootstrapContext().getServiceRegistry() );
|
||||
}
|
||||
|
||||
TypeDefinitionRegistry getTypeDefinitionRegistry();
|
||||
}
|
||||
|
@ -70,7 +70,6 @@ default CollectionSemanticsResolver getPersistentCollectionRepresentationResolve
|
||||
* <li>{@link org.hibernate.boot.MetadataBuilder#applyBasicType(org.hibernate.type.BasicType)}</li>
|
||||
* <li>{@link org.hibernate.boot.MetadataBuilder#applyBasicType(org.hibernate.type.BasicType, String[])}</li>
|
||||
* <li>{@link org.hibernate.boot.MetadataBuilder#applyBasicType(org.hibernate.usertype.UserType, java.lang.String[])}</li>
|
||||
* <li>{@link org.hibernate.boot.MetadataBuilder#applyBasicType(org.hibernate.usertype.CompositeUserType, java.lang.String[])}</li>
|
||||
* </ul>
|
||||
*
|
||||
* @return The BasicType registrations
|
||||
@ -257,36 +256,4 @@ default String getSchemaCharset() {
|
||||
default boolean isXmlMappingEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access to any SQL functions explicitly registered with the MetadataBuilder. This
|
||||
* does not include Dialect defined functions, etc.
|
||||
*
|
||||
* @return The SQLFunctions registered through MetadataBuilder
|
||||
*
|
||||
* @deprecated Use {@link BootstrapContext#getSqlFunctions()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
Map<String,SQLFunction> getSqlFunctions();
|
||||
|
||||
/**
|
||||
* Access to any AuxiliaryDatabaseObject explicitly registered with the MetadataBuilder. This
|
||||
* does not include AuxiliaryDatabaseObject defined in mappings.
|
||||
*
|
||||
* @return The AuxiliaryDatabaseObject registered through MetadataBuilder
|
||||
*
|
||||
* @deprecated Use {@link BootstrapContext#getAuxiliaryDatabaseObjectList()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
List<AuxiliaryDatabaseObject> getAuxiliaryDatabaseObjectList();
|
||||
|
||||
/**
|
||||
* Access to collected AttributeConverter definitions.
|
||||
*
|
||||
* @return The AttributeConverterInfo registered through MetadataBuilder
|
||||
*
|
||||
* @deprecated Use {@link BootstrapContext#getAttributeConverters()} instead
|
||||
*/
|
||||
@Deprecated
|
||||
List<AttributeConverterInfo> getAttributeConverters();
|
||||
}
|
||||
|
@ -15,7 +15,6 @@
|
||||
import org.hibernate.mapping.MappedSuperclass;
|
||||
import org.hibernate.query.named.NamedQueryRepository;
|
||||
import org.hibernate.type.Type;
|
||||
import org.hibernate.type.TypeResolver;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
/**
|
||||
@ -38,16 +37,6 @@ public interface MetadataImplementor extends Metadata, Mapping {
|
||||
*/
|
||||
TypeConfiguration getTypeConfiguration();
|
||||
|
||||
/**
|
||||
* Retrieve the {@link Type} resolver associated with this factory.
|
||||
*
|
||||
* @return The type resolver
|
||||
*
|
||||
* @deprecated (since 5.3) No replacement, access to and handling of Types will be much different in 6.0
|
||||
*/
|
||||
@Deprecated
|
||||
TypeResolver getTypeResolver();
|
||||
|
||||
NamedQueryRepository buildNamedQueryRepository(SessionFactoryImplementor sessionFactory);
|
||||
|
||||
void validate() throws MappingException;
|
||||
|
@ -152,6 +152,7 @@
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.loader.PropertyPath;
|
||||
import org.hibernate.mapping.Any;
|
||||
import org.hibernate.mapping.BasicValue;
|
||||
import org.hibernate.mapping.Component;
|
||||
import org.hibernate.mapping.Constraint;
|
||||
import org.hibernate.mapping.DependantValue;
|
||||
@ -1353,9 +1354,16 @@ private static void bindFilterDefs(XAnnotatedElement annotatedElement, MetadataB
|
||||
private static void bindFilterDef(FilterDef defAnn, MetadataBuildingContext context) {
|
||||
Map<String, org.hibernate.type.Type> params = new HashMap<>();
|
||||
for ( ParamDef param : defAnn.parameters() ) {
|
||||
params.put( param.name(), context.getMetadataCollector().getTypeResolver().heuristicType( param.type() ) );
|
||||
params.put(
|
||||
param.name(),
|
||||
context.getMetadataCollector()
|
||||
.getTypeConfiguration()
|
||||
.getBasicTypeRegistry()
|
||||
.getRegisteredType( param.type() )
|
||||
);
|
||||
}
|
||||
FilterDefinition def = new FilterDefinition( defAnn.name(), defAnn.defaultCondition(), params );
|
||||
|
||||
final FilterDefinition def = new FilterDefinition( defAnn.name(), defAnn.defaultCondition(), params );
|
||||
LOG.debugf( "Binding filter definition: %s", def.getFilterName() );
|
||||
context.getMetadataCollector().addFilterDefinition( def );
|
||||
}
|
||||
@ -1396,7 +1404,8 @@ private static void bindTypeDef(TypeDef defAnn, MetadataBuildingContext context)
|
||||
defAnn.name(),
|
||||
defAnn.typeClass(),
|
||||
null,
|
||||
params
|
||||
params,
|
||||
context.getMetadataCollector().getTypeConfiguration()
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -1410,7 +1419,8 @@ private static void bindTypeDef(TypeDef defAnn, MetadataBuildingContext context)
|
||||
defAnn.defaultForType().getName(),
|
||||
defAnn.typeClass(),
|
||||
new String[]{ defAnn.defaultForType().getName() },
|
||||
params
|
||||
params,
|
||||
context.getMetadataCollector().getTypeConfiguration()
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -1460,7 +1470,7 @@ private static void bindDiscriminatorColumnToRootPersistentClass(
|
||||
}
|
||||
discriminatorColumn.setJoins( secondaryTables );
|
||||
discriminatorColumn.setPropertyHolder( propertyHolder );
|
||||
SimpleValue discriminatorColumnBinding = new SimpleValue( context, rootClass.getTable() );
|
||||
BasicValue discriminatorColumnBinding = new BasicValue( context, rootClass.getTable() );
|
||||
rootClass.setDiscriminator( discriminatorColumnBinding );
|
||||
discriminatorColumn.linkWithValue( discriminatorColumnBinding );
|
||||
discriminatorColumnBinding.setTypeName( discriminatorColumn.getDiscriminatorTypeName() );
|
||||
|
@ -2116,4 +2116,12 @@ public interface AvailableSettings extends org.hibernate.jpa.AvailableSettings {
|
||||
*/
|
||||
String OMIT_JOIN_OF_SUPERCLASS_TABLES = "hibernate.query.omit_join_of_superclass_tables";
|
||||
|
||||
|
||||
/**
|
||||
* Global setting identifying the preferred JDBC type code for storing
|
||||
* boolean values. The fallback is to ask the Dialect
|
||||
*
|
||||
* @since 6.0
|
||||
*/
|
||||
String PREFERRED_BOOLEAN_JDBC_TYPE_CODE = "hibernate.type.perferred_boolean_jdbc_type_code";
|
||||
}
|
||||
|
@ -970,7 +970,7 @@ public static Any buildAnyValue(
|
||||
value.setMetaType( metaAnnDef.metaType() );
|
||||
|
||||
HashMap values = new HashMap();
|
||||
org.hibernate.type.Type metaType = context.getMetadataCollector().getTypeResolver().heuristicType( value.getMetaType() );
|
||||
org.hibernate.type.Type metaType = context.getMetadataCollector().getTypeConfiguration().getBasicTypeRegistry().getRegisteredType( value.getMetaType() );
|
||||
for (MetaValue metaValue : metaAnnDef.metaValues()) {
|
||||
try {
|
||||
Object discrim = ( (org.hibernate.type.DiscriminatorType) metaType ).stringToObject( metaValue
|
||||
|
@ -29,7 +29,12 @@
|
||||
import org.hibernate.boot.MetadataBuilder;
|
||||
import org.hibernate.boot.MetadataSources;
|
||||
import org.hibernate.boot.SessionFactoryBuilder;
|
||||
import org.hibernate.boot.internal.ClassmateContext;
|
||||
import org.hibernate.boot.internal.NamedProcedureCallDefinitionImpl;
|
||||
import org.hibernate.boot.model.TypeContributor;
|
||||
import org.hibernate.boot.model.convert.internal.ClassBasedConverterDescriptor;
|
||||
import org.hibernate.boot.model.convert.internal.InstanceBasedConverterDescriptor;
|
||||
import org.hibernate.boot.model.convert.spi.ConverterDescriptor;
|
||||
import org.hibernate.boot.model.naming.ImplicitNamingStrategy;
|
||||
import org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl;
|
||||
import org.hibernate.boot.model.naming.PhysicalNamingStrategy;
|
||||
@ -40,23 +45,19 @@
|
||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||
import org.hibernate.cfg.annotations.NamedEntityGraphDefinition;
|
||||
import org.hibernate.boot.internal.NamedProcedureCallDefinitionImpl;
|
||||
import org.hibernate.context.spi.CurrentTenantIdentifierResolver;
|
||||
import org.hibernate.dialect.function.SQLFunction;
|
||||
import org.hibernate.query.sql.spi.NamedNativeQueryMemento;
|
||||
import org.hibernate.query.sql.spi.ResultSetMappingDescriptor;
|
||||
import org.hibernate.query.hql.internal.NamedHqlQueryMementoImpl;
|
||||
import org.hibernate.internal.CoreLogging;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.internal.util.xml.XmlDocument;
|
||||
import org.hibernate.proxy.EntityNotFoundDelegate;
|
||||
import org.hibernate.query.hql.internal.NamedHqlQueryMementoImpl;
|
||||
import org.hibernate.query.sql.spi.NamedNativeQueryMemento;
|
||||
import org.hibernate.query.sql.spi.ResultSetMappingDescriptor;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.tuple.entity.EntityTuplizerFactory;
|
||||
import org.hibernate.type.BasicType;
|
||||
import org.hibernate.type.CompositeCustomType;
|
||||
import org.hibernate.type.CustomType;
|
||||
import org.hibernate.type.SerializationException;
|
||||
import org.hibernate.usertype.CompositeUserType;
|
||||
import org.hibernate.usertype.UserType;
|
||||
|
||||
/**
|
||||
@ -88,11 +89,13 @@ public class Configuration {
|
||||
|
||||
private final BootstrapServiceRegistry bootstrapServiceRegistry;
|
||||
private final MetadataSources metadataSources;
|
||||
private final ClassmateContext classmateContext;
|
||||
|
||||
// used during processing mappings
|
||||
private ImplicitNamingStrategy implicitNamingStrategy;
|
||||
private PhysicalNamingStrategy physicalNamingStrategy;
|
||||
private List<BasicType> basicTypes = new ArrayList<>();
|
||||
private List<UserTypeRegistration> userTypeRegistrations;
|
||||
private List<TypeContributor> typeContributorRegistrations = new ArrayList<>();
|
||||
private Map<String, NamedHqlQueryMementoImpl> namedQueries;
|
||||
private Map<String, NamedNativeQueryMemento> namedSqlQueries;
|
||||
@ -102,7 +105,7 @@ public class Configuration {
|
||||
|
||||
private Map<String, SQLFunction> sqlFunctions;
|
||||
private List<AuxiliaryDatabaseObject> auxiliaryDatabaseObjectList;
|
||||
private HashMap<Class,AttributeConverterDefinition> attributeConverterDefinitionsByClass;
|
||||
private HashMap<Class, ConverterDescriptor> attributeConverterDescriptorsByClass;
|
||||
|
||||
// used to build SF
|
||||
private StandardServiceRegistryBuilder standardServiceRegistryBuilder;
|
||||
@ -121,12 +124,14 @@ public Configuration() {
|
||||
public Configuration(BootstrapServiceRegistry serviceRegistry) {
|
||||
this.bootstrapServiceRegistry = serviceRegistry;
|
||||
this.metadataSources = new MetadataSources( serviceRegistry );
|
||||
this.classmateContext = new ClassmateContext();
|
||||
reset();
|
||||
}
|
||||
|
||||
public Configuration(MetadataSources metadataSources) {
|
||||
this.bootstrapServiceRegistry = getBootstrapRegistry( metadataSources.getServiceRegistry() );
|
||||
this.metadataSources = metadataSources;
|
||||
this.classmateContext = new ClassmateContext();
|
||||
reset();
|
||||
}
|
||||
|
||||
@ -328,14 +333,17 @@ public Configuration registerTypeOverride(BasicType type) {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public Configuration registerTypeOverride(UserType type, String[] keys) {
|
||||
basicTypes.add( new CustomType( type, keys ) );
|
||||
return this;
|
||||
private interface UserTypeRegistration {
|
||||
void registerType(MetadataBuilder metadataBuilder);
|
||||
}
|
||||
|
||||
public Configuration registerTypeOverride(CompositeUserType type, String[] keys) {
|
||||
basicTypes.add( new CompositeCustomType( type, keys ) );
|
||||
public Configuration registerTypeOverride(UserType type, String[] keys) {
|
||||
if ( userTypeRegistrations == null ) {
|
||||
userTypeRegistrations = new ArrayList<>();
|
||||
}
|
||||
userTypeRegistrations.add(
|
||||
metadataBuilder -> metadataBuilder.applyBasicType( type, keys )
|
||||
);
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -651,56 +659,70 @@ public void setCurrentTenantIdentifierResolver(CurrentTenantIdentifierResolver c
|
||||
public SessionFactory buildSessionFactory(ServiceRegistry serviceRegistry) throws HibernateException {
|
||||
log.debug( "Building session factory using provided StandardServiceRegistry" );
|
||||
final MetadataBuilder metadataBuilder = metadataSources.getMetadataBuilder( (StandardServiceRegistry) serviceRegistry );
|
||||
|
||||
if ( implicitNamingStrategy != null ) {
|
||||
metadataBuilder.applyImplicitNamingStrategy( implicitNamingStrategy );
|
||||
}
|
||||
|
||||
if ( physicalNamingStrategy != null ) {
|
||||
metadataBuilder.applyPhysicalNamingStrategy( physicalNamingStrategy );
|
||||
}
|
||||
|
||||
if ( sharedCacheMode != null ) {
|
||||
metadataBuilder.applySharedCacheMode( sharedCacheMode );
|
||||
}
|
||||
|
||||
if ( !typeContributorRegistrations.isEmpty() ) {
|
||||
for ( TypeContributor typeContributor : typeContributorRegistrations ) {
|
||||
metadataBuilder.applyTypes( typeContributor );
|
||||
}
|
||||
}
|
||||
|
||||
if ( userTypeRegistrations != null ) {
|
||||
userTypeRegistrations.forEach( registration -> registration.registerType( metadataBuilder ) );
|
||||
}
|
||||
|
||||
if ( !basicTypes.isEmpty() ) {
|
||||
for ( BasicType basicType : basicTypes ) {
|
||||
metadataBuilder.applyBasicType( basicType );
|
||||
}
|
||||
}
|
||||
|
||||
if ( sqlFunctions != null ) {
|
||||
for ( Map.Entry<String, SQLFunction> entry : sqlFunctions.entrySet() ) {
|
||||
metadataBuilder.applySqlFunction( entry.getKey(), entry.getValue() );
|
||||
}
|
||||
}
|
||||
|
||||
if ( auxiliaryDatabaseObjectList != null ) {
|
||||
for ( AuxiliaryDatabaseObject auxiliaryDatabaseObject : auxiliaryDatabaseObjectList ) {
|
||||
metadataBuilder.applyAuxiliaryDatabaseObject( auxiliaryDatabaseObject );
|
||||
}
|
||||
}
|
||||
if ( attributeConverterDefinitionsByClass != null ) {
|
||||
for ( AttributeConverterDefinition attributeConverterDefinition : attributeConverterDefinitionsByClass.values() ) {
|
||||
metadataBuilder.applyAttributeConverter( attributeConverterDefinition );
|
||||
}
|
||||
|
||||
if ( attributeConverterDescriptorsByClass != null ) {
|
||||
attributeConverterDescriptorsByClass.values().forEach( metadataBuilder::applyAttributeConverter );
|
||||
}
|
||||
|
||||
final Metadata metadata = metadataBuilder.build();
|
||||
|
||||
final SessionFactoryBuilder sessionFactoryBuilder = metadata.getSessionFactoryBuilder();
|
||||
|
||||
if ( interceptor != null && interceptor != EmptyInterceptor.INSTANCE ) {
|
||||
sessionFactoryBuilder.applyInterceptor( interceptor );
|
||||
}
|
||||
|
||||
if ( getSessionFactoryObserver() != null ) {
|
||||
sessionFactoryBuilder.addSessionFactoryObservers( getSessionFactoryObserver() );
|
||||
}
|
||||
|
||||
if ( getEntityNotFoundDelegate() != null ) {
|
||||
sessionFactoryBuilder.applyEntityNotFoundDelegate( getEntityNotFoundDelegate() );
|
||||
}
|
||||
|
||||
if ( getEntityTuplizerFactory() != null ) {
|
||||
sessionFactoryBuilder.applyEntityTuplizerFactory( getEntityTuplizerFactory() );
|
||||
}
|
||||
|
||||
if ( getCurrentTenantIdentifierResolver() != null ) {
|
||||
sessionFactoryBuilder.applyCurrentTenantIdentifierResolver( getCurrentTenantIdentifierResolver() );
|
||||
}
|
||||
@ -752,7 +774,7 @@ public void addAuxiliaryDatabaseObject(AuxiliaryDatabaseObject object) {
|
||||
* by its "entity attribute" parameterized type?
|
||||
*/
|
||||
public void addAttributeConverter(Class<? extends AttributeConverter> attributeConverterClass, boolean autoApply) {
|
||||
addAttributeConverter( AttributeConverterDefinition.from( attributeConverterClass, autoApply ) );
|
||||
addAttributeConverter( new ClassBasedConverterDescriptor( attributeConverterClass, autoApply, classmateContext ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -760,8 +782,8 @@ public void addAttributeConverter(Class<? extends AttributeConverter> attributeC
|
||||
*
|
||||
* @param attributeConverterClass The AttributeConverter class.
|
||||
*/
|
||||
public void addAttributeConverter(Class<? extends AttributeConverter> attributeConverterClass) {
|
||||
addAttributeConverter( AttributeConverterDefinition.from( attributeConverterClass ) );
|
||||
public void addAttributeConverter(Class<? extends AttributeConverter<?,?>> attributeConverterClass) {
|
||||
addAttributeConverter( new ClassBasedConverterDescriptor( attributeConverterClass, classmateContext ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -771,8 +793,8 @@ public void addAttributeConverter(Class<? extends AttributeConverter> attributeC
|
||||
*
|
||||
* @param attributeConverter The AttributeConverter instance.
|
||||
*/
|
||||
public void addAttributeConverter(AttributeConverter attributeConverter) {
|
||||
addAttributeConverter( AttributeConverterDefinition.from( attributeConverter ) );
|
||||
public void addAttributeConverter(AttributeConverter<?,?> attributeConverter) {
|
||||
addAttributeConverter( new InstanceBasedConverterDescriptor( attributeConverter, classmateContext ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -784,15 +806,15 @@ public void addAttributeConverter(AttributeConverter attributeConverter) {
|
||||
* @param autoApply Should the AttributeConverter be auto applied to property types as specified
|
||||
* by its "entity attribute" parameterized type?
|
||||
*/
|
||||
public void addAttributeConverter(AttributeConverter attributeConverter, boolean autoApply) {
|
||||
addAttributeConverter( AttributeConverterDefinition.from( attributeConverter, autoApply ) );
|
||||
public void addAttributeConverter(AttributeConverter<?,?> attributeConverter, boolean autoApply) {
|
||||
addAttributeConverter( new InstanceBasedConverterDescriptor( attributeConverter, autoApply, classmateContext ) );
|
||||
}
|
||||
|
||||
public void addAttributeConverter(AttributeConverterDefinition definition) {
|
||||
if ( attributeConverterDefinitionsByClass == null ) {
|
||||
attributeConverterDefinitionsByClass = new HashMap<Class, AttributeConverterDefinition>();
|
||||
public void addAttributeConverter(ConverterDescriptor converterDescriptor) {
|
||||
if ( attributeConverterDescriptorsByClass == null ) {
|
||||
attributeConverterDescriptorsByClass = new HashMap<>();
|
||||
}
|
||||
attributeConverterDefinitionsByClass.put( definition.getAttributeConverter().getClass(), definition );
|
||||
attributeConverterDescriptorsByClass.put( converterDescriptor.getAttributeConverterClass(), converterDescriptor );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -16,6 +16,7 @@
|
||||
import org.hibernate.AssertionFailure;
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||
import org.hibernate.mapping.BasicValue;
|
||||
import org.hibernate.mapping.Column;
|
||||
import org.hibernate.mapping.Component;
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
@ -150,7 +151,7 @@ private Property createSimpleProperty(
|
||||
//property.setOptional( property.isOptional() );
|
||||
property.setPersistentClass( component.getOwner() );
|
||||
property.setPropertyAccessorName( referencedProperty.getPropertyAccessorName() );
|
||||
SimpleValue value = new SimpleValue( buildingContext, component.getTable() );
|
||||
SimpleValue value = new BasicValue( buildingContext, component.getTable() );
|
||||
property.setValue( value );
|
||||
final SimpleValue referencedValue = (SimpleValue) referencedProperty.getValue();
|
||||
value.setTypeName( referencedValue.getTypeName() );
|
||||
|
@ -42,6 +42,7 @@
|
||||
import org.hibernate.cfg.SecondPass;
|
||||
import org.hibernate.dialect.HSQLDialect;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.mapping.BasicValue;
|
||||
import org.hibernate.mapping.Collection;
|
||||
import org.hibernate.mapping.Column;
|
||||
import org.hibernate.mapping.Component;
|
||||
@ -496,7 +497,7 @@ else if ( value instanceof SimpleValue ) {
|
||||
targetValue = targetManyToOne;
|
||||
}
|
||||
else {
|
||||
targetValue = new SimpleValue( getBuildingContext(), collection.getCollectionTable() );
|
||||
targetValue = new BasicValue( getBuildingContext(), collection.getCollectionTable() );
|
||||
targetValue.copyTypeFrom( sourceValue );
|
||||
}
|
||||
Iterator columns = sourceValue.getColumnIterator();
|
||||
|
@ -43,12 +43,12 @@
|
||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.mapping.BasicValue;
|
||||
import org.hibernate.mapping.SimpleValue;
|
||||
import org.hibernate.mapping.Table;
|
||||
import org.hibernate.type.CharacterArrayClobType;
|
||||
import org.hibernate.type.CharacterArrayNClobType;
|
||||
import org.hibernate.type.CharacterNCharType;
|
||||
import org.hibernate.type.EnumType;
|
||||
import org.hibernate.type.PrimitiveCharacterArrayClobType;
|
||||
import org.hibernate.type.PrimitiveCharacterArrayNClobType;
|
||||
import org.hibernate.type.SerializableToBlobType;
|
||||
@ -67,26 +67,30 @@ public class SimpleValueBinder {
|
||||
|
||||
private MetadataBuildingContext buildingContext;
|
||||
|
||||
private String explicitType = "";
|
||||
private String defaultType = "";
|
||||
|
||||
private String propertyName;
|
||||
private String returnedClassName;
|
||||
private Ejb3Column[] columns;
|
||||
private String persistentClassName;
|
||||
private String explicitType = "";
|
||||
private String defaultType = "";
|
||||
private Properties typeParameters = new Properties();
|
||||
private boolean isNationalized;
|
||||
private boolean isLob;
|
||||
|
||||
private Table table;
|
||||
private SimpleValue simpleValue;
|
||||
private boolean isVersion;
|
||||
private BasicValue simpleValue;
|
||||
private String timeStampVersionType;
|
||||
//is a Map key
|
||||
private boolean key;
|
||||
private String referencedEntityName;
|
||||
private XProperty xproperty;
|
||||
private AccessType accessType;
|
||||
|
||||
//is a Map key
|
||||
private boolean key;
|
||||
|
||||
private boolean isVersion;
|
||||
private boolean isNationalized;
|
||||
private boolean isLob;
|
||||
private javax.persistence.EnumType enumerationStyle;
|
||||
|
||||
private ConverterDescriptor attributeConverterDescriptor;
|
||||
|
||||
public void setReferencedEntityName(String referencedEntityName) {
|
||||
@ -280,8 +284,8 @@ else if ( ( !key && property.isAnnotationPresent( Enumerated.class ) )
|
||||
)
|
||||
);
|
||||
}
|
||||
type = EnumType.class.getName();
|
||||
explicitType = type;
|
||||
|
||||
this.enumerationStyle = determineEnumType( property, key );
|
||||
}
|
||||
else if ( isNationalized ) {
|
||||
if ( buildingContext.getBootstrapContext().getReflectionManager().equals( returnedClassOrElement, String.class ) ) {
|
||||
@ -310,7 +314,7 @@ else if ( buildingContext.getBootstrapContext().getReflectionManager().equals( r
|
||||
|
||||
if ( BinderHelper.ANNOTATION_STRING_DEFAULT.equals( type ) ) {
|
||||
if ( returnedClassOrElement.isEnum() ) {
|
||||
type = EnumType.class.getName();
|
||||
this.enumerationStyle = determineEnumType( property, key );
|
||||
}
|
||||
}
|
||||
|
||||
@ -320,6 +324,16 @@ else if ( buildingContext.getBootstrapContext().getReflectionManager().equals( r
|
||||
applyAttributeConverter( property, attributeConverterDescriptor );
|
||||
}
|
||||
|
||||
private static javax.persistence.EnumType determineEnumType(XProperty property, boolean mapKey) {
|
||||
if ( mapKey ) {
|
||||
final MapKeyEnumerated annotation = property.getAnnotation( MapKeyEnumerated.class );
|
||||
return annotation == null ? javax.persistence.EnumType.ORDINAL : annotation.value();
|
||||
}
|
||||
|
||||
final Enumerated annotation = property.getAnnotation( Enumerated.class );
|
||||
return annotation == null ? javax.persistence.EnumType.ORDINAL : annotation.value();
|
||||
}
|
||||
|
||||
private Dialect getDialect() {
|
||||
return buildingContext.getBuildingOptions()
|
||||
.getServiceRegistry()
|
||||
@ -414,13 +428,20 @@ private void validate() {
|
||||
}
|
||||
|
||||
public SimpleValue make() {
|
||||
|
||||
validate();
|
||||
|
||||
LOG.debugf( "building SimpleValue for %s", propertyName );
|
||||
|
||||
if ( table == null ) {
|
||||
table = columns[0].getTable();
|
||||
}
|
||||
simpleValue = new SimpleValue( buildingContext, table );
|
||||
|
||||
simpleValue = new BasicValue( buildingContext, table );
|
||||
|
||||
if ( enumerationStyle != null ) {
|
||||
simpleValue.setEnumerationStyle( enumerationStyle );
|
||||
}
|
||||
|
||||
if ( isVersion ) {
|
||||
simpleValue.makeVersion();
|
||||
}
|
||||
@ -482,7 +503,11 @@ public void fillSimpleValue() {
|
||||
);
|
||||
simpleValue.setJpaAttributeConverterDescriptor( attributeConverterDescriptor );
|
||||
}
|
||||
else if ( enumerationStyle != null ) {
|
||||
simpleValue.setEnumerationStyle( enumerationStyle );
|
||||
}
|
||||
else {
|
||||
|
||||
String type;
|
||||
TypeDefinition typeDef;
|
||||
|
||||
@ -541,7 +566,7 @@ public void fillSimpleValue() {
|
||||
}
|
||||
|
||||
if ( simpleValue.getTypeName() != null && simpleValue.getTypeName().length() > 0
|
||||
&& simpleValue.getMetadata().getTypeResolver().basic( simpleValue.getTypeName() ) == null ) {
|
||||
&& simpleValue.getMetadata().getTypeConfiguration().getBasicTypeRegistry().getRegisteredType( simpleValue.getTypeName() ) == null ) {
|
||||
try {
|
||||
Class typeClass = buildingContext.getBootstrapContext().getClassLoaderAccess().classForName( simpleValue.getTypeName() );
|
||||
|
||||
|
@ -3018,6 +3018,13 @@ public boolean supportsJdbcConnectionLobCreation(DatabaseMetaData databaseMetaDa
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getPreferredSqlTypeCodeForBoolean() {
|
||||
// BIT is the safest option as most databases do not support a
|
||||
// boolean data-type. And BIT happens to be the JDBC recommended
|
||||
// mapping
|
||||
return Types.BIT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape String literal.
|
||||
*
|
||||
|
@ -46,7 +46,7 @@ public String render(Type columnType, List args, SessionFactoryImplementor facto
|
||||
throw new QueryException( "cast() requires two arguments; found : " + args.size() );
|
||||
}
|
||||
final String type = (String) args.get( 1 );
|
||||
final int[] sqlTypeCodes = factory.getTypeResolver().heuristicType( type ).sqlTypes( factory );
|
||||
final int[] sqlTypeCodes = factory.getTypeConfiguration().getBasicTypeRegistry().getRegisteredType( type ).sqlTypes( factory );
|
||||
if ( sqlTypeCodes.length!=1 ) {
|
||||
throw new QueryException("invalid Hibernate type for cast()");
|
||||
}
|
||||
|
@ -39,6 +39,18 @@ public String convert(Object value) {
|
||||
}
|
||||
};
|
||||
|
||||
public static final Converter<Integer> INTEGER = value -> {
|
||||
if ( value == null ) {
|
||||
throw new IllegalArgumentException( "Null value passed to convert" );
|
||||
}
|
||||
|
||||
if ( value instanceof Number ) {
|
||||
return ( (Number) value ).intValue();
|
||||
}
|
||||
|
||||
return Integer.parseInt( value.toString() );
|
||||
};
|
||||
|
||||
/**
|
||||
* Disallow direct instantiation
|
||||
*/
|
||||
|
@ -41,7 +41,6 @@
|
||||
import org.hibernate.SharedSessionBuilder;
|
||||
import org.hibernate.SimpleNaturalIdLoadAccess;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.TypeHelper;
|
||||
import org.hibernate.UnknownProfileException;
|
||||
import org.hibernate.cache.spi.CacheTransactionSynchronization;
|
||||
import org.hibernate.collection.spi.PersistentCollection;
|
||||
@ -1022,11 +1021,6 @@ public void disableFetchProfile(String name) throws UnknownProfileException {
|
||||
delegate.disableFetchProfile( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeHelper getTypeHelper() {
|
||||
return delegate.getTypeHelper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LobHelper getLobHelper() {
|
||||
return delegate.getLobHelper();
|
||||
|
@ -28,7 +28,6 @@
|
||||
import org.hibernate.SessionFactoryObserver;
|
||||
import org.hibernate.StatelessSession;
|
||||
import org.hibernate.StatelessSessionBuilder;
|
||||
import org.hibernate.TypeHelper;
|
||||
import org.hibernate.boot.spi.SessionFactoryOptions;
|
||||
import org.hibernate.cache.spi.CacheImplementor;
|
||||
import org.hibernate.cfg.Settings;
|
||||
@ -51,11 +50,9 @@
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.proxy.EntityNotFoundDelegate;
|
||||
import org.hibernate.query.spi.QueryEngine;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
import org.hibernate.service.spi.ServiceRegistryImplementor;
|
||||
import org.hibernate.stat.spi.StatisticsImplementor;
|
||||
import org.hibernate.type.Type;
|
||||
import org.hibernate.type.TypeResolver;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
/**
|
||||
@ -191,23 +188,6 @@ public boolean containsFetchProfileDefinition(String name) {
|
||||
return delegate.containsFetchProfileDefinition( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeHelper getTypeHelper() {
|
||||
return delegate.getTypeHelper();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the {@link Type} resolver associated with this factory.
|
||||
*
|
||||
* @return The type resolver
|
||||
*
|
||||
* @deprecated (since 5.3) No replacement, access to and handling of Types will be much different in 6.0
|
||||
*/
|
||||
@Deprecated
|
||||
public TypeResolver getTypeResolver() {
|
||||
return delegate.getTypeResolver();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IdentifierGenerator getIdentifierGenerator(String rootEntityName) {
|
||||
return delegate.getIdentifierGenerator( rootEntityName );
|
||||
|
@ -43,8 +43,6 @@
|
||||
import org.hibernate.service.spi.ServiceRegistryImplementor;
|
||||
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
||||
import org.hibernate.stat.spi.StatisticsImplementor;
|
||||
import org.hibernate.type.Type;
|
||||
import org.hibernate.type.TypeResolver;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
/**
|
||||
@ -78,6 +76,10 @@ public interface SessionFactoryImplementor
|
||||
|
||||
TypeConfiguration getTypeConfiguration();
|
||||
|
||||
default SessionFactoryImplementor getSessionFactory() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
default DomainMetamodel getDomainModel() {
|
||||
return getMetamodel();
|
||||
@ -117,16 +119,6 @@ default DomainMetamodel getDomainModel() {
|
||||
*/
|
||||
FetchProfile getFetchProfile(String name);
|
||||
|
||||
/**
|
||||
* Retrieve the {@link Type} resolver associated with this factory.
|
||||
*
|
||||
* @return The type resolver
|
||||
*
|
||||
* @deprecated (since 5.2) No replacement, access to and handling of Types will be much different in 6.0
|
||||
*/
|
||||
@Deprecated
|
||||
TypeResolver getTypeResolver();
|
||||
|
||||
/**
|
||||
* Get the identifier generator for the hierarchy
|
||||
*/
|
||||
|
@ -49,7 +49,6 @@
|
||||
import org.hibernate.SessionFactoryObserver;
|
||||
import org.hibernate.StatelessSession;
|
||||
import org.hibernate.StatelessSessionBuilder;
|
||||
import org.hibernate.TypeHelper;
|
||||
import org.hibernate.boot.cfgxml.spi.CfgXmlAccessService;
|
||||
import org.hibernate.boot.cfgxml.spi.LoadedConfig;
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||
@ -118,7 +117,6 @@
|
||||
import org.hibernate.query.spi.QueryImplementor;
|
||||
import org.hibernate.query.sql.spi.NativeQueryImplementor;
|
||||
import org.hibernate.query.sqm.NodeBuilder;
|
||||
import org.hibernate.query.sqm.internal.SqmCriteriaNodeBuilder;
|
||||
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
|
||||
import org.hibernate.resource.jdbc.spi.StatementInspector;
|
||||
import org.hibernate.resource.transaction.backend.jta.internal.synchronization.AfterCompletionAction;
|
||||
@ -135,7 +133,6 @@
|
||||
import org.hibernate.tool.schema.spi.DelayedDropAction;
|
||||
import org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator;
|
||||
import org.hibernate.type.Type;
|
||||
import org.hibernate.type.TypeResolver;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
@ -197,8 +194,6 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor {
|
||||
private final transient Map<String, FilterDefinition> filters;
|
||||
private final transient Map<String, FetchProfile> fetchProfiles;
|
||||
|
||||
private final transient TypeHelper typeHelper;
|
||||
|
||||
private final transient FastSessionServices fastSessionServices;
|
||||
private final transient SessionBuilder defaultSessionOpenOptions;
|
||||
private final transient SessionBuilder temporarySessionOpenOptions;
|
||||
@ -255,8 +250,6 @@ public SessionFactoryImpl(
|
||||
this.observer.addObserver( sessionFactoryObserver );
|
||||
}
|
||||
|
||||
this.typeHelper = new TypeLocatorImpl( bootMetamodel.getTypeConfiguration().getTypeResolver() );
|
||||
|
||||
this.filters = new HashMap<>();
|
||||
this.filters.putAll( bootMetamodel.getFilterDefinitions() );
|
||||
|
||||
@ -600,18 +593,6 @@ public IdentifierGeneratorFactory getIdentifierGeneratorFactory() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the {@link Type} resolver associated with this factory.
|
||||
*
|
||||
* @return The type resolver
|
||||
*
|
||||
* @deprecated (since 5.3) No replacement, access to and handling of Types will be much different in 6.0
|
||||
*/
|
||||
@Deprecated
|
||||
public TypeResolver getTypeResolver() {
|
||||
return metamodel.getTypeConfiguration().getTypeResolver();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeserializationResolver getDeserializationResolver() {
|
||||
return (DeserializationResolver) () -> (SessionFactoryImplementor) SessionFactoryRegistry.INSTANCE.findSessionFactory(
|
||||
@ -1046,10 +1027,6 @@ public FetchProfile getFetchProfile(String name) {
|
||||
return fetchProfiles.get( name );
|
||||
}
|
||||
|
||||
public TypeHelper getTypeHelper() {
|
||||
return typeHelper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AllowableParameterType<?> resolveParameterBindType(Object bindValue) {
|
||||
if ( bindValue == null ) {
|
||||
|
@ -60,7 +60,6 @@
|
||||
import org.hibernate.SimpleNaturalIdLoadAccess;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.TransientObjectException;
|
||||
import org.hibernate.TypeHelper;
|
||||
import org.hibernate.TypeMismatchException;
|
||||
import org.hibernate.UnknownProfileException;
|
||||
import org.hibernate.UnresolvableObjectException;
|
||||
@ -1880,11 +1879,6 @@ public void disableFetchProfile(String name) throws UnknownProfileException {
|
||||
loadQueryInfluencers.disableFetchProfile( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeHelper getTypeHelper() {
|
||||
return getSessionFactory().getTypeHelper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LobHelper getLobHelper() {
|
||||
if ( lobHelper == null ) {
|
||||
|
@ -1,152 +0,0 @@
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.internal;
|
||||
import java.io.Serializable;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.hibernate.TypeHelper;
|
||||
import org.hibernate.type.BasicType;
|
||||
import org.hibernate.type.Type;
|
||||
import org.hibernate.type.TypeResolver;
|
||||
import org.hibernate.usertype.CompositeUserType;
|
||||
|
||||
/**
|
||||
* Implementation of {@link org.hibernate.TypeHelper}
|
||||
*
|
||||
* @todo Do we want to cache the results of {@link #entity}, {@link #custom} and {@link #any} ?
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class TypeLocatorImpl implements TypeHelper, Serializable {
|
||||
private final TypeResolver typeResolver;
|
||||
|
||||
public TypeLocatorImpl(TypeResolver typeResolver) {
|
||||
this.typeResolver = typeResolver;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasicType basic(String name) {
|
||||
return typeResolver.basic( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasicType basic(Class javaType) {
|
||||
BasicType type = typeResolver.basic( javaType.getName() );
|
||||
if ( type == null ) {
|
||||
final Class variant = resolvePrimitiveOrPrimitiveWrapperVariantJavaType( javaType );
|
||||
if ( variant != null ) {
|
||||
type = typeResolver.basic( variant.getName() );
|
||||
}
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
private Class resolvePrimitiveOrPrimitiveWrapperVariantJavaType(Class javaType) {
|
||||
// boolean
|
||||
if ( Boolean.TYPE.equals( javaType ) ) {
|
||||
return Boolean.class;
|
||||
}
|
||||
if ( Boolean.class.equals( javaType ) ) {
|
||||
return Boolean.TYPE;
|
||||
}
|
||||
|
||||
// char
|
||||
if ( Character.TYPE.equals( javaType ) ) {
|
||||
return Character.class;
|
||||
}
|
||||
if ( Character.class.equals( javaType ) ) {
|
||||
return Character.TYPE;
|
||||
}
|
||||
|
||||
// byte
|
||||
if ( Byte.TYPE.equals( javaType ) ) {
|
||||
return Byte.class;
|
||||
}
|
||||
if ( Byte.class.equals( javaType ) ) {
|
||||
return Byte.TYPE;
|
||||
}
|
||||
|
||||
// short
|
||||
if ( Short.TYPE.equals( javaType ) ) {
|
||||
return Short.class;
|
||||
}
|
||||
if ( Short.class.equals( javaType ) ) {
|
||||
return Short.TYPE;
|
||||
}
|
||||
|
||||
// int
|
||||
if ( Integer.TYPE.equals( javaType ) ) {
|
||||
return Integer.class;
|
||||
}
|
||||
if ( Integer.class.equals( javaType ) ) {
|
||||
return Integer.TYPE;
|
||||
}
|
||||
|
||||
// long
|
||||
if ( Long.TYPE.equals( javaType ) ) {
|
||||
return Long.class;
|
||||
}
|
||||
if ( Long.class.equals( javaType ) ) {
|
||||
return Long.TYPE;
|
||||
}
|
||||
|
||||
// float
|
||||
if ( Float.TYPE.equals( javaType ) ) {
|
||||
return Float.class;
|
||||
}
|
||||
if ( Float.class.equals( javaType ) ) {
|
||||
return Float.TYPE;
|
||||
}
|
||||
|
||||
// double
|
||||
if ( Double.TYPE.equals( javaType ) ) {
|
||||
return Double.class;
|
||||
}
|
||||
if ( Double.class.equals( javaType ) ) {
|
||||
return Double.TYPE;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type heuristicType(String name) {
|
||||
return typeResolver.heuristicType( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type entity(Class entityClass) {
|
||||
return entity( entityClass.getName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type entity(String entityName) {
|
||||
return typeResolver.getTypeFactory().manyToOne( entityName );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "unchecked" })
|
||||
public Type custom(Class userTypeClass) {
|
||||
return custom( userTypeClass, null );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "unchecked" })
|
||||
public Type custom(Class userTypeClass, Properties parameters) {
|
||||
if ( CompositeUserType.class.isAssignableFrom( userTypeClass ) ) {
|
||||
return typeResolver.getTypeFactory().customComponent( userTypeClass, parameters );
|
||||
}
|
||||
else {
|
||||
return typeResolver.getTypeFactory().custom( userTypeClass, parameters );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type any(Type metaType, Type identifierType) {
|
||||
return typeResolver.getTypeFactory().any( metaType, identifierType );
|
||||
}
|
||||
}
|
@ -13,6 +13,7 @@
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Function;
|
||||
|
@ -18,66 +18,122 @@
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class StandardStack<T> implements Stack<T> {
|
||||
private LinkedList<T> internalStack = new LinkedList<>();
|
||||
@SuppressWarnings("unchecked")
|
||||
private final T nullMarker = (T) new Object();
|
||||
|
||||
private T current;
|
||||
|
||||
private LinkedList<T> internalStack;
|
||||
|
||||
public StandardStack() {
|
||||
}
|
||||
|
||||
public StandardStack(T initial) {
|
||||
internalStack.add( initial );
|
||||
current = initial;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void push(T newCurrent) {
|
||||
internalStack.addFirst( newCurrent );
|
||||
if ( newCurrent == null ) {
|
||||
newCurrent = nullMarker;
|
||||
}
|
||||
|
||||
if ( current != null ) {
|
||||
if ( internalStack == null ) {
|
||||
internalStack = new LinkedList<>();
|
||||
}
|
||||
internalStack.addFirst( current );
|
||||
}
|
||||
|
||||
current = newCurrent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T pop() {
|
||||
return internalStack.removeFirst();
|
||||
final T popped = this.current;
|
||||
if ( internalStack == null || internalStack.isEmpty() ) {
|
||||
this.current = null;
|
||||
}
|
||||
else {
|
||||
this.current = internalStack.removeFirst();
|
||||
}
|
||||
|
||||
return popped == nullMarker ? null : popped;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getCurrent() {
|
||||
return internalStack.peek();
|
||||
return current == nullMarker ? null : current;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T getPrevious() {
|
||||
if ( internalStack.size() < 2 ) {
|
||||
return null;
|
||||
if ( current != null && internalStack != null ) {
|
||||
final T previous = internalStack.getFirst();
|
||||
return previous == nullMarker ? null : previous;
|
||||
}
|
||||
return internalStack.get( internalStack.size() - 2 );
|
||||
|
||||
// otherwise...
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int depth() {
|
||||
return internalStack.size();
|
||||
if ( current == null ) {
|
||||
return 0;
|
||||
}
|
||||
else if ( internalStack == null || internalStack.isEmpty() ) {
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return internalStack.size() + 1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return internalStack.isEmpty();
|
||||
return current == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
internalStack.clear();
|
||||
current = null;
|
||||
if ( internalStack != null ) {
|
||||
internalStack.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitCurrentFirst(Consumer<T> action) {
|
||||
internalStack.forEach( action );
|
||||
if ( current != null ) {
|
||||
action.accept( current );
|
||||
if ( internalStack != null ) {
|
||||
internalStack.forEach( action );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <X> X findCurrentFirst(Function<T, X> function) {
|
||||
for ( T t : internalStack ) {
|
||||
final X result = function.apply( t );
|
||||
if ( result != null ) {
|
||||
return result;
|
||||
if ( current != null ) {
|
||||
{
|
||||
final X result = function.apply( current );
|
||||
|
||||
if ( result != null ) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
if ( internalStack != null ) {
|
||||
for ( T t : internalStack ) {
|
||||
final X result = function.apply( t );
|
||||
if ( result != null ) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,11 @@
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.engine.config.spi.ConfigurationService;
|
||||
import org.hibernate.engine.config.spi.StandardConverters;
|
||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.internal.util.collections.ArrayHelper;
|
||||
|
||||
@ -490,4 +495,21 @@ private static String extractFromSystem(String systemPropertyName) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized int getPreferredSqlTypeCodeForBoolean(StandardServiceRegistry serviceRegistry) {
|
||||
final Integer typeCode = serviceRegistry.getService( ConfigurationService.class ).getSetting(
|
||||
AvailableSettings.PREFERRED_BOOLEAN_JDBC_TYPE_CODE,
|
||||
StandardConverters.INTEGER
|
||||
);
|
||||
if ( typeCode != null ) {
|
||||
return typeCode;
|
||||
}
|
||||
|
||||
// default to the Dialect answer
|
||||
return serviceRegistry.getService( JdbcServices.class )
|
||||
.getJdbcEnvironment()
|
||||
.getDialect()
|
||||
.getPreferredSqlTypeCodeForBoolean();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,6 +35,8 @@
|
||||
import org.hibernate.boot.cfgxml.spi.CfgXmlAccessService;
|
||||
import org.hibernate.boot.cfgxml.spi.LoadedConfig;
|
||||
import org.hibernate.boot.cfgxml.spi.MappingReference;
|
||||
import org.hibernate.boot.model.convert.internal.ClassBasedConverterDescriptor;
|
||||
import org.hibernate.boot.model.convert.spi.ConverterDescriptor;
|
||||
import org.hibernate.boot.model.process.spi.ManagedResources;
|
||||
import org.hibernate.boot.model.process.spi.MetadataBuildingProcess;
|
||||
import org.hibernate.boot.registry.BootstrapServiceRegistry;
|
||||
@ -53,7 +55,6 @@
|
||||
import org.hibernate.bytecode.enhance.spi.EnhancementContext;
|
||||
import org.hibernate.bytecode.enhance.spi.UnloadedClass;
|
||||
import org.hibernate.bytecode.enhance.spi.UnloadedField;
|
||||
import org.hibernate.cfg.AttributeConverterDefinition;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.cfg.beanvalidation.BeanValidationIntegrator;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
@ -210,7 +211,7 @@ private EntityManagerFactoryBuilderImpl(
|
||||
configure( standardServiceRegistry, mergedSettings );
|
||||
|
||||
final MetadataSources metadataSources = new MetadataSources( bsr );
|
||||
List<AttributeConverterDefinition> attributeConverterDefinitions = populate(
|
||||
List<ConverterDescriptor> attributeConverterDefinitions = populate(
|
||||
metadataSources,
|
||||
mergedSettings,
|
||||
standardServiceRegistry
|
||||
@ -743,7 +744,7 @@ private void configure(StandardServiceRegistry ssr, MergedSettings mergedSetting
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected List<AttributeConverterDefinition> populate(
|
||||
protected List<ConverterDescriptor> populate(
|
||||
MetadataSources metadataSources,
|
||||
MergedSettings mergedSettings,
|
||||
StandardServiceRegistry ssr) {
|
||||
@ -788,17 +789,19 @@ protected List<AttributeConverterDefinition> populate(
|
||||
// }
|
||||
// }
|
||||
|
||||
List<AttributeConverterDefinition> attributeConverterDefinitions = null;
|
||||
List<ConverterDescriptor> converterDescriptors = null;
|
||||
|
||||
// add any explicit Class references passed in
|
||||
final List<Class> loadedAnnotatedClasses = (List<Class>) configurationValues.remove( AvailableSettings.LOADED_CLASSES );
|
||||
if ( loadedAnnotatedClasses != null ) {
|
||||
for ( Class cls : loadedAnnotatedClasses ) {
|
||||
if ( AttributeConverter.class.isAssignableFrom( cls ) ) {
|
||||
if ( attributeConverterDefinitions == null ) {
|
||||
attributeConverterDefinitions = new ArrayList<>();
|
||||
if ( converterDescriptors == null ) {
|
||||
converterDescriptors = new ArrayList<>();
|
||||
}
|
||||
attributeConverterDefinitions.add( AttributeConverterDefinition.from( (Class<? extends AttributeConverter>) cls ) );
|
||||
converterDescriptors.add(
|
||||
new ClassBasedConverterDescriptor( cls, metamodelBuilder.getBootstrapContext().getClassmateContext() )
|
||||
);
|
||||
}
|
||||
else {
|
||||
metadataSources.addAnnotatedClass( cls );
|
||||
@ -820,14 +823,14 @@ protected List<AttributeConverterDefinition> populate(
|
||||
explicitOrmXmlList.forEach( metadataSources::addResource );
|
||||
}
|
||||
|
||||
return attributeConverterDefinitions;
|
||||
return converterDescriptors;
|
||||
}
|
||||
|
||||
protected void populate(
|
||||
MetadataBuilder metamodelBuilder,
|
||||
MergedSettings mergedSettings,
|
||||
StandardServiceRegistry ssr,
|
||||
List<AttributeConverterDefinition> attributeConverterDefinitions) {
|
||||
List<ConverterDescriptor> converterDescriptors) {
|
||||
( (MetadataBuilderImplementor) metamodelBuilder ).getBootstrapContext().markAsJpaBootstrap();
|
||||
|
||||
if ( persistenceUnit.getTempClassLoader() != null ) {
|
||||
@ -853,8 +856,8 @@ protected void populate(
|
||||
typeContributorList.getTypeContributors().forEach( metamodelBuilder::applyTypes );
|
||||
}
|
||||
|
||||
if ( attributeConverterDefinitions != null ) {
|
||||
attributeConverterDefinitions.forEach( metamodelBuilder::applyAttributeConverter );
|
||||
if ( converterDescriptors != null ) {
|
||||
converterDescriptors.forEach( metamodelBuilder::applyAttributeConverter );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,8 @@
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.type.Type;
|
||||
import org.hibernate.type.descriptor.java.BasicJavaDescriptor;
|
||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||
|
||||
/**
|
||||
* Simplified access to JDBC ResultSetMetaData
|
||||
@ -74,39 +76,22 @@ public Type getHibernateType(int columnPos) throws SQLException {
|
||||
length = resultSetMetaData.getColumnDisplaySize( columnPos );
|
||||
}
|
||||
|
||||
String hibernateTypeName;
|
||||
|
||||
//Get the contributed Hibernate Type first
|
||||
Set<String> hibernateTypeNames = factory.getMetamodel()
|
||||
.getTypeConfiguration()
|
||||
.getJdbcToHibernateTypeContributionMap()
|
||||
.get( columnType );
|
||||
|
||||
//If the user has not supplied any JDBC Type to Hibernate Type mapping, use the Dialect-based mapping
|
||||
if ( hibernateTypeNames != null && !hibernateTypeNames.isEmpty() ) {
|
||||
if ( hibernateTypeNames.size() > 1 ) {
|
||||
throw new HibernateException(
|
||||
String.format(
|
||||
"There are multiple Hibernate types: [%s] registered for the [%d] JDBC type code",
|
||||
String.join( ", ", hibernateTypeNames ),
|
||||
columnType
|
||||
) );
|
||||
}
|
||||
else {
|
||||
hibernateTypeName = hibernateTypeNames.iterator().next();
|
||||
}
|
||||
}
|
||||
else {
|
||||
hibernateTypeName = factory.getDialect().getHibernateTypeName(
|
||||
columnType,
|
||||
length,
|
||||
precision,
|
||||
scale
|
||||
);
|
||||
}
|
||||
|
||||
return factory.getTypeResolver().heuristicType(
|
||||
hibernateTypeName
|
||||
final String hibernateTypeName = factory.getDialect().getHibernateTypeName(
|
||||
columnType,
|
||||
length,
|
||||
precision,
|
||||
scale
|
||||
);
|
||||
|
||||
if ( hibernateTypeName != null ) {
|
||||
return factory.getTypeConfiguration().getBasicTypeRegistry().getRegisteredType( hibernateTypeName );
|
||||
}
|
||||
|
||||
final SqlTypeDescriptor columnSqlTypeDescriptor = factory.getTypeConfiguration()
|
||||
.getSqlTypeDescriptorRegistry()
|
||||
.getDescriptor( columnType );
|
||||
final BasicJavaDescriptor<Object> relationalJtd = columnSqlTypeDescriptor.getJdbcRecommendedJavaTypeMapping( factory.getTypeConfiguration() );
|
||||
|
||||
return factory.getTypeConfiguration().getBasicTypeRegistry().resolve( relationalJtd, columnSqlTypeDescriptor );
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
import org.hibernate.engine.spi.LoadQueryInfluencers;
|
||||
import org.hibernate.metamodel.mapping.ModelPart;
|
||||
import org.hibernate.query.NavigablePath;
|
||||
import org.hibernate.query.sqm.sql.SqlExpressionResolver;
|
||||
import org.hibernate.sql.ast.JoinType;
|
||||
import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator;
|
||||
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
|
||||
@ -38,6 +39,7 @@ default TableGroup createRootTableGroup(
|
||||
JoinType tableReferenceJoinType,
|
||||
LockMode lockMode,
|
||||
SqlAliasBaseGenerator aliasBaseGenerator,
|
||||
SqlExpressionResolver sqlExpressionResolver,
|
||||
SqlAstCreationContext creationContext) {
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
}
|
||||
|
@ -12,7 +12,6 @@
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||
import org.hibernate.boot.spi.MetadataImplementor;
|
||||
import org.hibernate.type.MetaType;
|
||||
import org.hibernate.type.Type;
|
||||
|
||||
/**
|
||||
@ -23,7 +22,7 @@
|
||||
public class Any extends SimpleValue {
|
||||
private String identifierTypeName;
|
||||
private String metaTypeName = "string";
|
||||
private Map metaValues;
|
||||
private Map<Object,String> metaValueToEntityNameMap;
|
||||
private boolean lazy = true;
|
||||
|
||||
/**
|
||||
@ -47,12 +46,15 @@ public void setIdentifierType(String identifierType) {
|
||||
}
|
||||
|
||||
public Type getType() throws MappingException {
|
||||
final Type metaType = getMetadata().getTypeResolver().heuristicType( metaTypeName );
|
||||
final Type metaType = getMetadata().getTypeConfiguration().getBasicTypeRegistry().getRegisteredType( metaTypeName );
|
||||
final Type identifierType = getMetadata().getTypeConfiguration().getBasicTypeRegistry().getRegisteredType( identifierTypeName );
|
||||
|
||||
return getMetadata().getTypeResolver().getTypeFactory().any(
|
||||
metaValues == null ? metaType : new MetaType( metaValues, metaType ),
|
||||
getMetadata().getTypeResolver().heuristicType( identifierTypeName ),
|
||||
isLazy()
|
||||
return MappingHelper.anyMapping(
|
||||
metaType,
|
||||
identifierType,
|
||||
metaValueToEntityNameMap,
|
||||
isLazy(),
|
||||
getBuildingContext()
|
||||
);
|
||||
}
|
||||
|
||||
@ -67,11 +69,12 @@ public void setMetaType(String type) {
|
||||
}
|
||||
|
||||
public Map getMetaValues() {
|
||||
return metaValues;
|
||||
return metaValueToEntityNameMap;
|
||||
}
|
||||
|
||||
public void setMetaValues(Map metaValues) {
|
||||
this.metaValues = metaValues;
|
||||
public void setMetaValues(Map metaValueToEntityNameMap) {
|
||||
//noinspection unchecked
|
||||
this.metaValueToEntityNameMap = metaValueToEntityNameMap;
|
||||
}
|
||||
|
||||
public boolean isLazy() {
|
||||
@ -99,7 +102,7 @@ public boolean isSame(Any other) {
|
||||
return super.isSame( other )
|
||||
&& Objects.equals( identifierTypeName, other.identifierTypeName )
|
||||
&& Objects.equals( metaTypeName, other.metaTypeName )
|
||||
&& Objects.equals( metaValues, other.metaValues )
|
||||
&& Objects.equals( metaValueToEntityNameMap, other.metaValueToEntityNameMap )
|
||||
&& lazy == other.lazy;
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
|
||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||
import org.hibernate.boot.spi.MetadataImplementor;
|
||||
import org.hibernate.type.ArrayType;
|
||||
import org.hibernate.type.CollectionType;
|
||||
import org.hibernate.type.PrimitiveType;
|
||||
|
||||
@ -22,14 +23,6 @@
|
||||
public class Array extends List {
|
||||
private String elementClassName;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link Array#Array(MetadataBuildingContext, PersistentClass)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public Array(MetadataImplementor metadata, PersistentClass owner) {
|
||||
super( metadata, owner );
|
||||
}
|
||||
|
||||
public Array(MetadataBuildingContext buildingContext, PersistentClass owner) {
|
||||
super( buildingContext, owner );
|
||||
}
|
||||
@ -56,9 +49,7 @@ public Class getElementClass() throws MappingException {
|
||||
|
||||
@Override
|
||||
public CollectionType getDefaultCollectionType() throws MappingException {
|
||||
return getMetadata().getTypeResolver()
|
||||
.getTypeFactory()
|
||||
.array( getRole(), getReferencedPropertyName(), getElementClass() );
|
||||
return new ArrayType( getTypeConfiguration(), getRole(), getReferencedPropertyName(), getElementClass() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -7,7 +7,7 @@
|
||||
package org.hibernate.mapping;
|
||||
|
||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||
import org.hibernate.boot.spi.MetadataImplementor;
|
||||
import org.hibernate.type.BagType;
|
||||
import org.hibernate.type.CollectionType;
|
||||
|
||||
/**
|
||||
@ -16,23 +16,12 @@
|
||||
* @author Gavin King
|
||||
*/
|
||||
public class Bag extends Collection {
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link Bag#Bag(MetadataBuildingContext, PersistentClass)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public Bag(MetadataImplementor metadata, PersistentClass owner) {
|
||||
super( metadata, owner );
|
||||
}
|
||||
|
||||
public Bag(MetadataBuildingContext buildingContext, PersistentClass owner) {
|
||||
super( buildingContext, owner );
|
||||
}
|
||||
|
||||
public CollectionType getDefaultCollectionType() {
|
||||
return getMetadata().getTypeResolver()
|
||||
.getTypeFactory()
|
||||
.bag( getRole(), getReferencedPropertyName() );
|
||||
return new BagType( getMetadata().getTypeConfiguration(), getRole(), getReferencedPropertyName() );
|
||||
}
|
||||
|
||||
void createPrimaryKey() {
|
||||
|
@ -0,0 +1,626 @@
|
||||
/*
|
||||
* 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.mapping;
|
||||
|
||||
import java.util.Properties;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.TemporalType;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.boot.model.TypeDefinition;
|
||||
import org.hibernate.boot.model.convert.spi.ConverterDescriptor;
|
||||
import org.hibernate.boot.model.convert.spi.JpaAttributeConverterCreationContext;
|
||||
import org.hibernate.boot.model.process.internal.InferredBasicValueResolution;
|
||||
import org.hibernate.boot.model.process.internal.InferredBasicValueResolver;
|
||||
import org.hibernate.boot.model.process.internal.NamedBasicTypeResolution;
|
||||
import org.hibernate.boot.model.process.internal.NamedConverterResolution;
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
|
||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||
import org.hibernate.internal.util.ReflectHelper;
|
||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||
import org.hibernate.metamodel.model.convert.internal.NamedEnumValueConverter;
|
||||
import org.hibernate.metamodel.model.convert.internal.OrdinalEnumValueConverter;
|
||||
import org.hibernate.metamodel.model.convert.spi.BasicValueConverter;
|
||||
import org.hibernate.resource.beans.spi.ManagedBeanRegistry;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.type.BasicType;
|
||||
import org.hibernate.type.CustomType;
|
||||
import org.hibernate.type.RowVersionType;
|
||||
import org.hibernate.type.Type;
|
||||
import org.hibernate.type.descriptor.java.EnumJavaTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.java.ImmutableMutabilityPlan;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.java.MutabilityPlan;
|
||||
import org.hibernate.type.descriptor.java.PrimitiveByteArrayTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.java.RowVersionTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.java.TemporalJavaTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.java.spi.JavaTypeDescriptorRegistry;
|
||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptorIndicators;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class BasicValue extends SimpleValue implements SqlTypeDescriptorIndicators {
|
||||
|
||||
private final TypeConfiguration typeConfiguration;
|
||||
private final int preferredJdbcTypeCodeForBoolean;
|
||||
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// incoming "configuration" values
|
||||
|
||||
|
||||
private Function<TypeConfiguration,JavaTypeDescriptor<?>> explicitJavaTypeAccess;
|
||||
private Function<TypeConfiguration,SqlTypeDescriptor> explicitSqlTypeAccess;
|
||||
|
||||
private MutabilityPlan explicitMutabilityPlan;
|
||||
|
||||
private boolean isNationalized;
|
||||
private boolean isLob;
|
||||
private EnumType enumerationStyle;
|
||||
private TemporalType temporalPrecision;
|
||||
|
||||
private ConverterDescriptor attributeConverterDescriptor;
|
||||
|
||||
private Class resolvedJavaClass;
|
||||
|
||||
private String ownerName;
|
||||
private String propertyName;
|
||||
|
||||
private Properties explicitLocalTypeParams;
|
||||
|
||||
private BasicValue dependentValue;
|
||||
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Resolved state - available after `#setTypeUsingReflection`
|
||||
|
||||
private Resolution<?> resolution;
|
||||
|
||||
public BasicValue(MetadataBuildingContext buildingContext) {
|
||||
super( buildingContext );
|
||||
|
||||
this.typeConfiguration = buildingContext.getBootstrapContext().getTypeConfiguration();
|
||||
this.preferredJdbcTypeCodeForBoolean = buildingContext.getPreferredSqlTypeCodeForBoolean();
|
||||
}
|
||||
|
||||
public BasicValue(MetadataBuildingContext buildingContext, Table table) {
|
||||
super( buildingContext, table );
|
||||
|
||||
this.typeConfiguration = buildingContext.getBootstrapContext().getTypeConfiguration();
|
||||
this.preferredJdbcTypeCodeForBoolean = buildingContext.getPreferredSqlTypeCodeForBoolean();
|
||||
}
|
||||
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Setters - in preparation of resolution
|
||||
|
||||
public void setJavaClass(Class resolvedJavaClass) {
|
||||
this.resolvedJavaClass = resolvedJavaClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTypeUsingReflection(String className, String propertyName) throws MappingException {
|
||||
if ( resolution != null ) {
|
||||
throw new IllegalStateException( "BasicValue already resolved" );
|
||||
}
|
||||
|
||||
this.ownerName = className;
|
||||
this.propertyName = propertyName;
|
||||
}
|
||||
|
||||
public void setEnumerationStyle(EnumType enumerationStyle) {
|
||||
this.enumerationStyle = enumerationStyle;
|
||||
}
|
||||
|
||||
public EnumType getEnumerationStyle() {
|
||||
return enumerationStyle;
|
||||
}
|
||||
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Resolution
|
||||
|
||||
@Override
|
||||
public Type getType() throws MappingException {
|
||||
resolve();
|
||||
assert resolution != null;
|
||||
|
||||
return resolution.getResolvedBasicType();
|
||||
}
|
||||
|
||||
public Resolution<?> resolve() {
|
||||
if ( resolution != null ) {
|
||||
return resolution;
|
||||
}
|
||||
|
||||
final String explicitTypeName = getTypeName();
|
||||
if ( explicitTypeName != null ) {
|
||||
resolution = interpretExplicitlyNamedType(
|
||||
explicitTypeName,
|
||||
explicitJavaTypeAccess,
|
||||
explicitSqlTypeAccess,
|
||||
attributeConverterDescriptor,
|
||||
explicitMutabilityPlan,
|
||||
explicitLocalTypeParams,
|
||||
this,
|
||||
typeConfiguration,
|
||||
getBuildingContext()
|
||||
);
|
||||
}
|
||||
else {
|
||||
final ServiceRegistry serviceRegistry = typeConfiguration.getServiceRegistry();
|
||||
final ClassLoaderService classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
|
||||
|
||||
resolution = implicitlyResolveBasicType(
|
||||
explicitJavaTypeAccess,
|
||||
explicitSqlTypeAccess,
|
||||
attributeConverterDescriptor,
|
||||
this,
|
||||
() -> {
|
||||
if ( resolvedJavaClass != null ) {
|
||||
return getBuildingContext().getBootstrapContext()
|
||||
.getTypeConfiguration()
|
||||
.getJavaTypeDescriptorRegistry()
|
||||
.resolveDescriptor( resolvedJavaClass );
|
||||
}
|
||||
else if ( ownerName != null && propertyName != null ) {
|
||||
final Class reflectedJavaType = ReflectHelper.reflectedPropertyClass(
|
||||
ownerName,
|
||||
propertyName,
|
||||
classLoaderService
|
||||
);
|
||||
|
||||
// First resolve from the BasicTypeRegistry.
|
||||
// If it does resolve, we can use the JTD instead of delegating to the JTD Regsitry.
|
||||
final BasicType basicType = getBuildingContext().getBootstrapContext()
|
||||
.getTypeConfiguration()
|
||||
.getBasicTypeRegistry()
|
||||
.getRegisteredType( reflectedJavaType.getName() );
|
||||
if ( basicType != null ) {
|
||||
return basicType.getJavaTypeDescriptor();
|
||||
}
|
||||
|
||||
return getBuildingContext().getBootstrapContext()
|
||||
.getTypeConfiguration()
|
||||
.getJavaTypeDescriptorRegistry()
|
||||
.resolveDescriptor( reflectedJavaType );
|
||||
}
|
||||
else if ( dependentValue != null ) {
|
||||
// todo (6.0) - Can we just use the resolution directly?
|
||||
// In 5.x we copied the typeName and its associated parameters for this use case.
|
||||
// It would stand to reason we could just share the same Resolution instance
|
||||
// instead of constructing this BasicValue's very own here?
|
||||
return dependentValue.resolve().getDomainJavaDescriptor();
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
isVersion(),
|
||||
typeConfiguration
|
||||
);
|
||||
}
|
||||
|
||||
return resolution;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static Resolution interpretExplicitlyNamedType(
|
||||
String name,
|
||||
Function<TypeConfiguration,JavaTypeDescriptor<?>> explicitJtdAccess,
|
||||
Function<TypeConfiguration,SqlTypeDescriptor> explicitStdAccess,
|
||||
ConverterDescriptor converterDescriptor,
|
||||
MutabilityPlan explicitMutabilityPlan,
|
||||
Properties localTypeParams,
|
||||
SqlTypeDescriptorIndicators stdIndicators,
|
||||
TypeConfiguration typeConfiguration,
|
||||
MetadataBuildingContext context) {
|
||||
|
||||
final ManagedBeanRegistry managedBeanRegistry = context.getBootstrapContext()
|
||||
.getServiceRegistry()
|
||||
.getService( ManagedBeanRegistry.class );
|
||||
|
||||
final JpaAttributeConverterCreationContext converterCreationContext = new JpaAttributeConverterCreationContext() {
|
||||
@Override
|
||||
public ManagedBeanRegistry getManagedBeanRegistry() {
|
||||
return managedBeanRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaTypeDescriptorRegistry getJavaTypeDescriptorRegistry() {
|
||||
return typeConfiguration.getJavaTypeDescriptorRegistry();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Name could refer to:
|
||||
// 1) a named converter - HBM support for JPA's AttributeConverter via its `type="..."` XML attribute
|
||||
// 2) basic type "resolution key"
|
||||
// 3) UserType or BasicType class name - directly, or through a TypeDefinition
|
||||
|
||||
if ( name.startsWith( ConverterDescriptor.TYPE_NAME_PREFIX ) ) {
|
||||
// atm this should never happen due to impl of `#setExplicitTypeName`
|
||||
return NamedConverterResolution.from(
|
||||
name,
|
||||
explicitJtdAccess,
|
||||
explicitStdAccess,
|
||||
converterCreationContext,
|
||||
explicitMutabilityPlan,
|
||||
stdIndicators,
|
||||
context
|
||||
);
|
||||
}
|
||||
|
||||
// see if it is a named basic type
|
||||
final BasicType basicTypeByName = typeConfiguration.getBasicTypeRegistry().getRegisteredType( name );
|
||||
if ( basicTypeByName != null ) {
|
||||
final BasicValueConverter valueConverter;
|
||||
final JavaTypeDescriptor<?> domainJtd;
|
||||
if ( converterDescriptor == null ) {
|
||||
valueConverter = null;
|
||||
domainJtd = basicTypeByName.getJavaTypeDescriptor();
|
||||
}
|
||||
else {
|
||||
valueConverter = converterDescriptor.createJpaAttributeConverter( converterCreationContext );
|
||||
domainJtd = valueConverter.getDomainJavaDescriptor();
|
||||
}
|
||||
|
||||
return new NamedBasicTypeResolution(
|
||||
domainJtd,
|
||||
basicTypeByName,
|
||||
valueConverter,
|
||||
explicitMutabilityPlan,
|
||||
context
|
||||
);
|
||||
}
|
||||
|
||||
// see if it is a named TypeDefinition
|
||||
final TypeDefinition typeDefinition = context.getTypeDefinitionRegistry().resolve( name );
|
||||
if ( typeDefinition != null ) {
|
||||
return typeDefinition.resolve(
|
||||
explicitJtdAccess.apply( typeConfiguration ),
|
||||
explicitStdAccess.apply( typeConfiguration ),
|
||||
localTypeParams,
|
||||
explicitMutabilityPlan,
|
||||
context
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// see if the name is a UserType or BasicType implementor class name
|
||||
final ClassLoaderService cls = typeConfiguration.getServiceRegistry().getService( ClassLoaderService.class );
|
||||
try {
|
||||
final Class typeNamedClass = cls.classForName( name );
|
||||
|
||||
// if there are no local config params, register an implicit TypeDefinition for this custom type .
|
||||
// later uses may find it and re-use its cacheable reference...
|
||||
if ( CollectionHelper.isEmpty( localTypeParams ) ) {
|
||||
final TypeDefinition implicitDefinition = new TypeDefinition(
|
||||
name,
|
||||
typeNamedClass,
|
||||
null,
|
||||
null,
|
||||
typeConfiguration
|
||||
);
|
||||
context.getTypeDefinitionRegistry().register( implicitDefinition );
|
||||
return implicitDefinition.resolve(
|
||||
explicitJtdAccess != null ? explicitJtdAccess.apply( typeConfiguration ) : null,
|
||||
explicitStdAccess != null ? explicitStdAccess.apply( typeConfiguration ) : null,
|
||||
null,
|
||||
explicitMutabilityPlan,
|
||||
context
|
||||
);
|
||||
}
|
||||
|
||||
return TypeDefinition.createLocalResolution(
|
||||
name,
|
||||
typeNamedClass,
|
||||
explicitJtdAccess.apply( typeConfiguration ),
|
||||
explicitStdAccess.apply( typeConfiguration ),
|
||||
explicitMutabilityPlan,
|
||||
localTypeParams,
|
||||
context
|
||||
);
|
||||
}
|
||||
catch (ClassLoadingException ignore) {
|
||||
// allow the exception below to trigger
|
||||
}
|
||||
|
||||
throw new MappingException( "Could not resolve named type : " + name );
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static Resolution implicitlyResolveBasicType(
|
||||
Function<TypeConfiguration,JavaTypeDescriptor<?>> explicitJtdAccess,
|
||||
Function<TypeConfiguration,SqlTypeDescriptor> explicitStdAccess,
|
||||
ConverterDescriptor attributeConverterDescriptor,
|
||||
SqlTypeDescriptorIndicators stdIndicators,
|
||||
Supplier<JavaTypeDescriptor> reflectedJtdResolver,
|
||||
boolean isVersion,
|
||||
TypeConfiguration typeConfiguration) {
|
||||
|
||||
final InferredBasicValueResolver resolver = new InferredBasicValueResolver( explicitJtdAccess, explicitStdAccess, typeConfiguration );
|
||||
|
||||
if ( attributeConverterDescriptor != null ) {
|
||||
assert !isVersion : "Version attribute cannot define AttributeConverter";
|
||||
|
||||
// we have an attribute converter, use that to either:
|
||||
// 1) validate the explicit BasicJavaDescriptor/SqlTypeDescriptor
|
||||
// 2) use the converter Class parameters to infer the BasicJavaDescriptor/SqlTypeDescriptor
|
||||
|
||||
final Class<?> converterDomainJavaType = attributeConverterDescriptor.getDomainValueResolvedType()
|
||||
.getErasedType();
|
||||
|
||||
final JavaTypeDescriptor<?> converterDomainJtd = typeConfiguration.getJavaTypeDescriptorRegistry()
|
||||
.getDescriptor( converterDomainJavaType );
|
||||
|
||||
if ( resolver.getDomainJtd() == null ) {
|
||||
resolver.setDomainJtd( converterDomainJtd );
|
||||
}
|
||||
else {
|
||||
if ( !resolver.getDomainJtd().equals( converterDomainJtd ) ) {
|
||||
throw new HibernateException(
|
||||
"JavaTypeDescriptors did not match between BasicTypeParameters#getJavaTypeDescriptor and " +
|
||||
"BasicTypeParameters#getAttributeConverterDefinition#getDomainType"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
final Class<?> converterRelationalJavaType = attributeConverterDescriptor.getRelationalValueResolvedType()
|
||||
.getErasedType();
|
||||
|
||||
resolver.setRelationalJtd(
|
||||
typeConfiguration.getJavaTypeDescriptorRegistry().getDescriptor( converterRelationalJavaType )
|
||||
);
|
||||
|
||||
final SqlTypeDescriptor converterHintedStd = resolver.getRelationalJtd().getJdbcRecommendedSqlType( stdIndicators );
|
||||
|
||||
if ( resolver.getRelationalStd() == null ) {
|
||||
resolver.setRelationalStd( converterHintedStd );
|
||||
}
|
||||
else {
|
||||
if ( !resolver.getRelationalStd().equals( converterHintedStd ) ) {
|
||||
throw new HibernateException(
|
||||
"SqlTypeDescriptors did not match between BasicTypeParameters#getSqlTypeDescriptor and " +
|
||||
"BasicTypeParameters#getAttributeConverterDefinition#getJdbcType"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
resolver.setValueConverter(
|
||||
attributeConverterDescriptor.createJpaAttributeConverter(
|
||||
new JpaAttributeConverterCreationContext() {
|
||||
@Override
|
||||
public ManagedBeanRegistry getManagedBeanRegistry() {
|
||||
return typeConfiguration.getServiceRegistry().getService( ManagedBeanRegistry.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaTypeDescriptorRegistry getJavaTypeDescriptorRegistry() {
|
||||
return typeConfiguration.getJavaTypeDescriptorRegistry();
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
else {
|
||||
if ( resolver.getDomainJtd() == null ) {
|
||||
resolver.setDomainJtd( reflectedJtdResolver.get() );
|
||||
}
|
||||
|
||||
if ( resolver.getDomainJtd() instanceof EnumJavaTypeDescriptor ) {
|
||||
final EnumJavaTypeDescriptor<?> enumJavaDescriptor = (EnumJavaTypeDescriptor<?>) resolver.getDomainJtd();
|
||||
|
||||
final EnumType enumType = stdIndicators.getEnumeratedType() != null
|
||||
? stdIndicators.getEnumeratedType()
|
||||
: EnumType.ORDINAL;
|
||||
|
||||
switch ( enumType ) {
|
||||
case STRING: {
|
||||
final JavaTypeDescriptor<String> stringJtd = typeConfiguration.getJavaTypeDescriptorRegistry().getDescriptor( String.class );
|
||||
final SqlTypeDescriptor relationalStd = stringJtd.getJdbcRecommendedSqlType( stdIndicators );
|
||||
|
||||
resolver.setRelationalJtd( stringJtd );
|
||||
resolver.setRelationalStd( relationalStd );
|
||||
|
||||
final NamedEnumValueConverter valueConverter = new NamedEnumValueConverter(
|
||||
enumJavaDescriptor,
|
||||
relationalStd,
|
||||
stringJtd
|
||||
);
|
||||
|
||||
resolver.setValueConverter( valueConverter );
|
||||
|
||||
final org.hibernate.type.EnumType enumMappingType = new org.hibernate.type.EnumType(
|
||||
enumJavaDescriptor.getJavaType(),
|
||||
valueConverter,
|
||||
typeConfiguration
|
||||
);
|
||||
|
||||
final CustomType basicType = new CustomType( enumMappingType, typeConfiguration );
|
||||
|
||||
resolver.injectResolution(
|
||||
new InferredBasicValueResolution(
|
||||
basicType,
|
||||
enumJavaDescriptor,
|
||||
stringJtd,
|
||||
relationalStd,
|
||||
valueConverter,
|
||||
ImmutableMutabilityPlan.INSTANCE
|
||||
)
|
||||
);
|
||||
break;
|
||||
}
|
||||
case ORDINAL: {
|
||||
final JavaTypeDescriptor<Integer> integerJtd = typeConfiguration.getJavaTypeDescriptorRegistry().getDescriptor( Integer.class );
|
||||
final SqlTypeDescriptor std = integerJtd.getJdbcRecommendedSqlType( stdIndicators );
|
||||
|
||||
resolver.setRelationalJtd( integerJtd );
|
||||
resolver.setRelationalStd( std );
|
||||
|
||||
final OrdinalEnumValueConverter valueConverter = new OrdinalEnumValueConverter(
|
||||
enumJavaDescriptor,
|
||||
std,
|
||||
integerJtd
|
||||
);
|
||||
|
||||
resolver.setValueConverter( valueConverter );
|
||||
|
||||
final org.hibernate.type.EnumType enumMappingType = new org.hibernate.type.EnumType(
|
||||
enumJavaDescriptor.getJavaType(),
|
||||
valueConverter,
|
||||
typeConfiguration
|
||||
);
|
||||
|
||||
final CustomType basicType = new CustomType( enumMappingType, typeConfiguration );
|
||||
|
||||
resolver.injectResolution(
|
||||
new InferredBasicValueResolution(
|
||||
basicType,
|
||||
enumJavaDescriptor,
|
||||
integerJtd,
|
||||
std,
|
||||
valueConverter,
|
||||
ImmutableMutabilityPlan.INSTANCE
|
||||
)
|
||||
);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
throw new HibernateException( "Unknown EnumType : " + enumType );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( resolver.getDomainJtd() instanceof TemporalJavaTypeDescriptor ) {
|
||||
if ( stdIndicators.getTemporalPrecision() != null ) {
|
||||
resolver.setDomainJtd(
|
||||
( (TemporalJavaTypeDescriptor) resolver.getDomainJtd() ).resolveTypeForPrecision(
|
||||
stdIndicators.getTemporalPrecision(),
|
||||
typeConfiguration
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
else if ( resolver.getDomainJtd() instanceof PrimitiveByteArrayTypeDescriptor && isVersion ) {
|
||||
resolver.setDomainJtd( RowVersionTypeDescriptor.INSTANCE );
|
||||
resolver.injectResolution(
|
||||
new InferredBasicValueResolution(
|
||||
RowVersionType.INSTANCE,
|
||||
RowVersionType.INSTANCE.getJavaTypeDescriptor(),
|
||||
RowVersionType.INSTANCE.getJavaTypeDescriptor(),
|
||||
RowVersionType.INSTANCE.getSqlTypeDescriptor(),
|
||||
null,
|
||||
ImmutableMutabilityPlan.INSTANCE
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( resolver.getRelationalStd() == null ) {
|
||||
if ( resolver.getRelationalJtd() == null ) {
|
||||
if ( resolver.getDomainJtd() == null ) {
|
||||
throw new IllegalArgumentException(
|
||||
"Could not determine JavaTypeDescriptor nor SqlTypeDescriptor to use"
|
||||
);
|
||||
}
|
||||
|
||||
resolver.setRelationalJtd( resolver.getDomainJtd() );
|
||||
}
|
||||
|
||||
resolver.setRelationalStd( resolver.getRelationalJtd().getJdbcRecommendedSqlType( stdIndicators ) );
|
||||
}
|
||||
else if ( resolver.getRelationalJtd() == null ) {
|
||||
resolver.setRelationalJtd(
|
||||
resolver.getRelationalStd().getJdbcRecommendedJavaTypeMapping( typeConfiguration )
|
||||
);
|
||||
if ( resolver.getDomainJtd() == null ) {
|
||||
resolver.setDomainJtd( resolver.getRelationalJtd() );
|
||||
}
|
||||
}
|
||||
|
||||
return resolver.build();
|
||||
}
|
||||
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// SqlTypeDescriptorIndicators
|
||||
|
||||
@Override
|
||||
public EnumType getEnumeratedType() {
|
||||
return getEnumerationStyle();
|
||||
}
|
||||
|
||||
public boolean isNationalized() {
|
||||
return isNationalized;
|
||||
}
|
||||
|
||||
public boolean isLob() {
|
||||
return isLob;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPreferredSqlTypeCodeForBoolean() {
|
||||
return preferredJdbcTypeCodeForBoolean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TypeConfiguration getTypeConfiguration() {
|
||||
return typeConfiguration;
|
||||
}
|
||||
|
||||
public void setExplicitTypeParams(Properties explicitLocalTypeParams) {
|
||||
this.explicitLocalTypeParams = explicitLocalTypeParams;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolved form of {@link BasicValue} as part of interpreting the
|
||||
* boot-time model into the run-time model
|
||||
*/
|
||||
public interface Resolution<J> {
|
||||
/**
|
||||
* The associated BasicType
|
||||
*/
|
||||
BasicType getResolvedBasicType();
|
||||
|
||||
/**
|
||||
* The JavaTypeDescriptor for the value as part of the domain model
|
||||
*/
|
||||
JavaTypeDescriptor<J> getDomainJavaDescriptor();
|
||||
|
||||
/**
|
||||
* The JavaTypeDescriptor for the relational value as part of
|
||||
* the relational model (its JDBC representation)
|
||||
*/
|
||||
JavaTypeDescriptor<?> getRelationalJavaDescriptor();
|
||||
|
||||
/**
|
||||
* The JavaTypeDescriptor for the relational value as part of
|
||||
* the relational model (its JDBC representation)
|
||||
*/
|
||||
SqlTypeDescriptor getRelationalSqlTypeDescriptor();
|
||||
|
||||
/**
|
||||
* Converter, if any, to convert values between the
|
||||
* domain and relational JavaTypeDescriptor representations
|
||||
*/
|
||||
BasicValueConverter getValueConverter();
|
||||
|
||||
/**
|
||||
* The resolved MutabilityPlan
|
||||
*/
|
||||
MutabilityPlan<J> getMutabilityPlan();
|
||||
}
|
||||
}
|
@ -11,8 +11,8 @@
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Properties;
|
||||
import java.util.Objects;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.hibernate.FetchMode;
|
||||
import org.hibernate.MappingException;
|
||||
@ -27,6 +27,7 @@
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.type.CollectionType;
|
||||
import org.hibernate.type.Type;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
/**
|
||||
* Mapping for a collection. Subclasses specialize to particular collection styles.
|
||||
@ -38,7 +39,7 @@ public abstract class Collection implements Fetchable, Value, Filterable {
|
||||
public static final String DEFAULT_ELEMENT_COLUMN_NAME = "elt";
|
||||
public static final String DEFAULT_KEY_COLUMN_NAME = "id";
|
||||
|
||||
private final MetadataImplementor metadata;
|
||||
private final MetadataBuildingContext buildingContext;
|
||||
private PersistentClass owner;
|
||||
|
||||
private KeyValue key;
|
||||
@ -89,20 +90,20 @@ public abstract class Collection implements Fetchable, Value, Filterable {
|
||||
private String loaderName;
|
||||
|
||||
protected Collection(MetadataBuildingContext buildingContext, PersistentClass owner) {
|
||||
this(buildingContext.getMetadataCollector(), owner);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link Collection#Collection(MetadataBuildingContext, PersistentClass)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
protected Collection(MetadataImplementor metadata, PersistentClass owner) {
|
||||
this.metadata = metadata;
|
||||
this.buildingContext = buildingContext;
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public MetadataBuildingContext getBuildingContext() {
|
||||
return buildingContext;
|
||||
}
|
||||
|
||||
public MetadataImplementor getMetadata() {
|
||||
return metadata;
|
||||
return getBuildingContext().getMetadataCollector();
|
||||
}
|
||||
|
||||
public TypeConfiguration getTypeConfiguration() {
|
||||
return getBuildingContext().getBootstrapContext().getTypeConfiguration();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -382,13 +383,12 @@ public Type getType() throws MappingException {
|
||||
}
|
||||
|
||||
public CollectionType getCollectionType() {
|
||||
// todo (6.0) : hook in CollectionSemantics
|
||||
if ( typeName == null ) {
|
||||
return getDefaultCollectionType();
|
||||
}
|
||||
else {
|
||||
return getMetadata().getTypeConfiguration().getTypeResolver()
|
||||
.getTypeFactory()
|
||||
.customCollection( typeName, typeParameters, role, referencedPropertyName );
|
||||
return MappingHelper.customCollection( typeName, typeParameters, role, referencedPropertyName, getMetadata() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,8 +29,9 @@
|
||||
import org.hibernate.internal.util.collections.JoinedIterator;
|
||||
import org.hibernate.property.access.spi.Setter;
|
||||
import org.hibernate.tuple.component.ComponentMetamodel;
|
||||
import org.hibernate.type.ComponentType;
|
||||
import org.hibernate.type.EmbeddedComponentType;
|
||||
import org.hibernate.type.Type;
|
||||
import org.hibernate.type.TypeFactory;
|
||||
|
||||
/**
|
||||
* The mapping for a component, composite element,
|
||||
@ -226,9 +227,12 @@ public Type getType() throws MappingException {
|
||||
this,
|
||||
getMetadata().getMetadataBuildingOptions()
|
||||
);
|
||||
final TypeFactory factory = getMetadata().getTypeConfiguration().getTypeResolver().getTypeFactory();
|
||||
localType = isEmbedded() ? factory.embeddedComponent( metamodel ) : factory.component( metamodel );
|
||||
type = localType;
|
||||
|
||||
localType = isEmbedded()
|
||||
? new EmbeddedComponentType( getBuildingContext().getBootstrapContext().getTypeConfiguration(), metamodel )
|
||||
: new ComponentType( getBuildingContext().getBootstrapContext().getTypeConfiguration(), metamodel );
|
||||
|
||||
this.type = localType;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,30 +7,20 @@
|
||||
package org.hibernate.mapping;
|
||||
|
||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||
import org.hibernate.boot.spi.MetadataImplementor;
|
||||
import org.hibernate.type.CollectionType;
|
||||
import org.hibernate.type.IdentifierBagType;
|
||||
|
||||
/**
|
||||
* An <tt>IdentifierBag</tt> has a primary key consisting of
|
||||
* just the identifier column
|
||||
*/
|
||||
public class IdentifierBag extends IdentifierCollection {
|
||||
/**
|
||||
* @deprecated User {@link IdentifierBag#IdentifierBag(MetadataBuildingContext, PersistentClass)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public IdentifierBag(MetadataImplementor metadata, PersistentClass owner) {
|
||||
super( metadata, owner );
|
||||
}
|
||||
|
||||
public IdentifierBag(MetadataBuildingContext buildingContext, PersistentClass owner) {
|
||||
super( buildingContext, owner );
|
||||
}
|
||||
|
||||
public CollectionType getDefaultCollectionType() {
|
||||
return getMetadata().getTypeResolver()
|
||||
.getTypeFactory()
|
||||
.idbag( getRole(), getReferencedPropertyName() );
|
||||
return new IdentifierBagType( getMetadata().getTypeConfiguration(), getRole(), getReferencedPropertyName() );
|
||||
}
|
||||
|
||||
public Object accept(ValueVisitor visitor) {
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||
import org.hibernate.boot.spi.MetadataImplementor;
|
||||
import org.hibernate.engine.spi.Mapping;
|
||||
|
||||
/**
|
||||
@ -20,14 +19,6 @@ public abstract class IdentifierCollection extends Collection {
|
||||
|
||||
private KeyValue identifier;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link IdentifierCollection#IdentifierCollection(MetadataBuildingContext, PersistentClass)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public IdentifierCollection(MetadataImplementor metadata, PersistentClass owner) {
|
||||
super( metadata, owner );
|
||||
}
|
||||
|
||||
public IdentifierCollection(MetadataBuildingContext buildingContext, PersistentClass owner) {
|
||||
super( buildingContext, owner );
|
||||
}
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||
import org.hibernate.boot.spi.MetadataImplementor;
|
||||
import org.hibernate.engine.spi.Mapping;
|
||||
|
||||
/**
|
||||
@ -24,14 +23,6 @@ public abstract class IndexedCollection extends Collection {
|
||||
|
||||
private Value index;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link IndexedCollection#IndexedCollection(MetadataBuildingContext, PersistentClass)} insetad.
|
||||
*/
|
||||
@Deprecated
|
||||
public IndexedCollection(MetadataImplementor metadata, PersistentClass owner) {
|
||||
super( metadata, owner );
|
||||
}
|
||||
|
||||
public IndexedCollection(MetadataBuildingContext buildingContext, PersistentClass owner) {
|
||||
super( buildingContext, owner );
|
||||
}
|
||||
|
@ -8,8 +8,8 @@
|
||||
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||
import org.hibernate.boot.spi.MetadataImplementor;
|
||||
import org.hibernate.type.CollectionType;
|
||||
import org.hibernate.type.ListType;
|
||||
|
||||
/**
|
||||
* A list mapping has a primary key consisting of the key columns + index column.
|
||||
@ -24,22 +24,12 @@ public boolean isList() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link List#List(MetadataBuildingContext, PersistentClass)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public List(MetadataImplementor metadata, PersistentClass owner) {
|
||||
super( metadata, owner );
|
||||
}
|
||||
|
||||
public List(MetadataBuildingContext buildingContext, PersistentClass owner) {
|
||||
super( buildingContext, owner );
|
||||
}
|
||||
|
||||
public CollectionType getDefaultCollectionType() throws MappingException {
|
||||
return getMetadata().getTypeResolver()
|
||||
.getTypeFactory()
|
||||
.list( getRole(), getReferencedPropertyName() );
|
||||
return new ListType( getMetadata().getTypeConfiguration(), getRole(), getReferencedPropertyName() );
|
||||
}
|
||||
|
||||
public Object accept(ValueVisitor visitor) {
|
||||
|
@ -24,6 +24,8 @@ public class ManyToOne extends ToOne {
|
||||
private boolean ignoreNotFound;
|
||||
private boolean isLogicalOneToOne;
|
||||
|
||||
private Type resolvedType;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link ManyToOne#ManyToOne(MetadataBuildingContext, Table)} instead.
|
||||
*/
|
||||
@ -37,16 +39,22 @@ public ManyToOne(MetadataBuildingContext buildingContext, Table table) {
|
||||
}
|
||||
|
||||
public Type getType() throws MappingException {
|
||||
return getMetadata().getTypeResolver().getTypeFactory().manyToOne(
|
||||
getReferencedEntityName(),
|
||||
referenceToPrimaryKey,
|
||||
getReferencedPropertyName(),
|
||||
getPropertyName(),
|
||||
isLazy(),
|
||||
isUnwrapProxy(),
|
||||
isIgnoreNotFound(),
|
||||
isLogicalOneToOne
|
||||
);
|
||||
if ( resolvedType != null ) {
|
||||
resolvedType = MappingHelper.manyToOne(
|
||||
getReferencedEntityName(),
|
||||
isReferenceToPrimaryKey(),
|
||||
getReferencedPropertyName(),
|
||||
getPropertyName(),
|
||||
isLogicalOneToOne(),
|
||||
isLazy(),
|
||||
isUnwrapProxy(),
|
||||
isIgnoreNotFound(),
|
||||
getBuildingContext()
|
||||
);
|
||||
assert resolvedType != null;
|
||||
}
|
||||
|
||||
return resolvedType;
|
||||
}
|
||||
|
||||
public void createForeignKey() throws MappingException {
|
||||
@ -56,6 +64,8 @@ public void createForeignKey() throws MappingException {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void createPropertyRefConstraints(Map persistentClasses) {
|
||||
if (referencedPropertyName!=null) {
|
||||
PersistentClass pc = (PersistentClass) persistentClasses.get(getReferencedEntityName() );
|
||||
|
@ -10,21 +10,15 @@
|
||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||
import org.hibernate.boot.spi.MetadataImplementor;
|
||||
import org.hibernate.type.CollectionType;
|
||||
import org.hibernate.type.MapType;
|
||||
import org.hibernate.type.OrderedMapType;
|
||||
import org.hibernate.type.SortedMapType;
|
||||
|
||||
/**
|
||||
* A map has a primary key consisting of
|
||||
* the key columns + index columns.
|
||||
*/
|
||||
public class Map extends IndexedCollection {
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link Map#Map(MetadataBuildingContext, PersistentClass)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public Map(MetadataImplementor metadata, PersistentClass owner) {
|
||||
super( metadata, owner );
|
||||
}
|
||||
|
||||
public Map(MetadataBuildingContext buildingContext, PersistentClass owner) {
|
||||
super( buildingContext, owner );
|
||||
}
|
||||
@ -35,20 +29,14 @@ public boolean isMap() {
|
||||
|
||||
public CollectionType getDefaultCollectionType() {
|
||||
if ( isSorted() ) {
|
||||
return getMetadata().getTypeResolver()
|
||||
.getTypeFactory()
|
||||
.sortedMap( getRole(), getReferencedPropertyName(), getComparator() );
|
||||
return new SortedMapType( getTypeConfiguration(), getRole(), getReferencedPropertyName(), getComparator() );
|
||||
}
|
||||
else if ( hasOrder() ) {
|
||||
return getMetadata().getTypeResolver()
|
||||
.getTypeFactory()
|
||||
.orderedMap( getRole(), getReferencedPropertyName() );
|
||||
}
|
||||
else {
|
||||
return getMetadata().getTypeResolver()
|
||||
.getTypeFactory()
|
||||
.map( getRole(), getReferencedPropertyName() );
|
||||
|
||||
if ( hasOrder() ) {
|
||||
return new OrderedMapType( getTypeConfiguration(), getRole(), getReferencedPropertyName() );
|
||||
}
|
||||
|
||||
return new MapType( getTypeConfiguration(), getRole(), getReferencedPropertyName() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,163 @@
|
||||
/*
|
||||
* 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.mapping;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.hibernate.Internal;
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
|
||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||
import org.hibernate.boot.spi.MetadataImplementor;
|
||||
import org.hibernate.type.AnyType;
|
||||
import org.hibernate.type.CollectionType;
|
||||
import org.hibernate.type.CustomCollectionType;
|
||||
import org.hibernate.type.EntityType;
|
||||
import org.hibernate.type.ForeignKeyDirection;
|
||||
import org.hibernate.type.ManyToOneType;
|
||||
import org.hibernate.type.MetaType;
|
||||
import org.hibernate.type.OneToOneType;
|
||||
import org.hibernate.type.SpecialOneToOneType;
|
||||
import org.hibernate.type.Type;
|
||||
import org.hibernate.usertype.ParameterizedType;
|
||||
import org.hibernate.usertype.UserCollectionType;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@Internal
|
||||
final class MappingHelper {
|
||||
private final static Properties EMPTY_PROPERTIES = new Properties();
|
||||
|
||||
private MappingHelper() {
|
||||
}
|
||||
|
||||
public static CollectionType customCollection(
|
||||
String typeName,
|
||||
Properties typeParameters,
|
||||
String role,
|
||||
String propertyRef,
|
||||
MetadataImplementor metadata) {
|
||||
final ClassLoaderService cls = metadata.getMetadataBuildingOptions().getServiceRegistry().getService( ClassLoaderService.class );
|
||||
|
||||
try {
|
||||
final Class<? extends UserCollectionType> typeClass = cls.classForName( typeName );
|
||||
|
||||
CustomCollectionType result = new CustomCollectionType( typeClass, role, propertyRef, metadata.getTypeConfiguration() );
|
||||
if ( typeParameters != null ) {
|
||||
injectParameters( result.getUserType(), typeParameters );
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
catch (ClassLoadingException e) {
|
||||
throw new MappingException( "user collection type class not found: " + typeName, e );
|
||||
}
|
||||
}
|
||||
|
||||
public static void injectParameters(Object type, Properties parameters) {
|
||||
if ( type instanceof ParameterizedType ) {
|
||||
if ( parameters == null ) {
|
||||
( (ParameterizedType) type ).setParameterValues( EMPTY_PROPERTIES );
|
||||
}
|
||||
else {
|
||||
( (ParameterizedType) type ).setParameterValues( parameters );
|
||||
}
|
||||
}
|
||||
else if ( parameters != null && !parameters.isEmpty() ) {
|
||||
throw new MappingException( "UserCollectionType impl does not implement ParameterizedType but parameters were present : " + type.getClass().getName() );
|
||||
}
|
||||
}
|
||||
|
||||
public static AnyType anyMapping(
|
||||
Type metaType,
|
||||
Type identifierType,
|
||||
Map<Object, String> metaValueToEntityNameMap,
|
||||
boolean lazy,
|
||||
MetadataBuildingContext buildingContext) {
|
||||
if ( metaValueToEntityNameMap != null ) {
|
||||
metaType = new MetaType( metaValueToEntityNameMap, metaType );
|
||||
}
|
||||
|
||||
return new AnyType( buildingContext.getBootstrapContext().getTypeConfiguration(), metaType, identifierType, lazy );
|
||||
}
|
||||
|
||||
public static ManyToOneType manyToOne(
|
||||
String referencedEntityName,
|
||||
boolean referenceToPrimaryKey,
|
||||
String referencedPropertyName,
|
||||
String propertyName,
|
||||
boolean isLogicalOneToOne,
|
||||
boolean lazy,
|
||||
boolean unwrapProxy,
|
||||
boolean ignoreNotFound,
|
||||
MetadataBuildingContext buildingContext) {
|
||||
return new ManyToOneType(
|
||||
buildingContext.getBootstrapContext().getTypeConfiguration(),
|
||||
referencedEntityName,
|
||||
referenceToPrimaryKey,
|
||||
referencedPropertyName,
|
||||
propertyName,
|
||||
lazy,
|
||||
unwrapProxy,
|
||||
ignoreNotFound,
|
||||
isLogicalOneToOne
|
||||
);
|
||||
}
|
||||
|
||||
public static SpecialOneToOneType specialOneToOne(
|
||||
String referencedEntityName,
|
||||
ForeignKeyDirection foreignKeyType,
|
||||
boolean referenceToPrimaryKey,
|
||||
String referencedPropertyName,
|
||||
boolean lazy,
|
||||
boolean unwrapProxy,
|
||||
String owningEntityName,
|
||||
String owningEntityPropertyName,
|
||||
boolean constrained,
|
||||
MetadataBuildingContext buildingContext) {
|
||||
return new SpecialOneToOneType(
|
||||
buildingContext.getBootstrapContext().getTypeConfiguration(),
|
||||
referencedEntityName,
|
||||
foreignKeyType,
|
||||
referenceToPrimaryKey,
|
||||
referencedPropertyName,
|
||||
lazy,
|
||||
unwrapProxy,
|
||||
owningEntityName,
|
||||
owningEntityPropertyName,
|
||||
constrained
|
||||
);
|
||||
}
|
||||
|
||||
public static OneToOneType oneToOne(
|
||||
String referencedEntityName,
|
||||
ForeignKeyDirection foreignKeyType,
|
||||
boolean referenceToPrimaryKey,
|
||||
String referencedPropertyName,
|
||||
boolean lazy,
|
||||
boolean unwrapProxy,
|
||||
String owningEntityName,
|
||||
String owningEntityPropertyName,
|
||||
boolean constrained,
|
||||
MetadataBuildingContext buildingContext) {
|
||||
return new OneToOneType(
|
||||
buildingContext.getBootstrapContext().getTypeConfiguration(),
|
||||
referencedEntityName,
|
||||
foreignKeyType,
|
||||
referenceToPrimaryKey,
|
||||
referencedPropertyName,
|
||||
lazy,
|
||||
unwrapProxy,
|
||||
owningEntityName,
|
||||
owningEntityPropertyName,
|
||||
constrained
|
||||
);
|
||||
}
|
||||
}
|
@ -12,7 +12,6 @@
|
||||
import org.hibernate.FetchMode;
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||
import org.hibernate.boot.spi.MetadataImplementor;
|
||||
import org.hibernate.engine.spi.Mapping;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.type.EntityType;
|
||||
@ -24,41 +23,34 @@
|
||||
* @author Gavin King
|
||||
*/
|
||||
public class OneToMany implements Value {
|
||||
private final MetadataImplementor metadata;
|
||||
private final MetadataBuildingContext buildingContext;
|
||||
private final Table referencingTable;
|
||||
|
||||
private String referencedEntityName;
|
||||
private PersistentClass associatedClass;
|
||||
private boolean ignoreNotFound;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link OneToMany#OneToMany(MetadataBuildingContext, PersistentClass)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public OneToMany(MetadataImplementor metadata, PersistentClass owner) throws MappingException {
|
||||
this.metadata = metadata;
|
||||
this.referencingTable = ( owner == null ) ? null : owner.getTable();
|
||||
}
|
||||
|
||||
public OneToMany(MetadataBuildingContext buildingContext, PersistentClass owner) throws MappingException {
|
||||
this.metadata = buildingContext.getMetadataCollector();
|
||||
this.buildingContext = buildingContext;
|
||||
this.referencingTable = ( owner == null ) ? null : owner.getTable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServiceRegistry getServiceRegistry() {
|
||||
return metadata.getMetadataBuildingOptions().getServiceRegistry();
|
||||
return buildingContext.getBuildingOptions().getServiceRegistry();
|
||||
}
|
||||
|
||||
private EntityType getEntityType() {
|
||||
return metadata.getTypeResolver().getTypeFactory().manyToOne(
|
||||
return MappingHelper.manyToOne(
|
||||
getReferencedEntityName(),
|
||||
true,
|
||||
null,
|
||||
null,
|
||||
false,
|
||||
false,
|
||||
isIgnoreNotFound(),
|
||||
false
|
||||
false,
|
||||
buildingContext
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -63,29 +63,31 @@ public void setEntityName(String propertyName) {
|
||||
|
||||
public Type getType() throws MappingException {
|
||||
if ( getColumnIterator().hasNext() ) {
|
||||
return getMetadata().getTypeResolver().getTypeFactory().specialOneToOne(
|
||||
getReferencedEntityName(),
|
||||
foreignKeyType,
|
||||
referenceToPrimaryKey,
|
||||
referencedPropertyName,
|
||||
return MappingHelper.specialOneToOne(
|
||||
getReferencedEntityName(),
|
||||
getForeignKeyType(),
|
||||
isReferenceToPrimaryKey(),
|
||||
getReferencedPropertyName(),
|
||||
isLazy(),
|
||||
isUnwrapProxy(),
|
||||
entityName,
|
||||
propertyName,
|
||||
constrained
|
||||
getEntityName(),
|
||||
getPropertyName(),
|
||||
isConstrained(),
|
||||
getBuildingContext()
|
||||
);
|
||||
}
|
||||
else {
|
||||
return getMetadata().getTypeResolver().getTypeFactory().oneToOne(
|
||||
getReferencedEntityName(),
|
||||
foreignKeyType,
|
||||
referenceToPrimaryKey,
|
||||
referencedPropertyName,
|
||||
return MappingHelper.oneToOne(
|
||||
getReferencedEntityName(),
|
||||
getForeignKeyType(),
|
||||
isReferenceToPrimaryKey(),
|
||||
getReferencedPropertyName(),
|
||||
isLazy(),
|
||||
isUnwrapProxy(),
|
||||
entityName,
|
||||
propertyName,
|
||||
constrained
|
||||
isConstrained(),
|
||||
getBuildingContext()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -7,20 +7,11 @@
|
||||
package org.hibernate.mapping;
|
||||
|
||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||
import org.hibernate.boot.spi.MetadataImplementor;
|
||||
|
||||
/**
|
||||
* A primitive array has a primary key consisting of the key columns + index column.
|
||||
*/
|
||||
public class PrimitiveArray extends Array {
|
||||
/**
|
||||
* @deprecated Use {@link PrimitiveArray#PrimitiveArray(MetadataBuildingContext, PersistentClass)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public PrimitiveArray(MetadataImplementor metadata, PersistentClass owner) {
|
||||
super( metadata, owner );
|
||||
}
|
||||
|
||||
public PrimitiveArray(MetadataBuildingContext buildingContext, PersistentClass owner) {
|
||||
super( buildingContext, owner );
|
||||
}
|
||||
|
@ -10,9 +10,11 @@
|
||||
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||
import org.hibernate.boot.spi.MetadataImplementor;
|
||||
import org.hibernate.engine.spi.Mapping;
|
||||
import org.hibernate.type.CollectionType;
|
||||
import org.hibernate.type.OrderedSetType;
|
||||
import org.hibernate.type.SetType;
|
||||
import org.hibernate.type.SortedSetType;
|
||||
|
||||
/**
|
||||
* A set with no nullable element columns. It will have a primary key
|
||||
@ -20,14 +22,6 @@
|
||||
* @author Gavin King
|
||||
*/
|
||||
public class Set extends Collection {
|
||||
/**
|
||||
* @deprecated Use {@link Set#Set(MetadataBuildingContext, PersistentClass)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public Set(MetadataImplementor metadata, PersistentClass owner) {
|
||||
super( metadata, owner );
|
||||
}
|
||||
|
||||
public Set(MetadataBuildingContext buildingContext, PersistentClass owner) {
|
||||
super( buildingContext, owner );
|
||||
}
|
||||
@ -51,20 +45,14 @@ public boolean isSet() {
|
||||
|
||||
public CollectionType getDefaultCollectionType() {
|
||||
if ( isSorted() ) {
|
||||
return getMetadata().getTypeResolver()
|
||||
.getTypeFactory()
|
||||
.sortedSet( getRole(), getReferencedPropertyName(), getComparator() );
|
||||
return new SortedSetType( getTypeConfiguration(), getRole(), getReferencedPropertyName(), getComparator() );
|
||||
}
|
||||
else if ( hasOrder() ) {
|
||||
return getMetadata().getTypeResolver()
|
||||
.getTypeFactory()
|
||||
.orderedSet( getRole(), getReferencedPropertyName() );
|
||||
}
|
||||
else {
|
||||
return getMetadata().getTypeResolver()
|
||||
.getTypeFactory()
|
||||
.set( getRole(), getReferencedPropertyName() );
|
||||
|
||||
if ( hasOrder() ) {
|
||||
return new OrderedSetType( getTypeConfiguration(), getRole(), getReferencedPropertyName() );
|
||||
}
|
||||
|
||||
return new SetType( getTypeConfiguration(), getRole(), getReferencedPropertyName() );
|
||||
}
|
||||
|
||||
void createPrimaryKey() {
|
||||
|
@ -13,8 +13,8 @@
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Properties;
|
||||
import java.util.Objects;
|
||||
import java.util.Properties;
|
||||
import javax.persistence.AttributeConverter;
|
||||
|
||||
import org.hibernate.FetchMode;
|
||||
@ -60,7 +60,7 @@
|
||||
* Any value that maps to columns.
|
||||
* @author Gavin King
|
||||
*/
|
||||
public class SimpleValue implements KeyValue {
|
||||
public abstract class SimpleValue implements KeyValue {
|
||||
private static final CoreMessageLogger log = CoreLogging.messageLogger( SimpleValue.class );
|
||||
|
||||
public static final String DEFAULT_ID_GEN_STRATEGY = "assigned";
|
||||
@ -119,6 +119,10 @@ public SimpleValue(MetadataBuildingContext buildingContext, Table table) {
|
||||
this.table = table;
|
||||
}
|
||||
|
||||
public MetadataBuildingContext getBuildingContext() {
|
||||
return buildingContext;
|
||||
}
|
||||
|
||||
public MetadataImplementor getMetadata() {
|
||||
return metadata;
|
||||
}
|
||||
@ -197,8 +201,8 @@ public String getTypeName() {
|
||||
}
|
||||
|
||||
public void setTypeName(String typeName) {
|
||||
if ( typeName != null && typeName.startsWith( AttributeConverterTypeAdapter.NAME_PREFIX ) ) {
|
||||
final String converterClassName = typeName.substring( AttributeConverterTypeAdapter.NAME_PREFIX.length() );
|
||||
if ( typeName != null && typeName.startsWith( ConverterDescriptor.TYPE_NAME_PREFIX ) ) {
|
||||
final String converterClassName = typeName.substring( ConverterDescriptor.TYPE_NAME_PREFIX.length() );
|
||||
final ClassLoaderService cls = getMetadata()
|
||||
.getMetadataBuildingOptions()
|
||||
.getServiceRegistry()
|
||||
@ -451,41 +455,44 @@ public boolean isValid(Mapping mapping) throws MappingException {
|
||||
return getColumnSpan()==getType().getColumnSpan(mapping);
|
||||
}
|
||||
|
||||
public Type getType() throws MappingException {
|
||||
if ( type != null ) {
|
||||
return type;
|
||||
}
|
||||
|
||||
if ( typeName == null ) {
|
||||
throw new MappingException( "No type name" );
|
||||
}
|
||||
|
||||
if ( typeParameters != null
|
||||
&& Boolean.valueOf( typeParameters.getProperty( DynamicParameterizedType.IS_DYNAMIC ) )
|
||||
&& typeParameters.get( DynamicParameterizedType.PARAMETER_TYPE ) == null ) {
|
||||
createParameterImpl();
|
||||
}
|
||||
|
||||
Type result = getMetadata().getTypeConfiguration().getTypeResolver().heuristicType( typeName, typeParameters );
|
||||
// if this is a byte[] version/timestamp, then we need to use RowVersionType
|
||||
// instead of BinaryType (HHH-10413)
|
||||
if ( isVersion && BinaryType.class.isInstance( result ) ) {
|
||||
log.debug( "version is BinaryType; changing to RowVersionType" );
|
||||
result = RowVersionType.INSTANCE;
|
||||
}
|
||||
if ( result == null ) {
|
||||
String msg = "Could not determine type for: " + typeName;
|
||||
if ( table != null ) {
|
||||
msg += ", at table: " + table.getName();
|
||||
}
|
||||
if ( columns != null && columns.size() > 0 ) {
|
||||
msg += ", for columns: " + columns;
|
||||
}
|
||||
throw new MappingException( msg );
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
// public Type getType() throws MappingException {
|
||||
// if ( type != null ) {
|
||||
// return type;
|
||||
// }
|
||||
//
|
||||
// if ( typeName == null ) {
|
||||
// throw new MappingException( "No type name" );
|
||||
// }
|
||||
//
|
||||
// if ( typeParameters != null
|
||||
// && Boolean.valueOf( typeParameters.getProperty( DynamicParameterizedType.IS_DYNAMIC ) )
|
||||
// && typeParameters.get( DynamicParameterizedType.PARAMETER_TYPE ) == null ) {
|
||||
// createParameterImpl();
|
||||
// }
|
||||
//
|
||||
// Type result = getMetadata().getTypeConfiguration().getTypeResolver().heuristicType( typeName, typeParameters );
|
||||
//
|
||||
// if ( isVersion && result instanceof BinaryType ) {
|
||||
// // if this is a byte[] version/timestamp, then we need to use RowVersionType
|
||||
// // instead of BinaryType (HHH-10413)
|
||||
// // todo (6.0) - although for T/SQL databases we should use its
|
||||
// log.debug( "version is BinaryType; changing to RowVersionType" );
|
||||
// result = RowVersionType.INSTANCE;
|
||||
// }
|
||||
//
|
||||
// if ( result == null ) {
|
||||
// String msg = "Could not determine type for: " + typeName;
|
||||
// if ( table != null ) {
|
||||
// msg += ", at table: " + table.getName();
|
||||
// }
|
||||
// if ( columns != null && columns.size() > 0 ) {
|
||||
// msg += ", for columns: " + columns;
|
||||
// }
|
||||
// throw new MappingException( msg );
|
||||
// }
|
||||
//
|
||||
// return result;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void setTypeUsingReflection(String className, String propertyName) throws MappingException {
|
||||
@ -640,7 +647,7 @@ public org.hibernate.type.descriptor.java.spi.JavaTypeDescriptorRegistry getJava
|
||||
|
||||
// todo : cache the AttributeConverterTypeAdapter in case that AttributeConverter is applied multiple times.
|
||||
|
||||
final String name = AttributeConverterTypeAdapter.NAME_PREFIX + jpaAttributeConverter.getConverterJavaTypeDescriptor().getJavaType().getName();
|
||||
final String name = ConverterDescriptor.TYPE_NAME_PREFIX + jpaAttributeConverter.getConverterJavaTypeDescriptor().getJavaType().getName();
|
||||
final String description = String.format(
|
||||
"BasicType adapter for AttributeConverter<%s,%s>",
|
||||
jpaAttributeConverter.getDomainJavaTypeDescriptor().getJavaType().getSimpleName(),
|
||||
@ -721,6 +728,10 @@ private static boolean[] extractBooleansFromList(List<Boolean> list) {
|
||||
return array;
|
||||
}
|
||||
|
||||
public ConverterDescriptor getJpaAttributeConverterDescriptor() {
|
||||
return attributeConverterDescriptor;
|
||||
}
|
||||
|
||||
public void setJpaAttributeConverterDescriptor(ConverterDescriptor descriptor) {
|
||||
this.attributeConverterDescriptor = descriptor;
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ public void setPropertyName(String propertyName) {
|
||||
|
||||
@Override
|
||||
public void setTypeUsingReflection(String className, String propertyName) throws MappingException {
|
||||
if (referencedEntityName == null) {
|
||||
if ( referencedEntityName == null ) {
|
||||
final ClassLoaderService cls = getMetadata().getMetadataBuildingOptions()
|
||||
.getServiceRegistry()
|
||||
.getService( ClassLoaderService.class );
|
||||
|
@ -150,6 +150,11 @@ public <X, Y> SingularPersistentAttribute<X, Y> buildIdAttribute(
|
||||
Property property) {
|
||||
LOG.trace( "Building identifier attribute [" + ownerType.getTypeName() + "." + property.getName() + "]" );
|
||||
|
||||
// ownerType = Entity(Person)
|
||||
// MetadataContext#containerRoleStack -> Person
|
||||
|
||||
// id-attribute = "id"
|
||||
|
||||
final SingularAttributeMetadata<X, Y> attributeMetadata = (SingularAttributeMetadata) determineAttributeMetadata(
|
||||
wrap( ownerType, property ),
|
||||
identifierMemberResolver
|
||||
|
@ -26,8 +26,6 @@
|
||||
import org.hibernate.internal.HEMLogging;
|
||||
import org.hibernate.internal.util.ReflectHelper;
|
||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||
import org.hibernate.internal.util.collections.Stack;
|
||||
import org.hibernate.internal.util.collections.StandardStack;
|
||||
import org.hibernate.mapping.Component;
|
||||
import org.hibernate.mapping.KeyValue;
|
||||
import org.hibernate.mapping.MappedSuperclass;
|
||||
@ -98,8 +96,6 @@ public class MetadataContext {
|
||||
private List<PersistentClass> stackOfPersistentClassesBeingProcessed = new ArrayList<>();
|
||||
private DomainMetamodel metamodel;
|
||||
|
||||
private Stack<String> containerRoleStack = new StandardStack<>();
|
||||
|
||||
public MetadataContext(
|
||||
JpaMetamodel jpaMetamodel,
|
||||
RuntimeModelCreationContext runtimeModelCreationContext,
|
||||
@ -133,10 +129,6 @@ DomainMetamodel getMetamodel() {
|
||||
return metamodel;
|
||||
}
|
||||
|
||||
public Stack<String> getContainerRoleStack() {
|
||||
return containerRoleStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the {@linkplain Class java type} to {@link EntityTypeImpl} map.
|
||||
*
|
||||
@ -257,39 +249,32 @@ public void wrapUp() {
|
||||
try {
|
||||
final EntityDomainType<?> jpaMapping = entityTypesByPersistentClass.get( safeMapping );
|
||||
|
||||
containerRoleStack.push( jpaMapping.getMappingRole() );
|
||||
applyIdMetadata( safeMapping, jpaMapping );
|
||||
applyVersionAttribute( safeMapping, jpaMapping );
|
||||
|
||||
try {
|
||||
applyIdMetadata( safeMapping, jpaMapping );
|
||||
applyVersionAttribute( safeMapping, jpaMapping );
|
||||
|
||||
Iterator<Property> properties = safeMapping.getDeclaredPropertyIterator();
|
||||
while ( properties.hasNext() ) {
|
||||
final Property property = properties.next();
|
||||
if ( property.getValue() == safeMapping.getIdentifierMapper() ) {
|
||||
// property represents special handling for id-class mappings but we have already
|
||||
// accounted for the embedded property mappings in #applyIdMetadata &&
|
||||
// #buildIdClassAttributes
|
||||
continue;
|
||||
}
|
||||
if ( safeMapping.isVersioned() && property == safeMapping.getVersion() ) {
|
||||
// skip the version property, it was already handled previously.
|
||||
continue;
|
||||
}
|
||||
final PersistentAttribute attribute = attributeFactory.buildAttribute(
|
||||
jpaMapping,
|
||||
property
|
||||
);
|
||||
if ( attribute != null ) {
|
||||
( (AttributeContainer) jpaMapping ).getInFlightAccess().addAttribute( attribute );
|
||||
}
|
||||
Iterator<Property> properties = safeMapping.getDeclaredPropertyIterator();
|
||||
while ( properties.hasNext() ) {
|
||||
final Property property = properties.next();
|
||||
if ( property.getValue() == safeMapping.getIdentifierMapper() ) {
|
||||
// property represents special handling for id-class mappings but we have already
|
||||
// accounted for the embedded property mappings in #applyIdMetadata &&
|
||||
// #buildIdClassAttributes
|
||||
continue;
|
||||
}
|
||||
if ( safeMapping.isVersioned() && property == safeMapping.getVersion() ) {
|
||||
// skip the version property, it was already handled previously.
|
||||
continue;
|
||||
}
|
||||
final PersistentAttribute attribute = attributeFactory.buildAttribute(
|
||||
jpaMapping,
|
||||
property
|
||||
);
|
||||
if ( attribute != null ) {
|
||||
( (AttributeContainer) jpaMapping ).getInFlightAccess().addAttribute( attribute );
|
||||
}
|
||||
}
|
||||
|
||||
( (AttributeContainer) jpaMapping ).getInFlightAccess().finishUp();
|
||||
}
|
||||
finally {
|
||||
containerRoleStack.pop();
|
||||
}
|
||||
( (AttributeContainer) jpaMapping ).getInFlightAccess().finishUp();
|
||||
|
||||
if ( staticMetamodelScanEnabled ) {
|
||||
populateStaticMetamodel( jpaMapping );
|
||||
@ -309,31 +294,23 @@ else if ( MappedSuperclass.class.isAssignableFrom( mapping.getClass() ) ) {
|
||||
try {
|
||||
final MappedSuperclassDomainType<?> jpaType = mappedSuperclassByMappedSuperclassMapping.get( safeMapping );
|
||||
|
||||
containerRoleStack.push( jpaType.getTypeName() );
|
||||
applyIdMetadata( safeMapping, jpaType );
|
||||
applyVersionAttribute( safeMapping, jpaType );
|
||||
|
||||
try {
|
||||
|
||||
applyIdMetadata( safeMapping, jpaType );
|
||||
applyVersionAttribute( safeMapping, jpaType );
|
||||
|
||||
Iterator<Property> properties = safeMapping.getDeclaredPropertyIterator();
|
||||
while ( properties.hasNext() ) {
|
||||
final Property property = properties.next();
|
||||
if ( safeMapping.isVersioned() && property == safeMapping.getVersion() ) {
|
||||
// skip the version property, it was already handled previously.
|
||||
continue;
|
||||
}
|
||||
final PersistentAttribute attribute = attributeFactory.buildAttribute( jpaType, property );
|
||||
if ( attribute != null ) {
|
||||
( (AttributeContainer) jpaType ).getInFlightAccess().addAttribute( attribute );
|
||||
}
|
||||
Iterator<Property> properties = safeMapping.getDeclaredPropertyIterator();
|
||||
while ( properties.hasNext() ) {
|
||||
final Property property = properties.next();
|
||||
if ( safeMapping.isVersioned() && property == safeMapping.getVersion() ) {
|
||||
// skip the version property, it was already handled previously.
|
||||
continue;
|
||||
}
|
||||
final PersistentAttribute attribute = attributeFactory.buildAttribute( jpaType, property );
|
||||
if ( attribute != null ) {
|
||||
( (AttributeContainer) jpaType ).getInFlightAccess().addAttribute( attribute );
|
||||
}
|
||||
}
|
||||
|
||||
( (AttributeContainer) jpaType ).getInFlightAccess().finishUp();
|
||||
}
|
||||
finally {
|
||||
containerRoleStack.pop();
|
||||
}
|
||||
( (AttributeContainer) jpaType ).getInFlightAccess().finishUp();
|
||||
|
||||
if ( staticMetamodelScanEnabled ) {
|
||||
populateStaticMetamodel( jpaType );
|
||||
@ -376,22 +353,31 @@ else if ( MappedSuperclass.class.isAssignableFrom( mapping.getClass() ) ) {
|
||||
}
|
||||
|
||||
|
||||
// 1) create the part
|
||||
// 2) register the part (mapping role)
|
||||
// 3) somehow get the mapping role "into" the part (setter, ?)
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void applyIdMetadata(PersistentClass persistentClass, IdentifiableDomainType<?> identifiableType) {
|
||||
if ( persistentClass.hasIdentifierProperty() ) {
|
||||
final Property declaredIdentifierProperty = persistentClass.getDeclaredIdentifierProperty();
|
||||
if ( declaredIdentifierProperty != null ) {
|
||||
( ( AttributeContainer) identifiableType ).getInFlightAccess().applyIdAttribute(
|
||||
attributeFactory.buildIdAttribute( identifiableType, declaredIdentifierProperty )
|
||||
final SingularPersistentAttribute<?, Object> idAttribute = attributeFactory.buildIdAttribute(
|
||||
identifiableType,
|
||||
declaredIdentifierProperty
|
||||
);
|
||||
|
||||
( ( AttributeContainer) identifiableType ).getInFlightAccess().applyIdAttribute( idAttribute );
|
||||
}
|
||||
}
|
||||
else if ( persistentClass.hasIdentifierMapper() ) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Iterator<Property> propertyIterator = persistentClass.getIdentifierMapper().getPropertyIterator();
|
||||
( ( AttributeContainer) identifiableType ).getInFlightAccess().applyIdClassAttributes(
|
||||
buildIdClassAttributes( identifiableType, propertyIterator )
|
||||
final Iterator<Property> propertyIterator = persistentClass.getIdentifierMapper().getPropertyIterator();
|
||||
final Set<SingularPersistentAttribute<?, ?>> idClassAttributes = (Set<SingularPersistentAttribute<?, ?>>) buildIdClassAttributes(
|
||||
identifiableType,
|
||||
propertyIterator
|
||||
);
|
||||
( ( AttributeContainer) identifiableType ).getInFlightAccess().applyIdClassAttributes( idClassAttributes );
|
||||
}
|
||||
else {
|
||||
final KeyValue value = persistentClass.getIdentifier();
|
||||
|
@ -0,0 +1,13 @@
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.metamodel.mapping;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface AnyValuedMapping extends ValueMapping {
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.metamodel.mapping;
|
||||
|
||||
/**
|
||||
* Describes an attribute at the mapping model level.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface AttributeMapping extends ModelPart, ValueMapping {
|
||||
String getAttributeName();
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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.mapping;
|
||||
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
/**
|
||||
* Any basic-typed ValueMapping - e.g. a basic-valued singular attribute or a
|
||||
* basic-valued collection element
|
||||
*
|
||||
* todo (6.0) : better to use {@link org.hibernate.metamodel.relational.Identifier} instead to handle quoting?
|
||||
*
|
||||
* todo (6.0) : expose {@link org.hibernate.metamodel.model.convert.spi.BasicValueConverter}?
|
||||
* - Or just handle internal to impl?
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface BasicValuedMapping extends ValueMapping, SqlExpressable {
|
||||
@Override
|
||||
default int getJdbcTypeCount(TypeConfiguration typeConfiguration) {
|
||||
return 1;
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.mapping;
|
||||
|
||||
import org.hibernate.metamodel.model.convert.spi.BasicValueConverter;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface BasicValuedModelPart extends BasicValuedMapping, ModelPart {
|
||||
/**
|
||||
* The table expression (table name or subselect) that contains
|
||||
* the {@linkplain #getMappedColumnExpression mapped column}
|
||||
*/
|
||||
String getContainingTableExpression();
|
||||
|
||||
/**
|
||||
* The column expression (column name or formula) to which this basic value
|
||||
* is mapped
|
||||
*/
|
||||
String getMappedColumnExpression();
|
||||
|
||||
/**
|
||||
* Get the value converter applied to this model part if any
|
||||
*/
|
||||
BasicValueConverter getConverter();
|
||||
}
|
@ -7,6 +7,7 @@
|
||||
package org.hibernate.metamodel.mapping;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.hibernate.NotYetImplementedFor6Exception;
|
||||
@ -18,8 +19,6 @@
|
||||
* Contract for things at the domain/mapping level that can be bound into a JDBC
|
||||
* query.
|
||||
*
|
||||
* `SqlAstExpressable`? Similar to `SqmExpressable`.
|
||||
*
|
||||
* Notice that there may be more than one JDBC parameter involved here - an embedded value, e.g.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
@ -36,13 +35,15 @@ default int getJdbcTypeCount(TypeConfiguration typeConfiguration) {
|
||||
return value.get();
|
||||
}
|
||||
|
||||
// todo (6.0) : why did I do 2 forms of JDBC-type visiting? in-flight change?
|
||||
|
||||
/**
|
||||
* Visit all of the SqlExpressableTypes associated with this this Writeable.
|
||||
* Visit all of the SqlExpressableTypes associated with this this Bindable.
|
||||
* <p>
|
||||
* Used during cacheable SQL AST creation.
|
||||
*/
|
||||
default void visitJdbcTypes(
|
||||
Consumer<SqlExpressableType> action,
|
||||
Consumer<JdbcMapping> action,
|
||||
Clause clause,
|
||||
TypeConfiguration typeConfiguration) {
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
@ -146,6 +147,6 @@ interface JdbcValuesConsumer {
|
||||
/**
|
||||
* Consume a JDBC-level value. The JDBC type descriptor is also passed in
|
||||
*/
|
||||
void consume(Object value, SqlExpressableType type);
|
||||
void consume(Object value, JdbcMapping type);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.metamodel.mapping;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface EntityIdentifierMapping extends ValueMapping, ModelPart {
|
||||
String ROLE_LOCAL_NAME = "{id}";
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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.mapping;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
|
||||
/**
|
||||
* todo (6.0) : make this implement RootTableGroupProducer, etc instead of EntityPersister?
|
||||
*
|
||||
* todo (6.0) : leverage the "relational model" here?
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface EntityMappingType extends ManagedMappingType {
|
||||
/**
|
||||
* Safety-net.
|
||||
*
|
||||
* todo (6.0) : do we really need to expose?
|
||||
*/
|
||||
EntityPersister getEntityPersister();
|
||||
|
||||
EntityIdentifierMapping getIdentifierMapping();
|
||||
|
||||
EntityVersionMapping getVersionMapping();
|
||||
|
||||
default String getEntityName() {
|
||||
return getEntityPersister().getEntityName();
|
||||
}
|
||||
|
||||
// todo (6.0) : not sure we actually need this distinction at the mapping model level...
|
||||
|
||||
// /**
|
||||
// * For an entity, this form allows for Hibernate's "implicit treat" support -
|
||||
// * meaning it should find a sub-part whether defined on the entity, its
|
||||
// * super-type or even one of its sub-types.
|
||||
// *
|
||||
// * @see #findSubPartStrictly
|
||||
// */
|
||||
// @Override
|
||||
// ModelPart findSubPart(String name);
|
||||
//
|
||||
// /**
|
||||
// * Same purpose as {@link #findSubPart} except that this form limits
|
||||
// * the search to just this type and its super types.
|
||||
// */
|
||||
// ModelPart findSubPartStrictly(String name);
|
||||
//
|
||||
// /**
|
||||
// * Like {@link #findSubPart}, this form visits all parts defined on the
|
||||
// * entity, its super-types and its sub-types.
|
||||
// *
|
||||
// * @see #findSubPartStrictly
|
||||
// */
|
||||
// @Override
|
||||
// void visitSubParts(Consumer<ModelPart> consumer);
|
||||
//
|
||||
// /**
|
||||
// * Same purpose as {@link #visitSubParts} except that this form limits
|
||||
// * the visitation to just this type and its super types.
|
||||
// */
|
||||
// void visitSubPartsStrictly(Consumer<ModelPart> action);
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.metamodel.mapping;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface EntityVersionMapping extends SingularAttributeMapping, BasicValuedModelPart {
|
||||
}
|
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface SqlExpressableType {
|
||||
public interface JdbcMapping {
|
||||
/**
|
||||
* The descriptor for the Java type represented by this
|
||||
* expressable type
|
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.metamodel.mapping;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Commonality in regards to the mapping type system for all managed domain
|
||||
* types - entity types, mapped-superclass types, composite types, etc
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface ManagedMappingType extends MappingType, ModelPartContainer {
|
||||
Collection<AttributeMapping> getAttributeMappings();
|
||||
void visitAttributeMappings(Consumer<AttributeMapping> action);
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
/*
|
||||
* 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.mapping;
|
||||
|
||||
import org.hibernate.boot.spi.MetadataImplementor;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.metamodel.spi.DomainMetamodel;
|
||||
|
||||
/**
|
||||
* A context for creation of Hibernate's mapping model. This process
|
||||
* occurs just after the persister model has been created and "post initialized"
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface MappingModelCreationContext {
|
||||
SessionFactoryImplementor getSessionFactory();
|
||||
|
||||
DomainMetamodel getDomainModel();
|
||||
|
||||
MetadataImplementor getBootModel();
|
||||
}
|
@ -6,12 +6,6 @@
|
||||
*/
|
||||
package org.hibernate.metamodel.mapping;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.hibernate.NotYetImplementedFor6Exception;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
/**
|
||||
* Something that can be expressable at the mapping model level.
|
||||
*
|
||||
@ -22,19 +16,5 @@
|
||||
* @author Steve Ebersole
|
||||
* @author Andrea Boriero
|
||||
*/
|
||||
public interface MappingModelExpressable<T> {
|
||||
JavaTypeDescriptor<T> getExpressableJavaTypeDescriptor();
|
||||
|
||||
// todo (6.0) : others?
|
||||
// Probably `org.hibernate.metamodel.mapping.Bindable` should be consumed here. Or at least exposed from here
|
||||
//
|
||||
// todo (6.0) : IMO `Bindable` should be consumed here and `Bindable` go away
|
||||
|
||||
default void visitJdbcTypes(Consumer<SqlExpressableType> action, TypeConfiguration typeConfiguration){
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
}
|
||||
|
||||
default Bindable getBindable() {
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
}
|
||||
public interface MappingModelExpressable<T> extends Bindable {
|
||||
}
|
||||
|
@ -0,0 +1,13 @@
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.metamodel.mapping;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface MappingModelVisitor {
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.metamodel.mapping;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class MappingModelWalker {
|
||||
}
|
@ -20,6 +20,8 @@
|
||||
* @see DomainResultProducer
|
||||
* @see javax.persistence.metamodel.Bindable
|
||||
*
|
||||
* todo (6.0) : do we need to expose ModelPartContainer here? Only if _necessary_
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface ModelPart extends MappingModelExpressable {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user