HHH-18462 Provide alternatives to deprecated org.hibernate.engine.spi.Mapping
This commit is contained in:
parent
e411775c70
commit
1b0cc59913
|
@ -21,12 +21,12 @@ import org.hibernate.boot.query.NamedNativeQueryDefinition;
|
||||||
import org.hibernate.boot.query.NamedProcedureCallDefinition;
|
import org.hibernate.boot.query.NamedProcedureCallDefinition;
|
||||||
import org.hibernate.boot.query.NamedResultSetMappingDescriptor;
|
import org.hibernate.boot.query.NamedResultSetMappingDescriptor;
|
||||||
import org.hibernate.engine.spi.FilterDefinition;
|
import org.hibernate.engine.spi.FilterDefinition;
|
||||||
import org.hibernate.engine.spi.Mapping;
|
|
||||||
import org.hibernate.mapping.Collection;
|
import org.hibernate.mapping.Collection;
|
||||||
import org.hibernate.mapping.FetchProfile;
|
import org.hibernate.mapping.FetchProfile;
|
||||||
import org.hibernate.mapping.PersistentClass;
|
import org.hibernate.mapping.PersistentClass;
|
||||||
import org.hibernate.mapping.Table;
|
import org.hibernate.mapping.Table;
|
||||||
import org.hibernate.query.sqm.function.SqmFunctionDescriptor;
|
import org.hibernate.query.sqm.function.SqmFunctionDescriptor;
|
||||||
|
import org.hibernate.type.MappingContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the ORM model as determined by aggregating the provided mapping sources.
|
* Represents the ORM model as determined by aggregating the provided mapping sources.
|
||||||
|
@ -36,7 +36,7 @@ import org.hibernate.query.sqm.function.SqmFunctionDescriptor;
|
||||||
*
|
*
|
||||||
* @since 5.0
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
public interface Metadata extends Mapping {
|
public interface Metadata extends MappingContext {
|
||||||
/**
|
/**
|
||||||
* Get the builder for {@link SessionFactory} instances based on this metamodel.
|
* Get the builder for {@link SessionFactory} instances based on this metamodel.
|
||||||
*
|
*
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.engine.spi;
|
package org.hibernate.engine.spi;
|
||||||
|
|
||||||
import org.hibernate.MappingException;
|
|
||||||
import org.hibernate.type.Type;
|
import org.hibernate.type.Type;
|
||||||
|
import org.hibernate.type.MappingContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Declares operations used by implementors of {@link Type} that are common to
|
* Declares operations used by implementors of {@link Type} that are common to
|
||||||
|
@ -23,11 +23,9 @@ import org.hibernate.type.Type;
|
||||||
* @deprecated Use {@link org.hibernate.type.spi.TypeConfiguration},
|
* @deprecated Use {@link org.hibernate.type.spi.TypeConfiguration},
|
||||||
* {@link org.hibernate.boot.Metadata}, or
|
* {@link org.hibernate.boot.Metadata}, or
|
||||||
* {@link org.hibernate.metamodel.RuntimeMetamodels}
|
* {@link org.hibernate.metamodel.RuntimeMetamodels}
|
||||||
|
* or {@link MappingContext}
|
||||||
* to access such information
|
* to access such information
|
||||||
*/
|
*/
|
||||||
@Deprecated(since = "6.0")
|
@Deprecated(since = "6.0")
|
||||||
public interface Mapping {
|
public interface Mapping extends MappingContext {
|
||||||
Type getIdentifierType(String className) throws MappingException;
|
|
||||||
String getIdentifierPropertyName(String className) throws MappingException;
|
|
||||||
Type getReferencedPropertyType(String className, String propertyName) throws MappingException;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ import org.hibernate.stat.spi.StatisticsImplementor;
|
||||||
import org.hibernate.generator.Generator;
|
import org.hibernate.generator.Generator;
|
||||||
import org.hibernate.type.descriptor.WrapperOptions;
|
import org.hibernate.type.descriptor.WrapperOptions;
|
||||||
import org.hibernate.type.descriptor.java.JavaType;
|
import org.hibernate.type.descriptor.java.JavaType;
|
||||||
|
import org.hibernate.type.MappingContext;
|
||||||
import org.hibernate.type.spi.TypeConfiguration;
|
import org.hibernate.type.spi.TypeConfiguration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,7 +47,7 @@ import org.hibernate.type.spi.TypeConfiguration;
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public interface SessionFactoryImplementor
|
public interface SessionFactoryImplementor
|
||||||
extends Mapping, SessionFactory, SqmCreationContext, SqlAstCreationContext,
|
extends MappingContext, SessionFactory, SqmCreationContext, SqlAstCreationContext,
|
||||||
QueryParameterBindingTypeResolver { //deprecated extension, use MappingMetamodel
|
QueryParameterBindingTypeResolver { //deprecated extension, use MappingMetamodel
|
||||||
/**
|
/**
|
||||||
* Get the UUID for this {@code SessionFactory}.
|
* Get the UUID for this {@code SessionFactory}.
|
||||||
|
|
|
@ -12,7 +12,6 @@ import org.hibernate.FetchMode;
|
||||||
import org.hibernate.MappingException;
|
import org.hibernate.MappingException;
|
||||||
import org.hibernate.boot.model.relational.Database;
|
import org.hibernate.boot.model.relational.Database;
|
||||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||||
import org.hibernate.engine.spi.Mapping;
|
|
||||||
import org.hibernate.internal.util.collections.ArrayHelper;
|
import org.hibernate.internal.util.collections.ArrayHelper;
|
||||||
import org.hibernate.mapping.Column;
|
import org.hibernate.mapping.Column;
|
||||||
import org.hibernate.mapping.Selectable;
|
import org.hibernate.mapping.Selectable;
|
||||||
|
@ -22,6 +21,7 @@ import org.hibernate.mapping.ValueVisitor;
|
||||||
import org.hibernate.service.ServiceRegistry;
|
import org.hibernate.service.ServiceRegistry;
|
||||||
import org.hibernate.type.BasicType;
|
import org.hibernate.type.BasicType;
|
||||||
import org.hibernate.type.Type;
|
import org.hibernate.type.Type;
|
||||||
|
import org.hibernate.type.MappingContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
|
@ -148,7 +148,7 @@ public class ExportableColumn extends Column {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid(Mapping mapping) throws MappingException {
|
public boolean isValid(MappingContext mappingContext) throws MappingException {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,9 +14,9 @@ import java.util.function.Consumer;
|
||||||
import org.hibernate.MappingException;
|
import org.hibernate.MappingException;
|
||||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||||
import org.hibernate.engine.spi.Mapping;
|
|
||||||
import org.hibernate.type.AnyType;
|
import org.hibernate.type.AnyType;
|
||||||
import org.hibernate.type.Type;
|
import org.hibernate.type.Type;
|
||||||
|
import org.hibernate.type.MappingContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A mapping model object representing a {@linkplain org.hibernate.annotations.Any polymorphic association}
|
* A mapping model object representing a {@linkplain org.hibernate.annotations.Any polymorphic association}
|
||||||
|
@ -225,10 +225,12 @@ public class Any extends SimpleValue {
|
||||||
this.lazy = lazy;
|
this.lazy = lazy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setTypeUsingReflection(String className, String propertyName)
|
public void setTypeUsingReflection(String className, String propertyName)
|
||||||
throws MappingException {
|
throws MappingException {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object accept(ValueVisitor visitor) {
|
public Object accept(ValueVisitor visitor) {
|
||||||
return visitor.accept(this);
|
return visitor.accept(this);
|
||||||
}
|
}
|
||||||
|
@ -250,11 +252,12 @@ public class Any extends SimpleValue {
|
||||||
return simpleValue != null ? simpleValue.getTypeName() : null;
|
return simpleValue != null ? simpleValue.getTypeName() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isValid(Mapping mapping) throws MappingException {
|
@Override
|
||||||
|
public boolean isValid(MappingContext mappingContext) throws MappingException {
|
||||||
if ( discriminatorDescriptor != null ) {
|
if ( discriminatorDescriptor != null ) {
|
||||||
return discriminatorDescriptor.isValid( mapping ) && keyDescriptor.isValid( mapping );
|
return discriminatorDescriptor.isValid( mappingContext ) && keyDescriptor.isValid( mappingContext );
|
||||||
}
|
}
|
||||||
return metaMapping.isValid( mapping ) && keyMapping.isValid( mapping );
|
return metaMapping.isValid( mappingContext ) && keyMapping.isValid( mappingContext );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String columnName(Column column, MetadataBuildingContext buildingContext) {
|
private static String columnName(Column column, MetadataBuildingContext buildingContext) {
|
||||||
|
@ -391,9 +394,9 @@ public class Any extends SimpleValue {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid(Mapping mapping) {
|
public boolean isValid(MappingContext mappingContext) {
|
||||||
return columnName != null
|
return columnName != null
|
||||||
&& getType().getColumnSpan( mapping ) == 1;
|
&& getType().getColumnSpan( mappingContext ) == 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -465,9 +468,9 @@ public class Any extends SimpleValue {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid(Mapping mapping) throws MappingException {
|
public boolean isValid(MappingContext mappingContext) throws MappingException {
|
||||||
// check
|
// check
|
||||||
return super.isValid( mapping );
|
return super.isValid( mappingContext );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ import org.hibernate.service.ServiceRegistry;
|
||||||
import org.hibernate.type.CollectionType;
|
import org.hibernate.type.CollectionType;
|
||||||
import org.hibernate.type.CustomCollectionType;
|
import org.hibernate.type.CustomCollectionType;
|
||||||
import org.hibernate.type.Type;
|
import org.hibernate.type.Type;
|
||||||
|
import org.hibernate.type.MappingContext;
|
||||||
import org.hibernate.usertype.UserCollectionType;
|
import org.hibernate.usertype.UserCollectionType;
|
||||||
|
|
||||||
import static org.hibernate.internal.util.collections.ArrayHelper.EMPTY_BOOLEAN_ARRAY;
|
import static org.hibernate.internal.util.collections.ArrayHelper.EMPTY_BOOLEAN_ARRAY;
|
||||||
|
@ -245,10 +246,12 @@ public abstract class Collection implements Fetchable, Value, Filterable, SoftDe
|
||||||
return comparator;
|
return comparator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isLazy() {
|
public boolean isLazy() {
|
||||||
return lazy;
|
return lazy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setLazy(boolean lazy) {
|
public void setLazy(boolean lazy) {
|
||||||
this.lazy = lazy;
|
this.lazy = lazy;
|
||||||
}
|
}
|
||||||
|
@ -267,6 +270,7 @@ public abstract class Collection implements Fetchable, Value, Filterable, SoftDe
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean hasFormula() {
|
public boolean hasFormula() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -363,29 +367,39 @@ public abstract class Collection implements Fetchable, Value, Filterable, SoftDe
|
||||||
this.batchSize = batchSize;
|
this.batchSize = batchSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public FetchMode getFetchMode() {
|
public FetchMode getFetchMode() {
|
||||||
return fetchMode;
|
return fetchMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setFetchMode(FetchMode fetchMode) {
|
public void setFetchMode(FetchMode fetchMode) {
|
||||||
this.fetchMode = fetchMode;
|
this.fetchMode = fetchMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use {@link #validate(MappingContext)}
|
||||||
|
*/
|
||||||
|
@Deprecated(since = "7.0")
|
||||||
public void validate(Mapping mapping) throws MappingException {
|
public void validate(Mapping mapping) throws MappingException {
|
||||||
|
validate( (MappingContext) mapping);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void validate(MappingContext mappingContext) throws MappingException {
|
||||||
assert getKey() != null : "Collection key not bound : " + getRole();
|
assert getKey() != null : "Collection key not bound : " + getRole();
|
||||||
assert getElement() != null : "Collection element not bound : " + getRole();
|
assert getElement() != null : "Collection element not bound : " + getRole();
|
||||||
|
|
||||||
if ( !getKey().isValid( mapping ) ) {
|
if ( !getKey().isValid( mappingContext ) ) {
|
||||||
throw new MappingException(
|
throw new MappingException(
|
||||||
"collection foreign key mapping has wrong number of columns: "
|
"collection foreign key mappingContext has wrong number of columns: "
|
||||||
+ getRole()
|
+ getRole()
|
||||||
+ " type: "
|
+ " type: "
|
||||||
+ getKey().getType().getName()
|
+ getKey().getType().getName()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if ( !getElement().isValid( mapping ) ) {
|
if ( !getElement().isValid( mappingContext ) ) {
|
||||||
throw new MappingException(
|
throw new MappingException(
|
||||||
"collection element mapping has wrong number of columns: "
|
"collection element mappingContext has wrong number of columns: "
|
||||||
+ getRole()
|
+ getRole()
|
||||||
+ " type: "
|
+ " type: "
|
||||||
+ getElement().getType().getName()
|
+ getElement().getType().getName()
|
||||||
|
@ -420,10 +434,12 @@ public abstract class Collection implements Fetchable, Value, Filterable, SoftDe
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getColumnSpan() {
|
public int getColumnSpan() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Type getType() throws MappingException {
|
public Type getType() throws MappingException {
|
||||||
return getCollectionType();
|
return getCollectionType();
|
||||||
}
|
}
|
||||||
|
@ -483,18 +499,22 @@ public abstract class Collection implements Fetchable, Value, Filterable, SoftDe
|
||||||
return cachedCollectionType;
|
return cachedCollectionType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isNullable() {
|
public boolean isNullable() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isAlternateUniqueKey() {
|
public boolean isAlternateUniqueKey() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Table getTable() {
|
public Table getTable() {
|
||||||
return owner.getTable();
|
return owner.getTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void createForeignKey() {
|
public void createForeignKey() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -502,11 +522,13 @@ public abstract class Collection implements Fetchable, Value, Filterable, SoftDe
|
||||||
public void createUniqueKey(MetadataBuildingContext context) {
|
public void createUniqueKey(MetadataBuildingContext context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isSimpleValue() {
|
public boolean isSimpleValue() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isValid(Mapping mapping) {
|
@Override
|
||||||
|
public boolean isValid(MappingContext mappingContext) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -558,6 +580,7 @@ public abstract class Collection implements Fetchable, Value, Filterable, SoftDe
|
||||||
this.cacheConcurrencyStrategy = cacheConcurrencyStrategy;
|
this.cacheConcurrencyStrategy = cacheConcurrencyStrategy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setTypeUsingReflection(String className, String propertyName) {
|
public void setTypeUsingReflection(String className, String propertyName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -644,6 +667,7 @@ public abstract class Collection implements Fetchable, Value, Filterable, SoftDe
|
||||||
return deleteAllCheckStyle;
|
return deleteAllCheckStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void addFilter(
|
public void addFilter(
|
||||||
String name,
|
String name,
|
||||||
String condition,
|
String condition,
|
||||||
|
@ -662,6 +686,7 @@ public abstract class Collection implements Fetchable, Value, Filterable, SoftDe
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public List<FilterConfiguration> getFilters() {
|
public List<FilterConfiguration> getFilters() {
|
||||||
return filters;
|
return filters;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ import org.hibernate.type.descriptor.JdbcTypeNameMapper;
|
||||||
import org.hibernate.type.descriptor.jdbc.JdbcType;
|
import org.hibernate.type.descriptor.jdbc.JdbcType;
|
||||||
import org.hibernate.type.descriptor.sql.DdlType;
|
import org.hibernate.type.descriptor.sql.DdlType;
|
||||||
import org.hibernate.type.descriptor.sql.spi.DdlTypeRegistry;
|
import org.hibernate.type.descriptor.sql.spi.DdlTypeRegistry;
|
||||||
|
import org.hibernate.type.MappingContext;
|
||||||
import org.hibernate.type.spi.TypeConfiguration;
|
import org.hibernate.type.spi.TypeConfiguration;
|
||||||
|
|
||||||
import static java.util.Collections.unmodifiableList;
|
import static java.util.Collections.unmodifiableList;
|
||||||
|
@ -275,7 +276,15 @@ public class Column implements Selectable, Serializable, Cloneable, ColumnTypeIn
|
||||||
: name.equalsIgnoreCase( column.name ) );
|
: name.equalsIgnoreCase( column.name ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use {@link #getSqlTypeCode(MappingContext)}
|
||||||
|
*/
|
||||||
|
@Deprecated(since = "7.0")
|
||||||
public int getSqlTypeCode(Mapping mapping) throws MappingException{
|
public int getSqlTypeCode(Mapping mapping) throws MappingException{
|
||||||
|
return getSqlTypeCode((MappingContext) mapping);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSqlTypeCode(MappingContext mapping) throws MappingException {
|
||||||
if ( sqlTypeCode == null ) {
|
if ( sqlTypeCode == null ) {
|
||||||
final Type type = getValue().getType();
|
final Type type = getValue().getType();
|
||||||
final int[] sqlTypeCodes;
|
final int[] sqlTypeCodes;
|
||||||
|
@ -309,7 +318,7 @@ public class Column implements Selectable, Serializable, Cloneable, ColumnTypeIn
|
||||||
return sqlTypeCode;
|
return sqlTypeCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getSqlTypeName(DdlTypeRegistry ddlTypeRegistry, Dialect dialect, Mapping mapping) {
|
private String getSqlTypeName(DdlTypeRegistry ddlTypeRegistry, Dialect dialect, MappingContext mapping) {
|
||||||
if ( sqlTypeName == null ) {
|
if ( sqlTypeName == null ) {
|
||||||
final int typeCode = getSqlTypeCode( mapping );
|
final int typeCode = getSqlTypeCode( mapping );
|
||||||
final DdlType descriptor = ddlTypeRegistry.getDescriptor( typeCode );
|
final DdlType descriptor = ddlTypeRegistry.getDescriptor( typeCode );
|
||||||
|
@ -350,21 +359,21 @@ public class Column implements Selectable, Serializable, Cloneable, ColumnTypeIn
|
||||||
return sqlTypeName;
|
return sqlTypeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Type getUnderlyingType(Mapping mapping, Type type, int typeIndex) {
|
private static Type getUnderlyingType(MappingContext mappingContext, Type type, int typeIndex) {
|
||||||
if ( type instanceof ComponentType componentType ) {
|
if ( type instanceof ComponentType componentType ) {
|
||||||
int cols = 0;
|
int cols = 0;
|
||||||
for ( Type subtype : componentType.getSubtypes() ) {
|
for ( Type subtype : componentType.getSubtypes() ) {
|
||||||
int columnSpan = subtype.getColumnSpan( mapping );
|
int columnSpan = subtype.getColumnSpan( mappingContext );
|
||||||
if ( cols+columnSpan > typeIndex ) {
|
if ( cols+columnSpan > typeIndex ) {
|
||||||
return getUnderlyingType( mapping, subtype, typeIndex-cols );
|
return getUnderlyingType( mappingContext, subtype, typeIndex-cols );
|
||||||
}
|
}
|
||||||
cols += columnSpan;
|
cols += columnSpan;
|
||||||
}
|
}
|
||||||
throw new IndexOutOfBoundsException();
|
throw new IndexOutOfBoundsException();
|
||||||
}
|
}
|
||||||
else if ( type instanceof EntityType entityType ) {
|
else if ( type instanceof EntityType entityType ) {
|
||||||
final Type idType = entityType.getIdentifierOrUniqueKeyType( mapping );
|
final Type idType = entityType.getIdentifierOrUniqueKeyType( mappingContext );
|
||||||
return getUnderlyingType( mapping, idType, typeIndex );
|
return getUnderlyingType( mappingContext, idType, typeIndex );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return type;
|
return type;
|
||||||
|
@ -375,7 +384,7 @@ public class Column implements Selectable, Serializable, Cloneable, ColumnTypeIn
|
||||||
* Returns {@linkplain org.hibernate.type.SqlTypes SQL type code}
|
* Returns {@linkplain org.hibernate.type.SqlTypes SQL type code}
|
||||||
* for this column, or {@code null} if the type code is unknown.
|
* for this column, or {@code null} if the type code is unknown.
|
||||||
* <p>
|
* <p>
|
||||||
* Use {@link #getSqlTypeCode(Mapping)} to retrieve the type code
|
* Use {@link #getSqlTypeCode(MappingContext)} to retrieve the type code
|
||||||
* using {@link Value} associated with the column.
|
* using {@link Value} associated with the column.
|
||||||
*
|
*
|
||||||
* @return the type code, if it is set, otherwise null.
|
* @return the type code, if it is set, otherwise null.
|
||||||
|
@ -434,23 +443,31 @@ public class Column implements Selectable, Serializable, Cloneable, ColumnTypeIn
|
||||||
return scale == null ? 0 : scale;
|
return scale == null ? 0 : scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use {@link #getColumnSize(Dialect, MappingContext)}
|
||||||
|
*/
|
||||||
|
@Deprecated(since = "7.0")
|
||||||
public Size getColumnSize(Dialect dialect, Mapping mapping) {
|
public Size getColumnSize(Dialect dialect, Mapping mapping) {
|
||||||
|
return getColumnSize(dialect, (MappingContext) mapping);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Size getColumnSize(Dialect dialect, MappingContext mappingContext) {
|
||||||
if ( columnSize == null ) {
|
if ( columnSize == null ) {
|
||||||
columnSize = calculateColumnSize( dialect, mapping );
|
columnSize = calculateColumnSize( dialect, mappingContext );
|
||||||
}
|
}
|
||||||
return columnSize;
|
return columnSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
Size calculateColumnSize(Dialect dialect, Mapping mapping) {
|
Size calculateColumnSize(Dialect dialect, MappingContext mappingContext) {
|
||||||
Type type = getValue().getType();
|
Type type = getValue().getType();
|
||||||
Long lengthToUse = getLength();
|
Long lengthToUse = getLength();
|
||||||
Integer precisionToUse = getPrecision();
|
Integer precisionToUse = getPrecision();
|
||||||
Integer scaleToUse = getScale();
|
Integer scaleToUse = getScale();
|
||||||
if ( type instanceof EntityType ) {
|
if ( type instanceof EntityType ) {
|
||||||
type = getTypeForEntityValue( mapping, type, getTypeIndex() );
|
type = getTypeForEntityValue( mappingContext, type, getTypeIndex() );
|
||||||
}
|
}
|
||||||
if ( type instanceof ComponentType ) {
|
if ( type instanceof ComponentType ) {
|
||||||
type = getTypeForComponentValue( mapping, type, getTypeIndex() );
|
type = getTypeForComponentValue( mappingContext, type, getTypeIndex() );
|
||||||
}
|
}
|
||||||
if ( type instanceof BasicType<?> basicType ) {
|
if ( type instanceof BasicType<?> basicType ) {
|
||||||
if ( isTemporal( basicType.getExpressibleJavaType() ) ) {
|
if ( isTemporal( basicType.getExpressibleJavaType() ) ) {
|
||||||
|
@ -474,18 +491,18 @@ public class Column implements Selectable, Serializable, Cloneable, ColumnTypeIn
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Type getTypeForComponentValue(Mapping mapping, Type type, int typeIndex) {
|
private Type getTypeForComponentValue(MappingContext mappingContext, Type type, int typeIndex) {
|
||||||
final Type[] subtypes = ( (ComponentType) type ).getSubtypes();
|
final Type[] subtypes = ( (ComponentType) type ).getSubtypes();
|
||||||
int typeStartIndex = 0;
|
int typeStartIndex = 0;
|
||||||
for ( Type subtype : subtypes ) {
|
for ( Type subtype : subtypes ) {
|
||||||
final int columnSpan = subtype.getColumnSpan(mapping);
|
final int columnSpan = subtype.getColumnSpan(mappingContext);
|
||||||
if ( typeStartIndex + columnSpan > typeIndex ) {
|
if ( typeStartIndex + columnSpan > typeIndex ) {
|
||||||
final int subtypeIndex = typeIndex - typeStartIndex;
|
final int subtypeIndex = typeIndex - typeStartIndex;
|
||||||
if ( subtype instanceof EntityType ) {
|
if ( subtype instanceof EntityType ) {
|
||||||
return getTypeForEntityValue(mapping, subtype, subtypeIndex);
|
return getTypeForEntityValue(mappingContext, subtype, subtypeIndex);
|
||||||
}
|
}
|
||||||
if ( subtype instanceof ComponentType ) {
|
if ( subtype instanceof ComponentType ) {
|
||||||
return getTypeForComponentValue(mapping, subtype, subtypeIndex);
|
return getTypeForComponentValue(mappingContext, subtype, subtypeIndex);
|
||||||
}
|
}
|
||||||
if ( subtypeIndex == 0 ) {
|
if ( subtypeIndex == 0 ) {
|
||||||
return subtype;
|
return subtype;
|
||||||
|
@ -505,18 +522,18 @@ public class Column implements Selectable, Serializable, Cloneable, ColumnTypeIn
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Type getTypeForEntityValue(Mapping mapping, Type type, int typeIndex) {
|
private Type getTypeForEntityValue(MappingContext mappingContext, Type type, int typeIndex) {
|
||||||
int index = 0;
|
int index = 0;
|
||||||
if ( type instanceof EntityType entityType ) {
|
if ( type instanceof EntityType entityType ) {
|
||||||
return getTypeForEntityValue( mapping, entityType.getIdentifierOrUniqueKeyType( mapping ), typeIndex );
|
return getTypeForEntityValue( mappingContext, entityType.getIdentifierOrUniqueKeyType( mappingContext ), typeIndex );
|
||||||
}
|
}
|
||||||
else if ( type instanceof ComponentType componentType ) {
|
else if ( type instanceof ComponentType componentType ) {
|
||||||
for ( Type subtype : componentType.getSubtypes() ) {
|
for ( Type subtype : componentType.getSubtypes() ) {
|
||||||
final Type result = getTypeForEntityValue( mapping, subtype, typeIndex - index );
|
final Type result = getTypeForEntityValue( mappingContext, subtype, typeIndex - index );
|
||||||
if ( result != null ) {
|
if ( result != null ) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
index += subtype.getColumnSpan( mapping );
|
index += subtype.getColumnSpan( mappingContext );
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,6 @@ import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
|
||||||
import org.hibernate.boot.spi.BootstrapContext;
|
import org.hibernate.boot.spi.BootstrapContext;
|
||||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||||
import org.hibernate.dialect.Dialect;
|
import org.hibernate.dialect.Dialect;
|
||||||
import org.hibernate.engine.spi.Mapping;
|
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.generator.BeforeExecutionGenerator;
|
import org.hibernate.generator.BeforeExecutionGenerator;
|
||||||
import org.hibernate.generator.Generator;
|
import org.hibernate.generator.Generator;
|
||||||
|
@ -55,6 +54,7 @@ import org.hibernate.type.EmbeddedComponentType;
|
||||||
import org.hibernate.type.UserComponentType;
|
import org.hibernate.type.UserComponentType;
|
||||||
import org.hibernate.type.descriptor.java.JavaType;
|
import org.hibernate.type.descriptor.java.JavaType;
|
||||||
import org.hibernate.type.descriptor.java.spi.JavaTypeRegistry;
|
import org.hibernate.type.descriptor.java.spi.JavaTypeRegistry;
|
||||||
|
import org.hibernate.type.MappingContext;
|
||||||
import org.hibernate.usertype.CompositeUserType;
|
import org.hibernate.usertype.CompositeUserType;
|
||||||
|
|
||||||
import static java.util.Collections.unmodifiableList;
|
import static java.util.Collections.unmodifiableList;
|
||||||
|
@ -809,8 +809,8 @@ public class Component extends SimpleValue implements MetaAttributable, Sortable
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid(Mapping mapping) throws MappingException {
|
public boolean isValid(MappingContext mappingContext) throws MappingException {
|
||||||
if ( !super.isValid( mapping ) ) {
|
if ( !super.isValid( mappingContext ) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ( instantiatorPropertyNames != null ) {
|
if ( instantiatorPropertyNames != null ) {
|
||||||
|
|
|
@ -12,6 +12,7 @@ import org.hibernate.MappingException;
|
||||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||||
import org.hibernate.engine.spi.Mapping;
|
import org.hibernate.engine.spi.Mapping;
|
||||||
import org.hibernate.resource.beans.spi.ManagedBean;
|
import org.hibernate.resource.beans.spi.ManagedBean;
|
||||||
|
import org.hibernate.type.MappingContext;
|
||||||
import org.hibernate.usertype.UserCollectionType;
|
import org.hibernate.usertype.UserCollectionType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -68,11 +69,15 @@ public abstract class IdentifierCollection extends Collection {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void validate(Mapping mapping) throws MappingException {
|
public void validate(Mapping mapping) throws MappingException {
|
||||||
super.validate( mapping );
|
validate( (MappingContext) mapping);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void validate(MappingContext mappingContext) throws MappingException {
|
||||||
|
super.validate( mappingContext );
|
||||||
|
|
||||||
assert getElement() != null : "IdentifierCollection identifier not bound : " + getRole();
|
assert getElement() != null : "IdentifierCollection identifier not bound : " + getRole();
|
||||||
|
|
||||||
if ( !getIdentifier().isValid(mapping) ) {
|
if ( !getIdentifier().isValid( mappingContext ) ) {
|
||||||
throw new MappingException(
|
throw new MappingException(
|
||||||
"collection id mapping has wrong number of columns: " +
|
"collection id mapping has wrong number of columns: " +
|
||||||
getRole() +
|
getRole() +
|
||||||
|
|
|
@ -12,6 +12,7 @@ import org.hibernate.MappingException;
|
||||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||||
import org.hibernate.engine.spi.Mapping;
|
import org.hibernate.engine.spi.Mapping;
|
||||||
import org.hibernate.resource.beans.spi.ManagedBean;
|
import org.hibernate.resource.beans.spi.ManagedBean;
|
||||||
|
import org.hibernate.type.MappingContext;
|
||||||
import org.hibernate.usertype.UserCollectionType;
|
import org.hibernate.usertype.UserCollectionType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -92,11 +93,15 @@ public abstract class IndexedCollection extends Collection {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void validate(Mapping mapping) throws MappingException {
|
public void validate(Mapping mapping) throws MappingException {
|
||||||
super.validate( mapping );
|
validate( (MappingContext) mapping);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void validate(MappingContext mappingContext) throws MappingException {
|
||||||
|
super.validate( mappingContext );
|
||||||
|
|
||||||
assert getElement() != null : "IndexedCollection index not bound : " + getRole();
|
assert getElement() != null : "IndexedCollection index not bound : " + getRole();
|
||||||
|
|
||||||
if ( !getIndex().isValid(mapping) ) {
|
if ( !getIndex().isValid( mappingContext ) ) {
|
||||||
throw new MappingException(
|
throw new MappingException(
|
||||||
"collection index mapping has wrong number of columns: " +
|
"collection index mapping has wrong number of columns: " +
|
||||||
getRole() +
|
getRole() +
|
||||||
|
@ -106,6 +111,7 @@ public abstract class IndexedCollection extends Collection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isList() {
|
public boolean isList() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,11 +13,11 @@ import org.hibernate.FetchMode;
|
||||||
import org.hibernate.MappingException;
|
import org.hibernate.MappingException;
|
||||||
import org.hibernate.annotations.NotFoundAction;
|
import org.hibernate.annotations.NotFoundAction;
|
||||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||||
import org.hibernate.engine.spi.Mapping;
|
|
||||||
import org.hibernate.internal.util.collections.ArrayHelper;
|
import org.hibernate.internal.util.collections.ArrayHelper;
|
||||||
import org.hibernate.service.ServiceRegistry;
|
import org.hibernate.service.ServiceRegistry;
|
||||||
import org.hibernate.type.EntityType;
|
import org.hibernate.type.EntityType;
|
||||||
import org.hibernate.type.Type;
|
import org.hibernate.type.Type;
|
||||||
|
import org.hibernate.type.MappingContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A mapping model object representing a {@linkplain jakarta.persistence.OneToMany many-to-one association}.
|
* A mapping model object representing a {@linkplain jakarta.persistence.OneToMany many-to-one association}.
|
||||||
|
@ -103,10 +103,12 @@ public class OneToMany implements Value {
|
||||||
return associatedClass.getKey().getColumns();
|
return associatedClass.getKey().getColumns();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public int getColumnSpan() {
|
public int getColumnSpan() {
|
||||||
return associatedClass.getKey().getColumnSpan();
|
return associatedClass.getKey().getColumnSpan();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public FetchMode getFetchMode() {
|
public FetchMode getFetchMode() {
|
||||||
return FetchMode.JOIN;
|
return FetchMode.JOIN;
|
||||||
}
|
}
|
||||||
|
@ -114,31 +116,38 @@ public class OneToMany implements Value {
|
||||||
/**
|
/**
|
||||||
* Table of the owner entity (the "one" side)
|
* Table of the owner entity (the "one" side)
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public Table getTable() {
|
public Table getTable() {
|
||||||
return referencingTable;
|
return referencingTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Type getType() {
|
public Type getType() {
|
||||||
return getEntityType();
|
return getEntityType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isNullable() {
|
public boolean isNullable() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isSimpleValue() {
|
public boolean isSimpleValue() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isAlternateUniqueKey() {
|
public boolean isAlternateUniqueKey() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean hasFormula() {
|
public boolean hasFormula() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isValid(Mapping mapping) throws MappingException {
|
@Override
|
||||||
|
public boolean isValid(MappingContext mappingContext) throws MappingException {
|
||||||
if ( referencedEntityName == null ) {
|
if ( referencedEntityName == null ) {
|
||||||
throw new MappingException( "one to many association must specify the referenced entity" );
|
throw new MappingException( "one to many association must specify the referenced entity" );
|
||||||
}
|
}
|
||||||
|
@ -156,9 +165,11 @@ public class OneToMany implements Value {
|
||||||
this.referencedEntityName = referencedEntityName == null ? null : referencedEntityName.intern();
|
this.referencedEntityName = referencedEntityName == null ? null : referencedEntityName.intern();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setTypeUsingReflection(String className, String propertyName) {
|
public void setTypeUsingReflection(String className, String propertyName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object accept(ValueVisitor visitor) {
|
public Object accept(ValueVisitor visitor) {
|
||||||
return visitor.accept( this );
|
return visitor.accept( this );
|
||||||
}
|
}
|
||||||
|
@ -174,6 +185,7 @@ public class OneToMany implements Value {
|
||||||
&& Objects.equals( associatedClass, other.associatedClass );
|
&& Objects.equals( associatedClass, other.associatedClass );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean[] getColumnInsertability() {
|
public boolean[] getColumnInsertability() {
|
||||||
//TODO: we could just return all false...
|
//TODO: we could just return all false...
|
||||||
return ArrayHelper.EMPTY_BOOLEAN_ARRAY;
|
return ArrayHelper.EMPTY_BOOLEAN_ARRAY;
|
||||||
|
@ -184,6 +196,7 @@ public class OneToMany implements Value {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean[] getColumnUpdateability() {
|
public boolean[] getColumnUpdateability() {
|
||||||
//TODO: we could just return all false...
|
//TODO: we could just return all false...
|
||||||
return ArrayHelper.EMPTY_BOOLEAN_ARRAY;
|
return ArrayHelper.EMPTY_BOOLEAN_ARRAY;
|
||||||
|
|
|
@ -36,6 +36,7 @@ import org.hibernate.type.ComponentType;
|
||||||
import org.hibernate.type.CompositeType;
|
import org.hibernate.type.CompositeType;
|
||||||
import org.hibernate.type.Type;
|
import org.hibernate.type.Type;
|
||||||
import org.hibernate.type.WrapperArrayHandling;
|
import org.hibernate.type.WrapperArrayHandling;
|
||||||
|
import org.hibernate.type.MappingContext;
|
||||||
|
|
||||||
import static java.util.Collections.emptyList;
|
import static java.util.Collections.emptyList;
|
||||||
import static java.util.Collections.unmodifiableList;
|
import static java.util.Collections.unmodifiableList;
|
||||||
|
@ -278,7 +279,15 @@ public class Property implements Serializable, MetaAttributable {
|
||||||
this.metaAttributes = metas;
|
this.metaAttributes = metas;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use {@link #isValid(MappingContext)}
|
||||||
|
*/
|
||||||
|
@Deprecated(since = "7.0")
|
||||||
public boolean isValid(Mapping mapping) throws MappingException {
|
public boolean isValid(Mapping mapping) throws MappingException {
|
||||||
|
return isValid( (MappingContext) mapping);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isValid(MappingContext mappingContext) throws MappingException {
|
||||||
final Value value = getValue();
|
final Value value = getValue();
|
||||||
if ( value instanceof BasicValue && ( (BasicValue) value ).isDisallowedWrapperArray() ) {
|
if ( value instanceof BasicValue && ( (BasicValue) value ).isDisallowedWrapperArray() ) {
|
||||||
throw new MappingException(
|
throw new MappingException(
|
||||||
|
@ -295,7 +304,7 @@ public class Property implements Serializable, MetaAttributable {
|
||||||
"and the Javadoc of the org.hibernate.cfg.AvailableSettings.WRAPPER_ARRAY_HANDLING field."
|
"and the Javadoc of the org.hibernate.cfg.AvailableSettings.WRAPPER_ARRAY_HANDLING field."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return value.isValid( mapping );
|
return value.isValid( mappingContext );
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
|
@ -16,6 +16,7 @@ import org.hibernate.type.CollectionType;
|
||||||
import org.hibernate.type.OrderedSetType;
|
import org.hibernate.type.OrderedSetType;
|
||||||
import org.hibernate.type.SetType;
|
import org.hibernate.type.SetType;
|
||||||
import org.hibernate.type.SortedSetType;
|
import org.hibernate.type.SortedSetType;
|
||||||
|
import org.hibernate.type.MappingContext;
|
||||||
import org.hibernate.usertype.UserCollectionType;
|
import org.hibernate.usertype.UserCollectionType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,7 +51,11 @@ public class Set extends Collection {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void validate(Mapping mapping) throws MappingException {
|
public void validate(Mapping mapping) throws MappingException {
|
||||||
super.validate( mapping );
|
validate( (MappingContext) mapping );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void validate(MappingContext mappingContext) throws MappingException {
|
||||||
|
super.validate( mappingContext );
|
||||||
//for backward compatibility, disable this:
|
//for backward compatibility, disable this:
|
||||||
/*Iterator iter = getElement().getColumnIterator();
|
/*Iterator iter = getElement().getColumnIterator();
|
||||||
while ( iter.hasNext() ) {
|
while ( iter.hasNext() ) {
|
||||||
|
|
|
@ -34,7 +34,6 @@ import org.hibernate.boot.spi.InFlightMetadataCollector;
|
||||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||||
import org.hibernate.boot.spi.MetadataImplementor;
|
import org.hibernate.boot.spi.MetadataImplementor;
|
||||||
import org.hibernate.dialect.Dialect;
|
import org.hibernate.dialect.Dialect;
|
||||||
import org.hibernate.engine.spi.Mapping;
|
|
||||||
import org.hibernate.generator.Generator;
|
import org.hibernate.generator.Generator;
|
||||||
import org.hibernate.generator.GeneratorCreationContext;
|
import org.hibernate.generator.GeneratorCreationContext;
|
||||||
import org.hibernate.internal.CoreLogging;
|
import org.hibernate.internal.CoreLogging;
|
||||||
|
@ -54,6 +53,7 @@ import org.hibernate.type.descriptor.jdbc.LobTypeMappings;
|
||||||
import org.hibernate.type.descriptor.jdbc.NationalizedTypeMappings;
|
import org.hibernate.type.descriptor.jdbc.NationalizedTypeMappings;
|
||||||
import org.hibernate.type.internal.ConvertedBasicTypeImpl;
|
import org.hibernate.type.internal.ConvertedBasicTypeImpl;
|
||||||
import org.hibernate.type.internal.ParameterizedTypeImpl;
|
import org.hibernate.type.internal.ParameterizedTypeImpl;
|
||||||
|
import org.hibernate.type.MappingContext;
|
||||||
import org.hibernate.type.spi.TypeConfiguration;
|
import org.hibernate.type.spi.TypeConfiguration;
|
||||||
import org.hibernate.usertype.DynamicParameterizedType;
|
import org.hibernate.usertype.DynamicParameterizedType;
|
||||||
|
|
||||||
|
@ -156,6 +156,7 @@ public abstract class SimpleValue implements KeyValue {
|
||||||
return getMetadata().getMetadataBuildingOptions().getServiceRegistry();
|
return getMetadata().getMetadataBuildingOptions().getServiceRegistry();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public TypeConfiguration getTypeConfiguration() {
|
public TypeConfiguration getTypeConfiguration() {
|
||||||
return getBuildingContext().getBootstrapContext().getTypeConfiguration();
|
return getBuildingContext().getBootstrapContext().getTypeConfiguration();
|
||||||
}
|
}
|
||||||
|
@ -400,19 +401,23 @@ public abstract class SimpleValue implements KeyValue {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isUpdateable() {
|
public boolean isUpdateable() {
|
||||||
//needed to satisfy KeyValue
|
//needed to satisfy KeyValue
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public FetchMode getFetchMode() {
|
public FetchMode getFetchMode() {
|
||||||
return FetchMode.SELECT;
|
return FetchMode.SELECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Table getTable() {
|
public Table getTable() {
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getNullValue() {
|
public String getNullValue() {
|
||||||
return nullValue;
|
return nullValue;
|
||||||
}
|
}
|
||||||
|
@ -461,6 +466,7 @@ public abstract class SimpleValue implements KeyValue {
|
||||||
this.foreignKeyDefinition = foreignKeyDefinition;
|
this.foreignKeyDefinition = foreignKeyDefinition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isAlternateUniqueKey() {
|
public boolean isAlternateUniqueKey() {
|
||||||
return alternateUniqueKey;
|
return alternateUniqueKey;
|
||||||
}
|
}
|
||||||
|
@ -469,6 +475,7 @@ public abstract class SimpleValue implements KeyValue {
|
||||||
this.alternateUniqueKey = unique;
|
this.alternateUniqueKey = unique;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isNullable() {
|
public boolean isNullable() {
|
||||||
for ( Selectable selectable : getSelectables() ) {
|
for ( Selectable selectable : getSelectables() ) {
|
||||||
if ( selectable instanceof Formula ) {
|
if ( selectable instanceof Formula ) {
|
||||||
|
@ -486,12 +493,14 @@ public abstract class SimpleValue implements KeyValue {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isSimpleValue() {
|
public boolean isSimpleValue() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isValid(Mapping mapping) throws MappingException {
|
@Override
|
||||||
return getColumnSpan() == getType().getColumnSpan( mapping );
|
public boolean isValid(MappingContext mappingContext) throws MappingException {
|
||||||
|
return getColumnSpan() == getType().getColumnSpan( mappingContext );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setAttributeConverterDescriptor(ConverterDescriptor descriptor) {
|
protected void setAttributeConverterDescriptor(ConverterDescriptor descriptor) {
|
||||||
|
|
|
@ -12,9 +12,9 @@ import org.hibernate.boot.model.internal.AnnotatedJoinColumn;
|
||||||
import org.hibernate.boot.model.internal.AnnotatedJoinColumns;
|
import org.hibernate.boot.model.internal.AnnotatedJoinColumns;
|
||||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||||
import org.hibernate.engine.spi.Mapping;
|
|
||||||
import org.hibernate.internal.util.ReflectHelper;
|
import org.hibernate.internal.util.ReflectHelper;
|
||||||
import org.hibernate.type.EntityType;
|
import org.hibernate.type.EntityType;
|
||||||
|
import org.hibernate.type.MappingContext;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@ -53,10 +53,12 @@ public abstract class ToOne extends SimpleValue implements Fetchable, SortableVa
|
||||||
this.referenceToPrimaryKey = original.referenceToPrimaryKey;
|
this.referenceToPrimaryKey = original.referenceToPrimaryKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public FetchMode getFetchMode() {
|
public FetchMode getFetchMode() {
|
||||||
return fetchMode;
|
return fetchMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setFetchMode(FetchMode fetchMode) {
|
public void setFetchMode(FetchMode fetchMode) {
|
||||||
this.fetchMode=fetchMode;
|
this.fetchMode=fetchMode;
|
||||||
}
|
}
|
||||||
|
@ -97,10 +99,12 @@ public abstract class ToOne extends SimpleValue implements Fetchable, SortableVa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isTypeSpecified() {
|
public boolean isTypeSpecified() {
|
||||||
return referencedEntityName!=null;
|
return referencedEntityName!=null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Object accept(ValueVisitor visitor) {
|
public Object accept(ValueVisitor visitor) {
|
||||||
return visitor.accept(this);
|
return visitor.accept(this);
|
||||||
}
|
}
|
||||||
|
@ -116,17 +120,20 @@ public abstract class ToOne extends SimpleValue implements Fetchable, SortableVa
|
||||||
&& Objects.equals( referencedEntityName, other.referencedEntityName );
|
&& Objects.equals( referencedEntityName, other.referencedEntityName );
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isValid(Mapping mapping) throws MappingException {
|
@Override
|
||||||
|
public boolean isValid(MappingContext mappingContext) throws MappingException {
|
||||||
if (referencedEntityName==null) {
|
if (referencedEntityName==null) {
|
||||||
throw new MappingException("association must specify the referenced entity");
|
throw new MappingException("association must specify the referenced entity");
|
||||||
}
|
}
|
||||||
return super.isValid( mapping );
|
return super.isValid( mappingContext );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isLazy() {
|
public boolean isLazy() {
|
||||||
return lazy;
|
return lazy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void setLazy(boolean lazy) {
|
public void setLazy(boolean lazy) {
|
||||||
this.lazy = lazy;
|
this.lazy = lazy;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ import org.hibernate.type.CompositeType;
|
||||||
import org.hibernate.type.EntityType;
|
import org.hibernate.type.EntityType;
|
||||||
import org.hibernate.type.MetaType;
|
import org.hibernate.type.MetaType;
|
||||||
import org.hibernate.type.Type;
|
import org.hibernate.type.Type;
|
||||||
|
import org.hibernate.type.MappingContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A mapping model object which represents something that's persisted "by value",
|
* A mapping model object which represents something that's persisted "by value",
|
||||||
|
@ -73,12 +74,21 @@ public interface Value extends Serializable {
|
||||||
|
|
||||||
Type getType() throws MappingException;
|
Type getType() throws MappingException;
|
||||||
|
|
||||||
@Incubating
|
|
||||||
|
/**
|
||||||
|
* @deprecated use {@link #getSelectableType(MappingContext, int)}
|
||||||
|
*/
|
||||||
|
@Deprecated(since = "7.0")
|
||||||
default JdbcMapping getSelectableType(Mapping factory, int index) throws MappingException {
|
default JdbcMapping getSelectableType(Mapping factory, int index) throws MappingException {
|
||||||
return getType( factory, getType(), index );
|
return getSelectableType( (MappingContext) factory, index );
|
||||||
}
|
}
|
||||||
|
|
||||||
private JdbcMapping getType(Mapping factory, Type elementType, int index) {
|
@Incubating
|
||||||
|
default JdbcMapping getSelectableType(MappingContext mappingContext, int index) throws MappingException {
|
||||||
|
return getType( mappingContext, getType(), index );
|
||||||
|
}
|
||||||
|
|
||||||
|
private JdbcMapping getType(MappingContext factory, Type elementType, int index) {
|
||||||
if ( elementType instanceof CompositeType ) {
|
if ( elementType instanceof CompositeType ) {
|
||||||
final Type[] subtypes = ( (CompositeType) elementType ).getSubtypes();
|
final Type[] subtypes = ( (CompositeType) elementType ).getSubtypes();
|
||||||
for ( int i = 0; i < subtypes.length; i++ ) {
|
for ( int i = 0; i < subtypes.length; i++ ) {
|
||||||
|
@ -145,7 +155,15 @@ public interface Value extends Serializable {
|
||||||
|
|
||||||
boolean isSimpleValue();
|
boolean isSimpleValue();
|
||||||
|
|
||||||
boolean isValid(Mapping mapping) throws MappingException;
|
/**
|
||||||
|
* @deprecated use {@link #isValid(MappingContext)}
|
||||||
|
*/
|
||||||
|
@Deprecated(since = "7.0")
|
||||||
|
default boolean isValid(Mapping mapping) throws MappingException{
|
||||||
|
return isValid( (MappingContext) mapping );
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean isValid(MappingContext mappingContext) throws MappingException;
|
||||||
|
|
||||||
void setTypeUsingReflection(String className, String propertyName) throws MappingException;
|
void setTypeUsingReflection(String className, String propertyName) throws MappingException;
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ import org.hibernate.query.sqm.function.SqmFunctionRegistry;
|
||||||
import org.hibernate.type.CompositeType;
|
import org.hibernate.type.CompositeType;
|
||||||
import org.hibernate.type.EntityType;
|
import org.hibernate.type.EntityType;
|
||||||
import org.hibernate.type.Type;
|
import org.hibernate.type.Type;
|
||||||
|
import org.hibernate.type.MappingContext;
|
||||||
import org.hibernate.type.spi.TypeConfiguration;
|
import org.hibernate.type.spi.TypeConfiguration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,7 +38,7 @@ public class SelectableMappingsImpl implements SelectableMappings {
|
||||||
this.selectableMappings = selectableMappings;
|
this.selectableMappings = selectableMappings;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void resolveJdbcMappings(List<JdbcMapping> jdbcMappings, Mapping mapping, Type valueType) {
|
private static void resolveJdbcMappings(List<JdbcMapping> jdbcMappings, MappingContext mapping, Type valueType) {
|
||||||
final Type keyType;
|
final Type keyType;
|
||||||
if ( valueType instanceof EntityType ) {
|
if ( valueType instanceof EntityType ) {
|
||||||
keyType = ( (EntityType) valueType ).getIdentifierOrUniqueKeyType( mapping );
|
keyType = ( (EntityType) valueType ).getIdentifierOrUniqueKeyType( mapping );
|
||||||
|
@ -56,6 +57,10 @@ public class SelectableMappingsImpl implements SelectableMappings {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use {@link #from(String, Value, int[], MappingContext, TypeConfiguration, boolean[], boolean[], Dialect, SqmFunctionRegistry, RuntimeModelCreationContext)}
|
||||||
|
*/
|
||||||
|
@Deprecated(since = "7.0")
|
||||||
public static SelectableMappings from(
|
public static SelectableMappings from(
|
||||||
String containingTableExpression,
|
String containingTableExpression,
|
||||||
Value value,
|
Value value,
|
||||||
|
@ -67,12 +72,36 @@ public class SelectableMappingsImpl implements SelectableMappings {
|
||||||
Dialect dialect,
|
Dialect dialect,
|
||||||
SqmFunctionRegistry sqmFunctionRegistry,
|
SqmFunctionRegistry sqmFunctionRegistry,
|
||||||
RuntimeModelCreationContext creationContext) {
|
RuntimeModelCreationContext creationContext) {
|
||||||
|
return from(
|
||||||
|
containingTableExpression,
|
||||||
|
value, propertyOrder,
|
||||||
|
(MappingContext) mapping,
|
||||||
|
typeConfiguration,
|
||||||
|
insertable,
|
||||||
|
updateable,
|
||||||
|
dialect,
|
||||||
|
sqmFunctionRegistry,
|
||||||
|
creationContext
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SelectableMappings from(
|
||||||
|
String containingTableExpression,
|
||||||
|
Value value,
|
||||||
|
int[] propertyOrder,
|
||||||
|
MappingContext mappingContext,
|
||||||
|
TypeConfiguration typeConfiguration,
|
||||||
|
boolean[] insertable,
|
||||||
|
boolean[] updateable,
|
||||||
|
Dialect dialect,
|
||||||
|
SqmFunctionRegistry sqmFunctionRegistry,
|
||||||
|
RuntimeModelCreationContext creationContext) {
|
||||||
if ( insertable.length == 0 ) {
|
if ( insertable.length == 0 ) {
|
||||||
return from(
|
return from(
|
||||||
containingTableExpression,
|
containingTableExpression,
|
||||||
value,
|
value,
|
||||||
propertyOrder,
|
propertyOrder,
|
||||||
mapping,
|
mappingContext,
|
||||||
typeConfiguration,
|
typeConfiguration,
|
||||||
dialect,
|
dialect,
|
||||||
sqmFunctionRegistry,
|
sqmFunctionRegistry,
|
||||||
|
@ -80,7 +109,7 @@ public class SelectableMappingsImpl implements SelectableMappings {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
final List<JdbcMapping> jdbcMappings = new ArrayList<>();
|
final List<JdbcMapping> jdbcMappings = new ArrayList<>();
|
||||||
resolveJdbcMappings( jdbcMappings, mapping, value.getType() );
|
resolveJdbcMappings( jdbcMappings, mappingContext, value.getType() );
|
||||||
|
|
||||||
final List<Selectable> selectables = value.getVirtualSelectables();
|
final List<Selectable> selectables = value.getVirtualSelectables();
|
||||||
|
|
||||||
|
@ -107,7 +136,7 @@ public class SelectableMappingsImpl implements SelectableMappings {
|
||||||
String containingTableExpression,
|
String containingTableExpression,
|
||||||
Value value,
|
Value value,
|
||||||
int[] propertyOrder,
|
int[] propertyOrder,
|
||||||
Mapping mapping,
|
MappingContext mapping,
|
||||||
TypeConfiguration typeConfiguration,
|
TypeConfiguration typeConfiguration,
|
||||||
Dialect dialect,
|
Dialect dialect,
|
||||||
SqmFunctionRegistry sqmFunctionRegistry,
|
SqmFunctionRegistry sqmFunctionRegistry,
|
||||||
|
|
|
@ -16,7 +16,6 @@ import org.hibernate.HibernateException;
|
||||||
import org.hibernate.Internal;
|
import org.hibernate.Internal;
|
||||||
import org.hibernate.MappingException;
|
import org.hibernate.MappingException;
|
||||||
import org.hibernate.cache.MutableCacheKeyBuilder;
|
import org.hibernate.cache.MutableCacheKeyBuilder;
|
||||||
import org.hibernate.engine.spi.Mapping;
|
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.internal.util.collections.ArrayHelper;
|
import org.hibernate.internal.util.collections.ArrayHelper;
|
||||||
|
@ -33,6 +32,7 @@ import org.hibernate.type.descriptor.java.JavaType;
|
||||||
import org.hibernate.type.descriptor.java.StringJavaType;
|
import org.hibernate.type.descriptor.java.StringJavaType;
|
||||||
import org.hibernate.type.descriptor.jdbc.JdbcLiteralFormatter;
|
import org.hibernate.type.descriptor.jdbc.JdbcLiteralFormatter;
|
||||||
import org.hibernate.type.descriptor.jdbc.JdbcType;
|
import org.hibernate.type.descriptor.jdbc.JdbcType;
|
||||||
|
import org.hibernate.type.MappingContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated The functionality of DiscriminatorType, {@link DiscriminatorMetadata} and {@link MetaType} have been
|
* @deprecated The functionality of DiscriminatorType, {@link DiscriminatorMetadata} and {@link MetaType} have been
|
||||||
|
@ -145,7 +145,7 @@ public class DiscriminatorType<T> extends AbstractType implements BasicType<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean[] toColumnNullness(Object value, Mapping mapping) {
|
public boolean[] toColumnNullness(Object value, MappingContext mapping) {
|
||||||
return value == null
|
return value == null
|
||||||
? ArrayHelper.FALSE
|
? ArrayHelper.FALSE
|
||||||
: ArrayHelper.TRUE;
|
: ArrayHelper.TRUE;
|
||||||
|
@ -171,12 +171,12 @@ public class DiscriminatorType<T> extends AbstractType implements BasicType<T> {
|
||||||
// simple delegation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// simple delegation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int[] getSqlTypeCodes(Mapping mapping) throws MappingException {
|
public int[] getSqlTypeCodes(MappingContext mappingContext) throws MappingException {
|
||||||
return underlyingType.getSqlTypeCodes( mapping );
|
return underlyingType.getSqlTypeCodes( mappingContext );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getColumnSpan(Mapping mapping) throws MappingException {
|
public int getColumnSpan(MappingContext mapping) throws MappingException {
|
||||||
return underlyingType.getColumnSpan( mapping );
|
return underlyingType.getColumnSpan( mapping );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,6 @@ import org.hibernate.QueryException;
|
||||||
import org.hibernate.Remove;
|
import org.hibernate.Remove;
|
||||||
import org.hibernate.boot.Metadata;
|
import org.hibernate.boot.Metadata;
|
||||||
import org.hibernate.boot.spi.MetadataImplementor;
|
import org.hibernate.boot.spi.MetadataImplementor;
|
||||||
import org.hibernate.engine.spi.Mapping;
|
|
||||||
import org.hibernate.internal.CoreLogging;
|
import org.hibernate.internal.CoreLogging;
|
||||||
import org.hibernate.internal.CoreMessageLogger;
|
import org.hibernate.internal.CoreMessageLogger;
|
||||||
import org.hibernate.internal.util.StringHelper;
|
import org.hibernate.internal.util.StringHelper;
|
||||||
|
@ -33,6 +32,7 @@ import org.hibernate.type.ManyToOneType;
|
||||||
import org.hibernate.type.OneToOneType;
|
import org.hibernate.type.OneToOneType;
|
||||||
import org.hibernate.type.SpecialOneToOneType;
|
import org.hibernate.type.SpecialOneToOneType;
|
||||||
import org.hibernate.type.Type;
|
import org.hibernate.type.Type;
|
||||||
|
import org.hibernate.type.MappingContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Gavin King
|
* @author Gavin King
|
||||||
|
@ -352,7 +352,7 @@ class EntityPropertyMapping {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean hasNonIdentifierPropertyNamedId(final EntityType entityType, final Mapping factory) {
|
private boolean hasNonIdentifierPropertyNamedId(final EntityType entityType, final MappingContext factory) {
|
||||||
// TODO : would be great to have a Mapping#hasNonIdentifierPropertyNamedId method
|
// TODO : would be great to have a Mapping#hasNonIdentifierPropertyNamedId method
|
||||||
// I don't believe that Mapping#getReferencedPropertyType accounts for the identifier property; so
|
// I don't believe that Mapping#getReferencedPropertyType accounts for the identifier property; so
|
||||||
// if it returns for a property named 'id', then we should have a non-id field named id
|
// if it returns for a property named 'id', then we should have a non-id field named id
|
||||||
|
|
|
@ -19,7 +19,6 @@ import org.hibernate.Hibernate;
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.MappingException;
|
import org.hibernate.MappingException;
|
||||||
import org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer;
|
import org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer;
|
||||||
import org.hibernate.engine.spi.Mapping;
|
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.internal.util.collections.ArrayHelper;
|
import org.hibernate.internal.util.collections.ArrayHelper;
|
||||||
|
@ -101,7 +100,7 @@ public abstract class AbstractStandardBasicType<T>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean[] toColumnNullness(Object value, Mapping mapping) {
|
public boolean[] toColumnNullness(Object value, MappingContext mapping) {
|
||||||
return value == null ? ArrayHelper.FALSE : ArrayHelper.TRUE;
|
return value == null ? ArrayHelper.FALSE : ArrayHelper.TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,12 +131,12 @@ public abstract class AbstractStandardBasicType<T>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final int getColumnSpan(Mapping mapping) throws MappingException {
|
public final int getColumnSpan(MappingContext mapping) throws MappingException {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final int[] getSqlTypeCodes(Mapping mapping) throws MappingException {
|
public final int[] getSqlTypeCodes(MappingContext mappingContext) throws MappingException {
|
||||||
return sqlTypes;
|
return sqlTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,6 @@ import org.hibernate.TransientObjectException;
|
||||||
import org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer;
|
import org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer;
|
||||||
import org.hibernate.engine.spi.CascadeStyle;
|
import org.hibernate.engine.spi.CascadeStyle;
|
||||||
import org.hibernate.engine.spi.CascadeStyles;
|
import org.hibernate.engine.spi.CascadeStyles;
|
||||||
import org.hibernate.engine.spi.Mapping;
|
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
|
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
|
||||||
|
@ -78,8 +77,8 @@ public class AnyType extends AbstractType implements CompositeType, AssociationT
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int[] getSqlTypeCodes(Mapping mapping) throws MappingException {
|
public int[] getSqlTypeCodes(MappingContext mappingContext) throws MappingException {
|
||||||
return join( discriminatorType.getSqlTypeCodes( mapping ), identifierType.getSqlTypeCodes( mapping ) );
|
return join( discriminatorType.getSqlTypeCodes( mappingContext ), identifierType.getSqlTypeCodes( mappingContext ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -210,7 +209,7 @@ public class AnyType extends AbstractType implements CompositeType, AssociationT
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean[] toColumnNullness(Object value, Mapping mapping) {
|
public boolean[] toColumnNullness(Object value, MappingContext mapping) {
|
||||||
final boolean[] result = new boolean[ getColumnSpan( mapping ) ];
|
final boolean[] result = new boolean[ getColumnSpan( mapping ) ];
|
||||||
if ( value != null ) {
|
if ( value != null ) {
|
||||||
Arrays.fill( result, true );
|
Arrays.fill( result, true );
|
||||||
|
@ -225,7 +224,7 @@ public class AnyType extends AbstractType implements CompositeType, AssociationT
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getColumnSpan(Mapping session) {
|
public int getColumnSpan(MappingContext session) {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,6 @@ import org.hibernate.collection.spi.PersistentCollection;
|
||||||
import org.hibernate.engine.spi.CollectionEntry;
|
import org.hibernate.engine.spi.CollectionEntry;
|
||||||
import org.hibernate.engine.spi.CollectionKey;
|
import org.hibernate.engine.spi.CollectionKey;
|
||||||
import org.hibernate.engine.spi.EntityEntry;
|
import org.hibernate.engine.spi.EntityEntry;
|
||||||
import org.hibernate.engine.spi.Mapping;
|
|
||||||
import org.hibernate.engine.spi.PersistenceContext;
|
import org.hibernate.engine.spi.PersistenceContext;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
|
@ -162,12 +161,12 @@ public abstract class CollectionType extends AbstractType implements Association
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int[] getSqlTypeCodes(Mapping session) throws MappingException {
|
public int[] getSqlTypeCodes(MappingContext mappingContext) throws MappingException {
|
||||||
return ArrayHelper.EMPTY_INT_ARRAY;
|
return ArrayHelper.EMPTY_INT_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getColumnSpan(Mapping session) throws MappingException {
|
public int getColumnSpan(MappingContext session) throws MappingException {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -800,7 +799,7 @@ public abstract class CollectionType extends AbstractType implements Association
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean[] toColumnNullness(Object value, Mapping mapping) {
|
public boolean[] toColumnNullness(Object value, MappingContext mapping) {
|
||||||
return ArrayHelper.EMPTY_BOOLEAN_ARRAY;
|
return ArrayHelper.EMPTY_BOOLEAN_ARRAY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@ import org.hibernate.PropertyNotFoundException;
|
||||||
import org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer;
|
import org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer;
|
||||||
import org.hibernate.engine.spi.CascadeStyle;
|
import org.hibernate.engine.spi.CascadeStyle;
|
||||||
import org.hibernate.engine.spi.CascadeStyles;
|
import org.hibernate.engine.spi.CascadeStyles;
|
||||||
import org.hibernate.engine.spi.Mapping;
|
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.internal.util.StringHelper;
|
import org.hibernate.internal.util.StringHelper;
|
||||||
|
@ -128,7 +127,7 @@ public class ComponentType extends AbstractType implements CompositeTypeImplemen
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getColumnSpan(Mapping mapping) throws MappingException {
|
public int getColumnSpan(MappingContext mapping) throws MappingException {
|
||||||
int span = 0;
|
int span = 0;
|
||||||
for ( int i = 0; i < propertySpan; i++ ) {
|
for ( int i = 0; i < propertySpan; i++ ) {
|
||||||
span += propertyTypes[i].getColumnSpan( mapping );
|
span += propertyTypes[i].getColumnSpan( mapping );
|
||||||
|
@ -138,12 +137,12 @@ public class ComponentType extends AbstractType implements CompositeTypeImplemen
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int[] getSqlTypeCodes(Mapping mapping) throws MappingException {
|
public int[] getSqlTypeCodes(MappingContext mappingContext) throws MappingException {
|
||||||
//Not called at runtime so doesn't matter if it's slow :)
|
//Not called at runtime so doesn't matter if it's slow :)
|
||||||
final int[] sqlTypes = new int[getColumnSpan( mapping )];
|
final int[] sqlTypes = new int[getColumnSpan( mappingContext )];
|
||||||
int n = 0;
|
int n = 0;
|
||||||
for ( int i = 0; i < propertySpan; i++ ) {
|
for ( int i = 0; i < propertySpan; i++ ) {
|
||||||
int[] subtypes = propertyTypes[i].getSqlTypeCodes( mapping );
|
int[] subtypes = propertyTypes[i].getSqlTypeCodes( mappingContext );
|
||||||
for ( int subtype : subtypes ) {
|
for ( int subtype : subtypes ) {
|
||||||
sqlTypes[n++] = subtype;
|
sqlTypes[n++] = subtype;
|
||||||
}
|
}
|
||||||
|
@ -674,7 +673,7 @@ public class ComponentType extends AbstractType implements CompositeTypeImplemen
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean[] toColumnNullness(Object value, Mapping mapping) {
|
public boolean[] toColumnNullness(Object value, MappingContext mapping) {
|
||||||
final boolean[] result = new boolean[getColumnSpan( mapping )];
|
final boolean[] result = new boolean[getColumnSpan( mapping )];
|
||||||
if ( value != null ) {
|
if ( value != null ) {
|
||||||
final Object[] values = getPropertyValues( value ); //TODO!!!!!!!
|
final Object[] values = getPropertyValues( value ); //TODO!!!!!!!
|
||||||
|
|
|
@ -17,7 +17,6 @@ import org.hibernate.HibernateException;
|
||||||
import org.hibernate.MappingException;
|
import org.hibernate.MappingException;
|
||||||
import org.hibernate.cache.MutableCacheKeyBuilder;
|
import org.hibernate.cache.MutableCacheKeyBuilder;
|
||||||
import org.hibernate.engine.internal.CacheHelper;
|
import org.hibernate.engine.internal.CacheHelper;
|
||||||
import org.hibernate.engine.spi.Mapping;
|
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.internal.util.collections.ArrayHelper;
|
import org.hibernate.internal.util.collections.ArrayHelper;
|
||||||
|
@ -142,7 +141,7 @@ public class CustomType<J>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int[] getSqlTypeCodes(Mapping pi) {
|
public int[] getSqlTypeCodes(MappingContext mappingContext) {
|
||||||
return new int[] { jdbcType.getDdlTypeCode() };
|
return new int[] { jdbcType.getDdlTypeCode() };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +151,7 @@ public class CustomType<J>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getColumnSpan(Mapping session) {
|
public int getColumnSpan(MappingContext session) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,7 +316,7 @@ public class CustomType<J>
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean[] toColumnNullness(Object value, Mapping mapping) {
|
public boolean[] toColumnNullness(Object value, MappingContext mapping) {
|
||||||
boolean[] result = new boolean[ getColumnSpan(mapping) ];
|
boolean[] result = new boolean[ getColumnSpan(mapping) ];
|
||||||
if ( value != null ) {
|
if ( value != null ) {
|
||||||
Arrays.fill(result, true);
|
Arrays.fill(result, true);
|
||||||
|
|
|
@ -595,14 +595,20 @@ public abstract class EntityType extends AbstractType implements AssociationType
|
||||||
* @param factory The mappings...
|
* @param factory The mappings...
|
||||||
*
|
*
|
||||||
* @return The identifier type
|
* @return The identifier type
|
||||||
|
* @deprecated use {@link #getIdentifierType(MappingContext)}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated(since = "7.0")
|
||||||
Type getIdentifierType(final Mapping factory) {
|
Type getIdentifierType(final Mapping factory) {
|
||||||
|
return getIdentifierType( (MappingContext) factory );
|
||||||
|
}
|
||||||
|
|
||||||
|
Type getIdentifierType(final MappingContext mappingContext) {
|
||||||
final Type type = associatedIdentifierType;
|
final Type type = associatedIdentifierType;
|
||||||
//The following branch implements a simple lazy-initialization, but rather than the canonical
|
//The following branch implements a simple lazy-initialization, but rather than the canonical
|
||||||
//form it returns the local variable to avoid a second volatile read: associatedIdentifierType
|
//form it returns the local variable to avoid a second volatile read: associatedIdentifierType
|
||||||
//needs to be volatile as the initialization might happen by a different thread than the readers.
|
//needs to be volatile as the initialization might happen by a different thread than the readers.
|
||||||
if ( type == null ) {
|
if ( type == null ) {
|
||||||
associatedIdentifierType = factory.getIdentifierType( getAssociatedEntityName() );
|
associatedIdentifierType = mappingContext.getIdentifierType( getAssociatedEntityName() );
|
||||||
return associatedIdentifierType;
|
return associatedIdentifierType;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -639,15 +645,33 @@ public abstract class EntityType extends AbstractType implements AssociationType
|
||||||
*
|
*
|
||||||
* @throws MappingException Generally, if unable to resolve the associated entity name
|
* @throws MappingException Generally, if unable to resolve the associated entity name
|
||||||
* or unique key property name.
|
* or unique key property name.
|
||||||
|
* @deprecated use {@link #getIdentifierOrUniqueKeyType(MappingContext)}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated(since = "7.0")
|
||||||
public final Type getIdentifierOrUniqueKeyType(Mapping factory) throws MappingException {
|
public final Type getIdentifierOrUniqueKeyType(Mapping factory) throws MappingException {
|
||||||
|
return getIdentifierOrUniqueKeyType( (MappingContext) factory );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine the type of either (1) the identifier if we reference the
|
||||||
|
* associated entity's PK or (2) the unique key to which we refer (i.e.
|
||||||
|
* the property-ref).
|
||||||
|
*
|
||||||
|
* @param mappingContext The mappings context {@see MappingContext}
|
||||||
|
*
|
||||||
|
* @return The appropriate type.
|
||||||
|
*
|
||||||
|
* @throws MappingException Generally, if unable to resolve the associated entity name
|
||||||
|
* or unique key property name.
|
||||||
|
*/
|
||||||
|
public final Type getIdentifierOrUniqueKeyType(MappingContext mappingContext) throws MappingException {
|
||||||
if ( isReferenceToIdentifierProperty() ) {
|
if ( isReferenceToIdentifierProperty() ) {
|
||||||
return getIdentifierType( factory );
|
return getIdentifierType( mappingContext );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
final Type type = factory.getReferencedPropertyType( getAssociatedEntityName(), uniqueKeyPropertyName );
|
final Type type = mappingContext.getReferencedPropertyType( getAssociatedEntityName(), uniqueKeyPropertyName );
|
||||||
if ( type instanceof EntityType ) {
|
if ( type instanceof EntityType ) {
|
||||||
return ( (EntityType) type ).getIdentifierOrUniqueKeyType( factory );
|
return ( (EntityType) type ).getIdentifierOrUniqueKeyType( mappingContext );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return type;
|
return type;
|
||||||
|
@ -667,8 +691,23 @@ public abstract class EntityType extends AbstractType implements AssociationType
|
||||||
*/
|
*/
|
||||||
public final String getIdentifierOrUniqueKeyPropertyName(Mapping factory)
|
public final String getIdentifierOrUniqueKeyPropertyName(Mapping factory)
|
||||||
throws MappingException {
|
throws MappingException {
|
||||||
|
return getIdentifierOrUniqueKeyPropertyName( (MappingContext) factory);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the property on the associated entity to which our FK
|
||||||
|
* refers
|
||||||
|
*
|
||||||
|
* @param mappingContext The mappings...
|
||||||
|
*
|
||||||
|
* @return The appropriate property name.
|
||||||
|
*
|
||||||
|
* @throws MappingException Generally, if unable to resolve the associated entity name
|
||||||
|
*/
|
||||||
|
public final String getIdentifierOrUniqueKeyPropertyName(MappingContext mappingContext)
|
||||||
|
throws MappingException {
|
||||||
return isReferenceToIdentifierProperty()
|
return isReferenceToIdentifierProperty()
|
||||||
? factory.getIdentifierPropertyName( getAssociatedEntityName() )
|
? mappingContext.getIdentifierPropertyName( getAssociatedEntityName() )
|
||||||
: uniqueKeyPropertyName;
|
: uniqueKeyPropertyName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -766,7 +805,7 @@ public abstract class EntityType extends AbstractType implements AssociationType
|
||||||
return result == null ? null : persistenceContext.proxyFor( result );
|
return result == null ? null : persistenceContext.proxyFor( result );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Type requireIdentifierOrUniqueKeyType(Mapping mapping) {
|
protected Type requireIdentifierOrUniqueKeyType(MappingContext mapping) {
|
||||||
final Type fkTargetType = getIdentifierOrUniqueKeyType( mapping );
|
final Type fkTargetType = getIdentifierOrUniqueKeyType( mapping );
|
||||||
if ( fkTargetType == null ) {
|
if ( fkTargetType == null ) {
|
||||||
throw new MappingException(
|
throw new MappingException(
|
||||||
|
|
|
@ -13,7 +13,10 @@ import org.hibernate.AssertionFailure;
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.MappingException;
|
import org.hibernate.MappingException;
|
||||||
import org.hibernate.engine.internal.ForeignKeys;
|
import org.hibernate.engine.internal.ForeignKeys;
|
||||||
import org.hibernate.engine.spi.*;
|
import org.hibernate.engine.spi.EntityKey;
|
||||||
|
import org.hibernate.engine.spi.PersistenceContext;
|
||||||
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
import org.hibernate.type.spi.TypeConfiguration;
|
import org.hibernate.type.spi.TypeConfiguration;
|
||||||
|
|
||||||
|
@ -99,13 +102,13 @@ public class ManyToOneType extends EntityType {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getColumnSpan(Mapping mapping) throws MappingException {
|
public int getColumnSpan(MappingContext mapping) throws MappingException {
|
||||||
return requireIdentifierOrUniqueKeyType( mapping ).getColumnSpan( mapping );
|
return requireIdentifierOrUniqueKeyType( mapping ).getColumnSpan( mapping );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int[] getSqlTypeCodes(Mapping mapping) throws MappingException {
|
public int[] getSqlTypeCodes(MappingContext mappingContext) throws MappingException {
|
||||||
return requireIdentifierOrUniqueKeyType( mapping ).getSqlTypeCodes( mapping );
|
return requireIdentifierOrUniqueKeyType( mappingContext ).getSqlTypeCodes( mappingContext );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -231,7 +234,7 @@ public class ManyToOneType extends EntityType {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean[] toColumnNullness(Object value, Mapping mapping) {
|
public boolean[] toColumnNullness(Object value, MappingContext mapping) {
|
||||||
boolean[] result = new boolean[ getColumnSpan( mapping ) ];
|
boolean[] result = new boolean[ getColumnSpan( mapping ) ];
|
||||||
if ( value != null ) {
|
if ( value != null ) {
|
||||||
Arrays.fill( result, true );
|
Arrays.fill( result, true );
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
* 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.type;
|
||||||
|
|
||||||
|
import org.hibernate.MappingException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Declares operations used by implementors of {@link Type} that are common to
|
||||||
|
* "compiled" mappings held at runtime by a {@link org.hibernate.SessionFactory}
|
||||||
|
* and "uncompiled" mappings held by a {@link org.hibernate.cfg.Configuration}.
|
||||||
|
*
|
||||||
|
* @see Type
|
||||||
|
* @see org.hibernate.internal.SessionFactoryImpl
|
||||||
|
* @see org.hibernate.cfg.Configuration
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface MappingContext {
|
||||||
|
Type getIdentifierType(String className) throws MappingException;
|
||||||
|
|
||||||
|
String getIdentifierPropertyName(String className) throws MappingException;
|
||||||
|
|
||||||
|
Type getReferencedPropertyType(String className, String propertyName) throws MappingException;
|
||||||
|
}
|
|
@ -61,12 +61,12 @@ public class MetaType extends AbstractType {
|
||||||
return entityNameToDiscriminatorValueMap;
|
return entityNameToDiscriminatorValueMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int[] getSqlTypeCodes(Mapping mapping) throws MappingException {
|
public int[] getSqlTypeCodes(MappingContext mappingContext) throws MappingException {
|
||||||
return baseType.getSqlTypeCodes(mapping);
|
return baseType.getSqlTypeCodes( mappingContext );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getColumnSpan(Mapping mapping) throws MappingException {
|
public int getColumnSpan(MappingContext mapping) throws MappingException {
|
||||||
return baseType.getColumnSpan(mapping);
|
return baseType.getColumnSpan(mapping);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +110,15 @@ public class MetaType extends AbstractType {
|
||||||
return (String) value; //value is the entity name
|
return (String) value; //value is the entity name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated use {@link #fromXMLString(String, MappingContext)}
|
||||||
|
*/
|
||||||
|
@Deprecated(since = "7.0")
|
||||||
public Object fromXMLString(String xml, Mapping factory) throws HibernateException {
|
public Object fromXMLString(String xml, Mapping factory) throws HibernateException {
|
||||||
|
return fromXMLString( xml, (MappingContext) factory );
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object fromXMLString(String xml, MappingContext mappingContext) throws HibernateException {
|
||||||
return xml; //xml is the entity name
|
return xml; //xml is the entity name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +148,7 @@ public class MetaType extends AbstractType {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean[] toColumnNullness(Object value, Mapping mapping) {
|
public boolean[] toColumnNullness(Object value, MappingContext mapping) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ import java.sql.PreparedStatement;
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.MappingException;
|
import org.hibernate.MappingException;
|
||||||
import org.hibernate.engine.spi.EntityKey;
|
import org.hibernate.engine.spi.EntityKey;
|
||||||
import org.hibernate.engine.spi.Mapping;
|
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.internal.util.collections.ArrayHelper;
|
import org.hibernate.internal.util.collections.ArrayHelper;
|
||||||
|
@ -79,17 +78,17 @@ public class OneToOneType extends EntityType {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getColumnSpan(Mapping session) throws MappingException {
|
public int getColumnSpan(MappingContext session) throws MappingException {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int[] getSqlTypeCodes(Mapping session) throws MappingException {
|
public int[] getSqlTypeCodes(MappingContext mappingContext) throws MappingException {
|
||||||
return ArrayHelper.EMPTY_INT_ARRAY;
|
return ArrayHelper.EMPTY_INT_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean[] toColumnNullness(Object value, Mapping mapping) {
|
public boolean[] toColumnNullness(Object value, MappingContext mapping) {
|
||||||
return ArrayHelper.EMPTY_BOOLEAN_ARRAY;
|
return ArrayHelper.EMPTY_BOOLEAN_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,6 @@ import org.hibernate.HibernateException;
|
||||||
import org.hibernate.MappingException;
|
import org.hibernate.MappingException;
|
||||||
import org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer;
|
import org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer;
|
||||||
import org.hibernate.engine.jdbc.Size;
|
import org.hibernate.engine.jdbc.Size;
|
||||||
import org.hibernate.engine.spi.Mapping;
|
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.internal.util.ReflectHelper;
|
import org.hibernate.internal.util.ReflectHelper;
|
||||||
|
@ -126,7 +125,7 @@ public class SerializableToBlobType<T extends Serializable> implements BasicType
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean[] toColumnNullness(Object value, Mapping mapping) {
|
public boolean[] toColumnNullness(Object value, MappingContext mapping) {
|
||||||
return value == null ? ArrayHelper.FALSE : ArrayHelper.TRUE;
|
return value == null ? ArrayHelper.FALSE : ArrayHelper.TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,12 +168,12 @@ public class SerializableToBlobType<T extends Serializable> implements BasicType
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final int getColumnSpan(Mapping mapping) throws MappingException {
|
public final int getColumnSpan(MappingContext mapping) throws MappingException {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final int[] getSqlTypeCodes(Mapping mapping) throws MappingException {
|
public final int[] getSqlTypeCodes(MappingContext mappingContext) throws MappingException {
|
||||||
return sqlTypes;
|
return sqlTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,6 @@ import org.hibernate.AssertionFailure;
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.MappingException;
|
import org.hibernate.MappingException;
|
||||||
import org.hibernate.engine.internal.ForeignKeys;
|
import org.hibernate.engine.internal.ForeignKeys;
|
||||||
import org.hibernate.engine.spi.Mapping;
|
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.type.spi.TypeConfiguration;
|
import org.hibernate.type.spi.TypeConfiguration;
|
||||||
|
@ -54,12 +53,12 @@ public class SpecialOneToOneType extends OneToOneType {
|
||||||
super( original, superTypeEntityName );
|
super( original, superTypeEntityName );
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getColumnSpan(Mapping mapping) throws MappingException {
|
public int getColumnSpan(MappingContext mapping) throws MappingException {
|
||||||
return super.getIdentifierOrUniqueKeyType( mapping ).getColumnSpan( mapping );
|
return super.getIdentifierOrUniqueKeyType( mapping ).getColumnSpan( mapping );
|
||||||
}
|
}
|
||||||
|
|
||||||
public int[] getSqlTypeCodes(Mapping mapping) throws MappingException {
|
public int[] getSqlTypeCodes(MappingContext mappingContext) throws MappingException {
|
||||||
return super.getIdentifierOrUniqueKeyType( mapping ).getSqlTypeCodes( mapping );
|
return super.getIdentifierOrUniqueKeyType( mappingContext ).getSqlTypeCodes( mappingContext );
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean useLHSPrimaryKey() {
|
public boolean useLHSPrimaryKey() {
|
||||||
|
|
|
@ -96,15 +96,32 @@ public interface Type extends Serializable {
|
||||||
/**
|
/**
|
||||||
* How many columns are used to persist this type?
|
* How many columns are used to persist this type?
|
||||||
* <p>
|
* <p>
|
||||||
* Always the same as {@link #getSqlTypeCodes(Mapping) getSqlTypCodes(mapping).length}.
|
* Always the same as {@link #getSqlTypeCodes(MappingContext) getSqlTypCodes(mapping).length}.
|
||||||
*
|
*
|
||||||
* @param mapping The mapping object :/
|
* @param mapping The mapping object :/
|
||||||
*
|
*
|
||||||
* @return The number of columns
|
* @return The number of columns
|
||||||
*
|
*
|
||||||
* @throws MappingException Generally indicates an issue accessing the passed mapping object.
|
* @throws MappingException Generally indicates an issue accessing the passed mapping object.
|
||||||
|
* @deprecated use {@link #getColumnSpan(MappingContext)}
|
||||||
*/
|
*/
|
||||||
int getColumnSpan(Mapping mapping) throws MappingException;
|
@Deprecated(since = "7.0")
|
||||||
|
default int getColumnSpan(Mapping mapping) throws MappingException{
|
||||||
|
return getColumnSpan( (MappingContext) mapping);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How many columns are used to persist this type?
|
||||||
|
* <p>
|
||||||
|
* Always the same as {@link #getSqlTypeCodes(MappingContext) getSqlTypCodes(mappingContext).length}.
|
||||||
|
*
|
||||||
|
* @param mappingContext The mapping Context object {@link MappingContext}
|
||||||
|
*
|
||||||
|
* @return The number of columns
|
||||||
|
*
|
||||||
|
* @throws MappingException Generally indicates an issue accessing the passed mappingContext object.
|
||||||
|
*/
|
||||||
|
int getColumnSpan(MappingContext mappingContext) throws MappingException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the JDBC types codes as defined by {@link java.sql.Types} or {@link SqlTypes}
|
* Return the JDBC types codes as defined by {@link java.sql.Types} or {@link SqlTypes}
|
||||||
|
@ -117,8 +134,26 @@ public interface Type extends Serializable {
|
||||||
* @return The JDBC type codes.
|
* @return The JDBC type codes.
|
||||||
*
|
*
|
||||||
* @throws MappingException Generally indicates an issue accessing the passed mapping object.
|
* @throws MappingException Generally indicates an issue accessing the passed mapping object.
|
||||||
|
* @deprecated use {@link #getSqlTypeCodes(MappingContext)}
|
||||||
*/
|
*/
|
||||||
int[] getSqlTypeCodes(Mapping mapping) throws MappingException;
|
@Deprecated(since = "7.0")
|
||||||
|
default int[] getSqlTypeCodes(Mapping mapping) throws MappingException{
|
||||||
|
return getSqlTypeCodes((MappingContext) mapping);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the JDBC types codes as defined by {@link java.sql.Types} or {@link SqlTypes}
|
||||||
|
* for the columns mapped by this type.
|
||||||
|
* <p>
|
||||||
|
* The number of elements in this array must match the return from {@link #getColumnSpan}.
|
||||||
|
*
|
||||||
|
* @param mappingContext The mapping context {@link MappingContext} :/
|
||||||
|
*
|
||||||
|
* @return The JDBC type codes.
|
||||||
|
*
|
||||||
|
* @throws MappingException Generally indicates an issue accessing the passed mapping object.
|
||||||
|
*/
|
||||||
|
int[] getSqlTypeCodes(MappingContext mappingContext) throws MappingException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The class handled by this type.
|
* The class handled by this type.
|
||||||
|
@ -504,6 +539,22 @@ public interface Type extends Serializable {
|
||||||
* @param mapping The mapping abstraction
|
* @param mapping The mapping abstraction
|
||||||
*
|
*
|
||||||
* @return array indicating column nullness for a value instance
|
* @return array indicating column nullness for a value instance
|
||||||
|
* @deprecated use {@link #toColumnNullness(Object, MappingContext)}
|
||||||
*/
|
*/
|
||||||
boolean[] toColumnNullness(@Nullable Object value, Mapping mapping);
|
@Deprecated(since = "7.0")
|
||||||
|
default boolean[] toColumnNullness(@Nullable Object value, Mapping mapping){
|
||||||
|
return toColumnNullness( value,(MappingContext) mapping);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given an instance of the type, return an array of {@code boolean} values indicating which
|
||||||
|
* mapped columns would be null.
|
||||||
|
*
|
||||||
|
* @param value an instance of the type
|
||||||
|
* @param mappingContext The mapping context {@link MappingContext}
|
||||||
|
*
|
||||||
|
* @return array indicating column nullness for a value instance
|
||||||
|
*/
|
||||||
|
|
||||||
|
boolean[] toColumnNullness(@Nullable Object value, MappingContext mappingContext);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@ import org.hibernate.Hibernate;
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.MappingException;
|
import org.hibernate.MappingException;
|
||||||
import org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer;
|
import org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer;
|
||||||
import org.hibernate.engine.spi.Mapping;
|
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.internal.util.collections.ArrayHelper;
|
import org.hibernate.internal.util.collections.ArrayHelper;
|
||||||
|
@ -38,6 +37,7 @@ import org.hibernate.type.descriptor.java.JavaType;
|
||||||
import org.hibernate.type.descriptor.java.MutabilityPlan;
|
import org.hibernate.type.descriptor.java.MutabilityPlan;
|
||||||
import org.hibernate.type.descriptor.jdbc.JdbcLiteralFormatter;
|
import org.hibernate.type.descriptor.jdbc.JdbcLiteralFormatter;
|
||||||
import org.hibernate.type.descriptor.jdbc.JdbcType;
|
import org.hibernate.type.descriptor.jdbc.JdbcType;
|
||||||
|
import org.hibernate.type.MappingContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Christian Beikov
|
* @author Christian Beikov
|
||||||
|
@ -136,7 +136,7 @@ public class ConvertedBasicTypeImpl<J> implements ConvertedBasicType<J>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean[] toColumnNullness(Object value, Mapping mapping) {
|
public boolean[] toColumnNullness(Object value, MappingContext mapping) {
|
||||||
return value == null ? ArrayHelper.FALSE : ArrayHelper.TRUE;
|
return value == null ? ArrayHelper.FALSE : ArrayHelper.TRUE;
|
||||||
}
|
}
|
||||||
public final JavaType<J> getJavaTypeDescriptor() {
|
public final JavaType<J> getJavaTypeDescriptor() {
|
||||||
|
@ -153,12 +153,12 @@ public class ConvertedBasicTypeImpl<J> implements ConvertedBasicType<J>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final int getColumnSpan(Mapping mapping) throws MappingException {
|
public final int getColumnSpan(MappingContext mapping) throws MappingException {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final int[] getSqlTypeCodes(Mapping mapping) throws MappingException {
|
public final int[] getSqlTypeCodes(MappingContext mappingContext) throws MappingException {
|
||||||
return sqlTypes;
|
return sqlTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ package org.hibernate.processor.validation;
|
||||||
import jakarta.persistence.AccessType;
|
import jakarta.persistence.AccessType;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.hibernate.PropertyNotFoundException;
|
import org.hibernate.PropertyNotFoundException;
|
||||||
import org.hibernate.engine.spi.Mapping;
|
|
||||||
import org.hibernate.metamodel.mapping.EntityIdentifierMapping;
|
import org.hibernate.metamodel.mapping.EntityIdentifierMapping;
|
||||||
import org.hibernate.type.BasicType;
|
import org.hibernate.type.BasicType;
|
||||||
import org.hibernate.type.CollectionType;
|
import org.hibernate.type.CollectionType;
|
||||||
|
@ -22,6 +21,7 @@ import org.hibernate.type.descriptor.jdbc.IntegerJdbcType;
|
||||||
import org.hibernate.type.descriptor.jdbc.JdbcType;
|
import org.hibernate.type.descriptor.jdbc.JdbcType;
|
||||||
import org.hibernate.type.descriptor.jdbc.VarcharJdbcType;
|
import org.hibernate.type.descriptor.jdbc.VarcharJdbcType;
|
||||||
import org.hibernate.type.internal.BasicTypeImpl;
|
import org.hibernate.type.internal.BasicTypeImpl;
|
||||||
|
import org.hibernate.type.MappingContext;
|
||||||
|
|
||||||
import javax.annotation.processing.Filer;
|
import javax.annotation.processing.Filer;
|
||||||
import javax.annotation.processing.ProcessingEnvironment;
|
import javax.annotation.processing.ProcessingEnvironment;
|
||||||
|
@ -352,7 +352,7 @@ public abstract class ProcessorSessionFactory extends MockSessionFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getColumnSpan(Mapping mapping) {
|
public int getColumnSpan(MappingContext mapping) {
|
||||||
return propertyNames.length;
|
return propertyNames.length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue