re-enable tests
re-organize some tests added `@LoggingInspections` added `@MessageKeyWatcher` account for various "odd" explicit Type mappings fix column read/write transformations
This commit is contained in:
parent
e4f1461e17
commit
a02835bdde
|
@ -7,17 +7,17 @@
|
|||
package org.hibernate.boot.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.sql.Types;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.hibernate.NotYetImplementedFor6Exception;
|
||||
import org.hibernate.boot.model.process.internal.UserTypeResolution;
|
||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||
import org.hibernate.internal.util.MutableInteger;
|
||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||
import org.hibernate.mapping.BasicValue;
|
||||
import org.hibernate.metamodel.mapping.JdbcMapping;
|
||||
|
@ -26,11 +26,13 @@ import org.hibernate.resource.beans.spi.ManagedBean;
|
|||
import org.hibernate.resource.beans.spi.ManagedBeanRegistry;
|
||||
import org.hibernate.type.BasicType;
|
||||
import org.hibernate.type.CustomType;
|
||||
import org.hibernate.type.EnumType;
|
||||
import org.hibernate.type.SerializableType;
|
||||
import org.hibernate.type.Type;
|
||||
import org.hibernate.type.descriptor.java.ImmutableMutabilityPlan;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.java.MutabilityPlan;
|
||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptorIndicators;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
import org.hibernate.type.spi.TypeConfigurationAware;
|
||||
import org.hibernate.usertype.ParameterizedType;
|
||||
|
@ -59,7 +61,6 @@ public class TypeDefinition implements Serializable {
|
|||
private final Class typeImplementorClass;
|
||||
private final String[] registrationKeys;
|
||||
private final Properties parameters;
|
||||
private final TypeConfiguration typeConfiguration;
|
||||
|
||||
private BasicValue.Resolution<?> reusableResolution;
|
||||
|
||||
|
@ -74,7 +75,6 @@ public class TypeDefinition implements Serializable {
|
|||
this.typeImplementorClass = typeImplementorClass;
|
||||
this.registrationKeys= registrationKeys;
|
||||
this.parameters = parameters;
|
||||
this.typeConfiguration = typeConfiguration;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
@ -102,84 +102,94 @@ public class TypeDefinition implements Serializable {
|
|||
public BasicValue.Resolution<?> resolve(
|
||||
Map localConfigParameters,
|
||||
MutabilityPlan explicitMutabilityPlan,
|
||||
MetadataBuildingContext context) {
|
||||
MetadataBuildingContext context,
|
||||
SqlTypeDescriptorIndicators indicators) {
|
||||
if ( CollectionHelper.isEmpty( localConfigParameters ) ) {
|
||||
// we can use the re-usable resolution...
|
||||
if ( reusableResolution == null ) {
|
||||
final ManagedBean typeBean = context.getBootstrapContext()
|
||||
.getServiceRegistry()
|
||||
.getService( ManagedBeanRegistry.class )
|
||||
.getBean( typeImplementorClass );
|
||||
|
||||
final Object typeInstance = typeBean.getBeanInstance();
|
||||
|
||||
injectParameters( typeInstance, () -> parameters );
|
||||
|
||||
reusableResolution = createReusableResolution( typeInstance, name, context );
|
||||
reusableResolution = createResolution( null, Collections.emptyMap(), indicators, context );
|
||||
}
|
||||
|
||||
return reusableResolution;
|
||||
}
|
||||
else {
|
||||
final String name = this.name + ":" + NAME_COUNTER.getAndIncrement();
|
||||
return createResolution( name, localConfigParameters, indicators, context );
|
||||
}
|
||||
}
|
||||
|
||||
final ManagedBean typeBean = context.getBootstrapContext()
|
||||
.getServiceRegistry()
|
||||
.getService( ManagedBeanRegistry.class )
|
||||
.getBean( name, typeImplementorClass );
|
||||
|
||||
final Object typeInstance = typeBean.getBeanInstance();
|
||||
|
||||
injectParameters(
|
||||
typeInstance,
|
||||
() -> mergeParameters( parameters, localConfigParameters )
|
||||
);
|
||||
|
||||
|
||||
private BasicValue.Resolution<?> createResolution(
|
||||
String name,
|
||||
Map<?,?> usageSiteProperties,
|
||||
SqlTypeDescriptorIndicators indicators,
|
||||
MetadataBuildingContext context) {
|
||||
return createResolution(
|
||||
name,
|
||||
typeInstance,
|
||||
explicitMutabilityPlan,
|
||||
typeImplementorClass,
|
||||
parameters,
|
||||
usageSiteProperties,
|
||||
indicators,
|
||||
context
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private static Properties mergeParameters(Properties parameters, Map localConfigParameters) {
|
||||
final Properties mergedParameters = new Properties();
|
||||
|
||||
if ( parameters != null ) {
|
||||
mergedParameters.putAll( parameters );
|
||||
}
|
||||
|
||||
if ( localConfigParameters != null && ! localConfigParameters.isEmpty() ) {
|
||||
mergedParameters.putAll( localConfigParameters );
|
||||
}
|
||||
|
||||
return mergedParameters;
|
||||
}
|
||||
|
||||
public static void injectParameters(Object customType, Supplier<Properties> parameterSupplier) {
|
||||
if ( customType instanceof ParameterizedType ) {
|
||||
final Properties parameterValues = parameterSupplier.get();
|
||||
if ( parameterValues != null ) {
|
||||
( (ParameterizedType) customType ).setParameterValues( parameterValues );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static BasicValue.Resolution<?> createReusableResolution(
|
||||
Object namedTypeInstance,
|
||||
private static BasicValue.Resolution<?> createResolution(
|
||||
String name,
|
||||
MetadataBuildingContext buildingContext) {
|
||||
if ( namedTypeInstance instanceof UserType ) {
|
||||
final UserType userType = (UserType) namedTypeInstance;
|
||||
final CustomType customType = new CustomType( userType, buildingContext.getBootstrapContext().getTypeConfiguration() );
|
||||
Class<?> typeImplementorClass,
|
||||
Properties parameters,
|
||||
Map<?,?> usageSiteProperties,
|
||||
SqlTypeDescriptorIndicators indicators,
|
||||
MetadataBuildingContext context) {
|
||||
final TypeConfiguration typeConfiguration = context.getBootstrapContext().getTypeConfiguration();
|
||||
|
||||
final boolean isKnownType = Type.class.isAssignableFrom( typeImplementorClass )
|
||||
|| UserType.class.isAssignableFrom( typeImplementorClass );
|
||||
|
||||
// support for AttributeConverter would be nice too
|
||||
if ( isKnownType ) {
|
||||
final ManagedBean typeBean;
|
||||
if ( name != null ) {
|
||||
typeBean = context.getBootstrapContext()
|
||||
.getServiceRegistry()
|
||||
.getService( ManagedBeanRegistry.class )
|
||||
.getBean( name, typeImplementorClass );
|
||||
}
|
||||
else {
|
||||
typeBean = context.getBootstrapContext()
|
||||
.getServiceRegistry()
|
||||
.getService( ManagedBeanRegistry.class )
|
||||
.getBean( typeImplementorClass );
|
||||
}
|
||||
|
||||
final Object typeInstance = typeBean.getBeanInstance();
|
||||
|
||||
if ( typeInstance instanceof TypeConfigurationAware ) {
|
||||
( (TypeConfigurationAware) typeInstance ).setTypeConfiguration( typeConfiguration );
|
||||
}
|
||||
|
||||
injectParameters(
|
||||
typeInstance,
|
||||
() -> {
|
||||
if ( CollectionHelper.isNotEmpty( usageSiteProperties ) ) {
|
||||
final Properties properties = new Properties( parameters );
|
||||
properties.putAll( usageSiteProperties );
|
||||
return properties;
|
||||
}
|
||||
else {
|
||||
return parameters;
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
if ( typeInstance instanceof UserType ) {
|
||||
final UserType userType = (UserType) typeInstance;
|
||||
final CustomType customType = new CustomType( userType, typeConfiguration );
|
||||
|
||||
return new UserTypeResolution( customType, null );
|
||||
}
|
||||
else if ( namedTypeInstance instanceof BasicType ) {
|
||||
final BasicType resolvedBasicType = (BasicType) namedTypeInstance;
|
||||
|
||||
if ( typeInstance instanceof BasicType ) {
|
||||
final BasicType resolvedBasicType = (BasicType) typeInstance;
|
||||
return new BasicValue.Resolution<Object>() {
|
||||
@Override
|
||||
public JdbcMapping getJdbcMapping() {
|
||||
|
@ -220,12 +230,73 @@ public class TypeDefinition implements Serializable {
|
|||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Series of backward compatible special cases
|
||||
|
||||
if ( Serializable.class.isAssignableFrom( typeImplementorClass ) ) {
|
||||
final JavaTypeDescriptor<Serializable> jtd = typeConfiguration
|
||||
.getJavaTypeDescriptorRegistry()
|
||||
.resolveDescriptor( typeImplementorClass );
|
||||
final SqlTypeDescriptor jdbcType = typeConfiguration.getSqlTypeDescriptorRegistry().getDescriptor( Types.VARBINARY );
|
||||
final BasicType<Serializable> resolved = typeConfiguration.getBasicTypeRegistry().resolve( jtd, jdbcType );
|
||||
final SerializableType legacyType = new SerializableType( typeImplementorClass );
|
||||
|
||||
return new BasicValue.Resolution<Object>() {
|
||||
@Override
|
||||
public JdbcMapping getJdbcMapping() {
|
||||
return resolved;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasicType getLegacyResolvedBasicType() {
|
||||
return legacyType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaTypeDescriptor<Object> getDomainJavaDescriptor() {
|
||||
return resolved.getMappedJavaTypeDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaTypeDescriptor<?> getRelationalJavaDescriptor() {
|
||||
return resolved.getMappedJavaTypeDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqlTypeDescriptor getRelationalSqlTypeDescriptor() {
|
||||
return resolved.getSqlTypeDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasicValueConverter getValueConverter() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutabilityPlan<Object> getMutabilityPlan() {
|
||||
// a TypeDefinition does not explicitly provide a MutabilityPlan (yet?)
|
||||
return resolved.isMutable()
|
||||
? getDomainJavaDescriptor().getMutabilityPlan()
|
||||
: ImmutableMutabilityPlan.instance();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException(
|
||||
"Named type [" + namedTypeInstance + "] did not implement BasicType nor UserType"
|
||||
"Named type [" + typeImplementorClass + "] did not implement BasicType nor UserType"
|
||||
);
|
||||
}
|
||||
|
||||
public static void injectParameters(Object customType, Supplier<Properties> parameterSupplier) {
|
||||
if ( customType instanceof ParameterizedType ) {
|
||||
final Properties parameterValues = parameterSupplier.get();
|
||||
if ( parameterValues != null ) {
|
||||
( (ParameterizedType) customType ).setParameterValues( parameterValues );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static BasicValue.Resolution<?> createLocalResolution(
|
||||
String name,
|
||||
Class typeImplementorClass,
|
||||
|
@ -234,84 +305,21 @@ public class TypeDefinition implements Serializable {
|
|||
MetadataBuildingContext buildingContext) {
|
||||
name = name + ':' + NAME_COUNTER.getAndIncrement();
|
||||
|
||||
final ManagedBean typeBean = buildingContext.getBootstrapContext()
|
||||
.getServiceRegistry()
|
||||
.getService( ManagedBeanRegistry.class )
|
||||
.getBean( name, typeImplementorClass );
|
||||
final Properties properties = new Properties();
|
||||
properties.putAll( localTypeParams );
|
||||
|
||||
final Object typeInstance = typeBean.getBeanInstance();
|
||||
|
||||
if ( typeInstance instanceof TypeConfigurationAware ) {
|
||||
( (TypeConfigurationAware) typeInstance ).setTypeConfiguration( buildingContext.getBootstrapContext().getTypeConfiguration() );
|
||||
}
|
||||
|
||||
injectParameters( typeInstance, () -> CollectionHelper.asProperties( localTypeParams ) );
|
||||
final TypeConfiguration typeConfiguration = buildingContext.getBootstrapContext().getTypeConfiguration();
|
||||
|
||||
return createResolution(
|
||||
name,
|
||||
typeInstance,
|
||||
explicitMutabilityPlan,
|
||||
typeImplementorClass,
|
||||
properties,
|
||||
null,
|
||||
typeConfiguration.getCurrentBaseSqlTypeIndicators(),
|
||||
buildingContext
|
||||
);
|
||||
}
|
||||
|
||||
private static BasicValue.Resolution<?> createResolution(
|
||||
String name,
|
||||
Object namedTypeInstance,
|
||||
MutabilityPlan explicitMutabilityPlan,
|
||||
MetadataBuildingContext metadataBuildingContext) {
|
||||
if ( namedTypeInstance instanceof UserType ) {
|
||||
return new UserTypeResolution(
|
||||
new CustomType( (UserType) namedTypeInstance, metadataBuildingContext.getBootstrapContext().getTypeConfiguration() ),
|
||||
null
|
||||
);
|
||||
}
|
||||
else if ( namedTypeInstance instanceof org.hibernate.type.BasicType ) {
|
||||
final BasicType resolvedBasicType = (BasicType) namedTypeInstance;
|
||||
return new BasicValue.Resolution<Object>() {
|
||||
@Override
|
||||
public JdbcMapping getJdbcMapping() {
|
||||
return resolvedBasicType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasicType getLegacyResolvedBasicType() {
|
||||
return resolvedBasicType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaTypeDescriptor<Object> getDomainJavaDescriptor() {
|
||||
return resolvedBasicType.getMappedJavaTypeDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaTypeDescriptor<?> getRelationalJavaDescriptor() {
|
||||
return resolvedBasicType.getMappedJavaTypeDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqlTypeDescriptor getRelationalSqlTypeDescriptor() {
|
||||
return resolvedBasicType.getSqlTypeDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasicValueConverter getValueConverter() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutabilityPlan<Object> getMutabilityPlan() {
|
||||
throw new NotYetImplementedFor6Exception( getClass() );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException(
|
||||
"Named type [" + name + " : " + namedTypeInstance
|
||||
+ "] did not implement BasicType nor UserType"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if ( this == o ) {
|
||||
|
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.boot.model.process.internal;
|
||||
|
||||
import org.hibernate.mapping.BasicValue;
|
||||
import org.hibernate.metamodel.mapping.JdbcMapping;
|
||||
import org.hibernate.metamodel.model.convert.spi.BasicValueConverter;
|
||||
import org.hibernate.type.BasicType;
|
||||
import org.hibernate.type.ConvertedBasicType;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.java.MutabilityPlan;
|
||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptorIndicators;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class ConvertedBasicTypeResolution<J> implements BasicValue.Resolution<J> {
|
||||
private final ConvertedBasicType basicType;
|
||||
private final ValueConverterTypeAdapter adapted;
|
||||
|
||||
public ConvertedBasicTypeResolution(
|
||||
ConvertedBasicType basicType,
|
||||
SqlTypeDescriptorIndicators stdIndicators) {
|
||||
this.basicType = basicType;
|
||||
|
||||
final BasicValueConverter valueConverter = basicType.getValueConverter();
|
||||
|
||||
this.adapted = new ValueConverterTypeAdapter(
|
||||
valueConverter.getClass().getTypeName(),
|
||||
valueConverter,
|
||||
stdIndicators
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasicType<J> getLegacyResolvedBasicType() {
|
||||
return adapted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JdbcMapping getJdbcMapping() {
|
||||
return adapted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaTypeDescriptor<J> getDomainJavaDescriptor() {
|
||||
return basicType.getValueConverter().getDomainJavaDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaTypeDescriptor<?> getRelationalJavaDescriptor() {
|
||||
return basicType.getValueConverter().getRelationalJavaDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqlTypeDescriptor getRelationalSqlTypeDescriptor() {
|
||||
return adapted.getSqlTypeDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasicValueConverter getValueConverter() {
|
||||
return basicType.getValueConverter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutabilityPlan<J> getMutabilityPlan() {
|
||||
return getDomainJavaDescriptor().getMutabilityPlan();
|
||||
}
|
||||
}
|
|
@ -41,9 +41,9 @@ public class NamedBasicTypeResolution<J> implements BasicValue.Resolution<J> {
|
|||
this.basicType = basicType;
|
||||
|
||||
// named type cannot have converter applied
|
||||
this.valueConverter = null;
|
||||
// this.valueConverter = null;
|
||||
// todo (6.0) : does it even make sense to allow a combo of explicit Type and a converter?
|
||||
// this.valueConverter = valueConverter;
|
||||
this.valueConverter = valueConverter;
|
||||
|
||||
final MutabilityPlan explicitPlan = explicitMutabilityPlanAccess != null
|
||||
? explicitMutabilityPlanAccess.apply( context.getBootstrapContext().getTypeConfiguration() )
|
||||
|
@ -70,7 +70,9 @@ public class NamedBasicTypeResolution<J> implements BasicValue.Resolution<J> {
|
|||
|
||||
@Override
|
||||
public JavaTypeDescriptor<?> getRelationalJavaDescriptor() {
|
||||
return basicType.getJavaTypeDescriptor();
|
||||
return valueConverter == null
|
||||
? basicType.getJavaTypeDescriptor()
|
||||
: valueConverter.getRelationalJavaDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.boot.model.process.internal;
|
||||
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.metamodel.model.convert.spi.BasicValueConverter;
|
||||
import org.hibernate.type.AbstractSingleColumnStandardBasicType;
|
||||
import org.hibernate.type.descriptor.ValueBinder;
|
||||
import org.hibernate.type.descriptor.WrapperOptions;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.java.MutabilityPlan;
|
||||
import org.hibernate.type.descriptor.sql.SqlTypeDescriptorIndicators;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class ValueConverterTypeAdapter<J> extends AbstractSingleColumnStandardBasicType<J> {
|
||||
private final String description;
|
||||
private final BasicValueConverter<J,?> converter;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
private final ValueBinder valueBinder;
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public ValueConverterTypeAdapter(
|
||||
String description,
|
||||
BasicValueConverter<J, ?> converter,
|
||||
SqlTypeDescriptorIndicators indicators) {
|
||||
super(
|
||||
converter.getRelationalJavaDescriptor().getJdbcRecommendedSqlType( indicators ),
|
||||
(JavaTypeDescriptor) converter.getRelationalJavaDescriptor()
|
||||
);
|
||||
|
||||
this.description = description;
|
||||
this.converter = converter;
|
||||
|
||||
this.valueBinder = getSqlTypeDescriptor().getBinder( converter.getRelationalJavaDescriptor() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return converter.getClass().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "unchecked" })
|
||||
public void nullSafeSet(
|
||||
CallableStatement st,
|
||||
Object value,
|
||||
String name,
|
||||
SharedSessionContractImplementor session) throws SQLException {
|
||||
final Object converted = converter.toRelationalValue( (J) value );
|
||||
valueBinder.bind( st, converted, name, session );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "unchecked" })
|
||||
protected void nullSafeSet(PreparedStatement st, Object value, int index, WrapperOptions options) throws SQLException {
|
||||
final Object converted = converter.toRelationalValue( (J) value );
|
||||
valueBinder.bind( st, converted, index, options );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MutabilityPlan<J> getMutabilityPlan() {
|
||||
return converter.getDomainJavaDescriptor().getMutabilityPlan();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEqual(Object one, Object another) {
|
||||
//noinspection unchecked
|
||||
return ( (JavaTypeDescriptor<Object>) converter.getDomainJavaDescriptor() ).areEqual( one, another );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return description;
|
||||
}
|
||||
}
|
|
@ -2459,7 +2459,8 @@ public class ModelBinder {
|
|||
final BasicValue.Resolution<?> resolution = typeDefinition.resolve(
|
||||
parameters,
|
||||
null,
|
||||
metadataBuildingContext
|
||||
metadataBuildingContext,
|
||||
bootstrapContext.getTypeConfiguration().getCurrentBaseSqlTypeIndicators()
|
||||
);
|
||||
|
||||
return (DiscriminatorType<?>) resolution.getLegacyResolvedBasicType();
|
||||
|
|
|
@ -52,7 +52,7 @@ class SingularIdentifierAttributeSourceImpl
|
|||
|
||||
if ( StringHelper.isEmpty( idElement.getName() ) ) {
|
||||
DeprecationLogger.DEPRECATION_LOGGER.logDeprecationOfNonNamedIdAttribute( container.getAttributeRoleBase().getFullPath() );
|
||||
name = null;
|
||||
name = "id";
|
||||
}
|
||||
else {
|
||||
name = idElement.getName();
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.hibernate.boot.model.TypeDefinition;
|
|||
import org.hibernate.boot.model.convert.internal.ClassBasedConverterDescriptor;
|
||||
import org.hibernate.boot.model.convert.spi.ConverterDescriptor;
|
||||
import org.hibernate.boot.model.convert.spi.JpaAttributeConverterCreationContext;
|
||||
import org.hibernate.boot.model.process.internal.ConvertedBasicTypeResolution;
|
||||
import org.hibernate.boot.model.process.internal.InferredBasicValueResolver;
|
||||
import org.hibernate.boot.model.process.internal.NamedBasicTypeResolution;
|
||||
import org.hibernate.boot.model.process.internal.NamedConverterResolution;
|
||||
|
@ -36,6 +37,7 @@ import org.hibernate.metamodel.model.convert.spi.BasicValueConverter;
|
|||
import org.hibernate.resource.beans.spi.ManagedBeanRegistry;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.type.BasicType;
|
||||
import org.hibernate.type.ConvertedBasicType;
|
||||
import org.hibernate.type.Type;
|
||||
import org.hibernate.type.descriptor.java.BasicJavaDescriptor;
|
||||
import org.hibernate.type.descriptor.java.EnumJavaTypeDescriptor;
|
||||
|
@ -365,7 +367,12 @@ public class BasicValue extends SimpleValue implements SqlTypeDescriptorIndicato
|
|||
.resolveAutoApplied( (BasicJavaDescriptor<?>) jtd );
|
||||
if ( autoAppliedTypeDef != null ) {
|
||||
log.debug( "BasicValue resolution matched auto-applied type-definition" );
|
||||
return autoAppliedTypeDef.resolve( getTypeParameters(), null, getBuildingContext() );
|
||||
return autoAppliedTypeDef.resolve(
|
||||
getTypeParameters(),
|
||||
null,
|
||||
getBuildingContext(),
|
||||
this
|
||||
);
|
||||
}
|
||||
|
||||
if ( jtd instanceof EnumJavaTypeDescriptor ) {
|
||||
|
@ -483,14 +490,18 @@ public class BasicValue extends SimpleValue implements SqlTypeDescriptorIndicato
|
|||
if ( basicTypeByName != null ) {
|
||||
final BasicValueConverter valueConverter;
|
||||
final JavaTypeDescriptor<?> domainJtd;
|
||||
if ( converterDescriptor == null ) {
|
||||
valueConverter = null;
|
||||
domainJtd = basicTypeByName.getJavaTypeDescriptor();
|
||||
}
|
||||
else {
|
||||
if ( converterDescriptor != null ) {
|
||||
valueConverter = converterDescriptor.createJpaAttributeConverter( converterCreationContext );
|
||||
domainJtd = valueConverter.getDomainJavaDescriptor();
|
||||
}
|
||||
else if ( basicTypeByName instanceof ConvertedBasicType ) {
|
||||
final ConvertedBasicType convertedType = (ConvertedBasicType) basicTypeByName;
|
||||
return new ConvertedBasicTypeResolution( convertedType, stdIndicators );
|
||||
}
|
||||
else {
|
||||
valueConverter = null;
|
||||
domainJtd = basicTypeByName.getJavaTypeDescriptor();
|
||||
}
|
||||
|
||||
return new NamedBasicTypeResolution(
|
||||
domainJtd,
|
||||
|
@ -509,7 +520,8 @@ public class BasicValue extends SimpleValue implements SqlTypeDescriptorIndicato
|
|||
explicitMutabilityPlanAccess != null
|
||||
? explicitMutabilityPlanAccess.apply( typeConfiguration )
|
||||
: null,
|
||||
context
|
||||
context,
|
||||
stdIndicators
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -535,7 +547,8 @@ public class BasicValue extends SimpleValue implements SqlTypeDescriptorIndicato
|
|||
explicitMutabilityPlanAccess != null
|
||||
? explicitMutabilityPlanAccess.apply( typeConfiguration )
|
||||
: null,
|
||||
context
|
||||
context,
|
||||
stdIndicators
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -108,7 +108,9 @@ public class StandardPojoEntityRepresentationStrategy implements EntityRepresent
|
|||
|
||||
final KeyValue bootDescriptorIdentifier = bootDescriptor.getIdentifier();
|
||||
|
||||
if ( bootDescriptorIdentifier != null && bootDescriptorIdentifier instanceof Component ) {
|
||||
if ( bootDescriptorIdentifier instanceof Component ) {
|
||||
final Component component = (Component) bootDescriptorIdentifier;
|
||||
if ( bootDescriptor.getIdentifierMapper() != null ) {
|
||||
mapsIdRepresentationStrategy = new StandardPojoEmbeddableRepresentationStrategy(
|
||||
bootDescriptor.getIdentifierMapper(),
|
||||
creationContext
|
||||
|
@ -118,6 +120,10 @@ public class StandardPojoEntityRepresentationStrategy implements EntityRepresent
|
|||
mapsIdRepresentationStrategy = null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
mapsIdRepresentationStrategy = null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
mapsIdRepresentationStrategy = null;
|
||||
identifierPropertyName = identifierProperty.getName();
|
||||
|
@ -408,6 +414,11 @@ public class StandardPojoEntityRepresentationStrategy implements EntityRepresent
|
|||
if ( propertyAccess != null ) {
|
||||
return propertyAccess;
|
||||
}
|
||||
|
||||
if ( mapsIdRepresentationStrategy != null ) {
|
||||
return mapsIdRepresentationStrategy.resolvePropertyAccess( bootAttributeDescriptor );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
|
|||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.property.access.spi.PropertyAccess;
|
||||
import org.hibernate.query.NavigablePath;
|
||||
import org.hibernate.sql.Template;
|
||||
import org.hibernate.sql.ast.Clause;
|
||||
import org.hibernate.sql.ast.tree.from.TableGroup;
|
||||
import org.hibernate.sql.results.graph.DomainResult;
|
||||
|
@ -225,7 +226,7 @@ public class EmbeddableMappingType implements ManagedMappingType, SelectionMappi
|
|||
containingTableExpression,
|
||||
columnExpression,
|
||||
selectable.isFormula(),
|
||||
selectable.getCustomReadExpression(),
|
||||
selectable.getTemplate( dialect, sessionFactory.getQueryEngine().getSqmFunctionRegistry() ),
|
||||
selectable.getCustomWriteExpression(),
|
||||
representationStrategy.resolvePropertyAccess( bootPropertyDescriptor ),
|
||||
compositeType.getCascadeStyle( attributeIndex ),
|
||||
|
|
|
@ -193,6 +193,10 @@ public interface EntityMappingType extends ManagedMappingType, EntityValuedModel
|
|||
return superMappingType.getRootEntityDescriptor();
|
||||
}
|
||||
|
||||
default TableReference locateTableReference(TableGroup tableGroup) {
|
||||
return tableGroup.getPrimaryTableReference();
|
||||
}
|
||||
|
||||
interface ConstraintOrderedTableConsumer {
|
||||
void consume(String tableExpression, Supplier<Consumer<SelectionConsumer>> tableKeyColumnVisitationSupplier);
|
||||
}
|
||||
|
|
|
@ -23,6 +23,10 @@ import org.hibernate.sql.results.graph.DomainResultCreationState;
|
|||
public interface ForeignKeyDescriptor extends VirtualModelPart {
|
||||
String PART_NAME = "{fk}";
|
||||
|
||||
String getKeyColumnContainingTable();
|
||||
|
||||
String getTargetColumnContainingTable();
|
||||
|
||||
DomainResult createCollectionFetchDomainResult(
|
||||
NavigablePath collectionPath,
|
||||
TableGroup tableGroup,
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
package org.hibernate.metamodel.mapping;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
|
|
|
@ -84,6 +84,16 @@ public class EmbeddedForeignKeyDescriptor implements ForeignKeyDescriptor, Model
|
|||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKeyColumnContainingTable() {
|
||||
return keyColumnContainingTable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTargetColumnContainingTable() {
|
||||
return targetColumnContainingTable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainResult createCollectionFetchDomainResult(
|
||||
NavigablePath collectionPath,
|
||||
|
|
|
@ -7,21 +7,19 @@
|
|||
package org.hibernate.metamodel.mapping.internal;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.engine.spi.Mapping;
|
||||
import org.hibernate.internal.util.collections.ArrayHelper;
|
||||
import org.hibernate.internal.util.collections.CollectionHelper;
|
||||
import org.hibernate.mapping.Selectable;
|
||||
import org.hibernate.mapping.Value;
|
||||
import org.hibernate.metamodel.mapping.EmbeddableMappingType;
|
||||
import org.hibernate.metamodel.mapping.JdbcMapping;
|
||||
import org.hibernate.metamodel.mapping.SelectionConsumer;
|
||||
import org.hibernate.metamodel.mapping.SelectionMapping;
|
||||
import org.hibernate.metamodel.mapping.SelectionMappings;
|
||||
import org.hibernate.metamodel.mapping.EmbeddableMappingType;
|
||||
import org.hibernate.metamodel.mapping.JdbcMapping;
|
||||
import org.hibernate.query.sqm.function.SqmFunctionRegistry;
|
||||
import org.hibernate.type.CompositeType;
|
||||
import org.hibernate.type.EntityType;
|
||||
|
|
|
@ -68,6 +68,16 @@ public class SimpleForeignKeyDescriptor implements ForeignKeyDescriptor, BasicVa
|
|||
this.refersToPrimaryKey = refersToPrimaryKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKeyColumnContainingTable() {
|
||||
return keySelectionMapping.getContainingTableExpression();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTargetColumnContainingTable() {
|
||||
return targetSelectionMapping.getContainingTableExpression();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainResult<?> createCollectionFetchDomainResult(
|
||||
NavigablePath collectionPath,
|
||||
|
|
|
@ -6,26 +6,24 @@
|
|||
*/
|
||||
package org.hibernate.metamodel.mapping.ordering.ast;
|
||||
|
||||
import org.hibernate.query.SortOrder;
|
||||
import org.hibernate.metamodel.mapping.MappingType;
|
||||
import org.hibernate.metamodel.mapping.ModelPartContainer;
|
||||
import org.hibernate.metamodel.mapping.PluralAttributeMapping;
|
||||
import org.hibernate.metamodel.mapping.ordering.TranslationContext;
|
||||
import org.hibernate.persister.entity.AbstractEntityPersister;
|
||||
import org.hibernate.query.NavigablePath;
|
||||
import org.hibernate.query.SortOrder;
|
||||
import org.hibernate.sql.ast.spi.SqlAstCreationState;
|
||||
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
|
||||
import org.hibernate.sql.ast.tree.expression.Expression;
|
||||
import org.hibernate.sql.ast.tree.from.TableGroup;
|
||||
import org.hibernate.sql.ast.tree.from.TableReference;
|
||||
import org.hibernate.sql.ast.tree.from.TableReferenceJoin;
|
||||
import org.hibernate.sql.ast.tree.select.QuerySpec;
|
||||
import org.hibernate.sql.ast.tree.select.SortSpecification;
|
||||
|
||||
/**
|
||||
* Represents a column-reference used in an order-by fragment
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
* @apiNote This is Hibernate-specific feature. For {@link javax.persistence.OrderBy} (JPA)
|
||||
* all path references are expected to be domain paths (attributes).
|
||||
*
|
||||
|
@ -101,19 +99,15 @@ public class ColumnReference implements OrderingExpression, SequencePart {
|
|||
TableReference getTableReference(TableGroup tableGroup) {
|
||||
ModelPartContainer modelPart = tableGroup.getModelPart();
|
||||
if ( modelPart instanceof PluralAttributeMapping ) {
|
||||
MappingType partMappingType = ( (PluralAttributeMapping) modelPart ).getElementDescriptor()
|
||||
.getPartMappingType();
|
||||
if ( partMappingType instanceof AbstractEntityPersister ) {
|
||||
AbstractEntityPersister abstractEntityPersister = (AbstractEntityPersister) partMappingType;
|
||||
int i = abstractEntityPersister.determineTableNumberForColumn( columnExpression );
|
||||
String tableName = abstractEntityPersister.getTableName( i );
|
||||
for ( TableReferenceJoin tableReferenceJoin : tableGroup.getTableReferenceJoins() ) {
|
||||
final TableReference joinedTableReference = tableReferenceJoin.getJoinedTableReference();
|
||||
if ( joinedTableReference.getTableExpression()
|
||||
.equals( tableName ) ) {
|
||||
return joinedTableReference;
|
||||
}
|
||||
}
|
||||
final PluralAttributeMapping pluralAttribute = (PluralAttributeMapping) modelPart;
|
||||
final MappingType elementMappingType = (pluralAttribute).getElementDescriptor().getPartMappingType();
|
||||
|
||||
if ( elementMappingType instanceof AbstractEntityPersister ) {
|
||||
final AbstractEntityPersister abstractEntityPersister = (AbstractEntityPersister) elementMappingType;
|
||||
final int tableNumber = abstractEntityPersister.determineTableNumberForColumn( columnExpression );
|
||||
final String tableName = abstractEntityPersister.getTableName( tableNumber );
|
||||
|
||||
return tableGroup.getTableReference( tableName );
|
||||
}
|
||||
else {
|
||||
return tableGroup.getPrimaryTableReference();
|
||||
|
|
|
@ -247,6 +247,7 @@ import org.hibernate.type.TypeHelper;
|
|||
import org.hibernate.type.VersionType;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.java.MutabilityPlan;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
/**
|
||||
* Basic functionality for persisting an entity via JDBC
|
||||
|
@ -1405,7 +1406,7 @@ public abstract class AbstractEntityPersister
|
|||
generateJoinPredicate(
|
||||
primaryTableReference,
|
||||
joinedTableReference,
|
||||
i,
|
||||
getSubclassTableKeyColumns( i ),
|
||||
sqlExpressionResolver
|
||||
)
|
||||
);
|
||||
|
@ -1426,6 +1427,7 @@ public abstract class AbstractEntityPersister
|
|||
return resolvePrimaryTableReference( sqlAliasBase );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TableReferenceJoin createTableReferenceJoin(
|
||||
String joinTableExpression,
|
||||
|
@ -1437,22 +1439,13 @@ public abstract class AbstractEntityPersister
|
|||
for ( int i = 1; i < getSubclassTableSpan(); i++ ) {
|
||||
final String subclassTableName = getSubclassTableName( i );
|
||||
if ( subclassTableName.equals( joinTableExpression ) ) {
|
||||
final TableReference joinedTableReference = new TableReference(
|
||||
joinTableExpression,
|
||||
sqlAliasBase.generateNewAlias(),
|
||||
isNullableSubclassTable( i ),
|
||||
getFactory()
|
||||
);
|
||||
|
||||
return new TableReferenceJoin(
|
||||
determineSubclassTableJoinType( i, canUseInnerJoin, true, Collections.emptySet() ),
|
||||
joinedTableReference,
|
||||
generateJoinPredicate(
|
||||
return generateTableReferenceJoin(
|
||||
lhs,
|
||||
joinedTableReference,
|
||||
i,
|
||||
joinTableExpression,
|
||||
sqlAliasBase,
|
||||
determineSubclassTableJoinType( i, canUseInnerJoin, true, Collections.emptySet() ),
|
||||
getSubclassTableKeyColumns( i ),
|
||||
sqlExpressionResolver
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1460,6 +1453,32 @@ public abstract class AbstractEntityPersister
|
|||
return null;
|
||||
}
|
||||
|
||||
protected TableReferenceJoin generateTableReferenceJoin(
|
||||
TableReference lhs,
|
||||
String joinTableExpression,
|
||||
SqlAliasBase sqlAliasBase,
|
||||
SqlAstJoinType joinType,
|
||||
String[] targetColumns,
|
||||
SqlExpressionResolver sqlExpressionResolver) {
|
||||
final TableReference joinedTableReference = new TableReference(
|
||||
joinTableExpression,
|
||||
sqlAliasBase.generateNewAlias(),
|
||||
joinType != SqlAstJoinType.INNER,
|
||||
getFactory()
|
||||
);
|
||||
|
||||
return new TableReferenceJoin(
|
||||
joinType,
|
||||
joinedTableReference,
|
||||
generateJoinPredicate(
|
||||
lhs,
|
||||
joinedTableReference,
|
||||
targetColumns,
|
||||
sqlExpressionResolver
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
protected TableReference resolvePrimaryTableReference(SqlAliasBase sqlAliasBase) {
|
||||
return new TableReference(
|
||||
getTableName(),
|
||||
|
@ -1472,14 +1491,13 @@ public abstract class AbstractEntityPersister
|
|||
protected Predicate generateJoinPredicate(
|
||||
TableReference rootTableReference,
|
||||
TableReference joinedTableReference,
|
||||
int subClassTablePosition,
|
||||
String[] fkColumnNames,
|
||||
SqlExpressionResolver sqlExpressionResolver) {
|
||||
final EntityIdentifierMapping identifierMapping = getIdentifierMapping();
|
||||
|
||||
final Junction conjunction = new Junction( Junction.Nature.CONJUNCTION );
|
||||
|
||||
final String[] rootPkColumnNames = getKeyColumnNames();
|
||||
final String[] fkColumnNames = getSubclassTableKeyColumns( subClassTablePosition );
|
||||
|
||||
assert rootPkColumnNames.length == fkColumnNames.length;
|
||||
assert rootPkColumnNames.length == identifierMapping.getJdbcTypeCount();
|
||||
|
@ -1523,6 +1541,19 @@ public abstract class AbstractEntityPersister
|
|||
return conjunction;
|
||||
}
|
||||
|
||||
protected Predicate generateJoinPredicate(
|
||||
TableReference rootTableReference,
|
||||
TableReference joinedTableReference,
|
||||
int subClassTablePosition,
|
||||
SqlExpressionResolver sqlExpressionResolver) {
|
||||
return generateJoinPredicate(
|
||||
rootTableReference,
|
||||
joinedTableReference,
|
||||
getSubclassTableKeyColumns( subClassTablePosition ),
|
||||
sqlExpressionResolver
|
||||
);
|
||||
}
|
||||
|
||||
public Object initializeLazyProperty(String fieldName, Object entity, SharedSessionContractImplementor session) {
|
||||
final PersistenceContext persistenceContext = session.getPersistenceContextInternal();
|
||||
final EntityEntry entry = persistenceContext.getEntry( entity );
|
||||
|
@ -6393,8 +6424,11 @@ public abstract class AbstractEntityPersister
|
|||
Property bootProperty,
|
||||
int stateArrayPosition,
|
||||
MappingModelCreationProcess creationProcess) {
|
||||
|
||||
final SessionFactoryImplementor sessionFactory = creationProcess.getCreationContext().getSessionFactory();
|
||||
final TypeConfiguration typeConfiguration = sessionFactory.getTypeConfiguration();
|
||||
final JdbcServices jdbcServices = sessionFactory.getJdbcServices();
|
||||
final JdbcEnvironment jdbcEnvironment = jdbcServices.getJdbcEnvironment();
|
||||
final Dialect dialect = jdbcEnvironment.getDialect();
|
||||
|
||||
final String attrName = tupleAttrDefinition.getName();
|
||||
final Type attrType = tupleAttrDefinition.getType();
|
||||
|
@ -6452,7 +6486,7 @@ public abstract class AbstractEntityPersister
|
|||
|
||||
assert attrColumnExpression.equals( selectable.getText( sessionFactory.getDialect() ) );
|
||||
|
||||
customReadExpr = selectable.getCustomReadExpression();
|
||||
customReadExpr = selectable.getTemplate( dialect, sessionFactory.getQueryEngine().getSqmFunctionRegistry() );
|
||||
customWriteExpr = selectable.getCustomWriteExpression();
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -3922,6 +3922,12 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
|
|||
|
||||
try {
|
||||
queryExpressionContext.accept( this );
|
||||
|
||||
final List<SqmSelection> selections = subQuery.getQuerySpec().getSelectClause().getSelections();
|
||||
if ( selections.size() == 1 ) {
|
||||
subQuery.applyInferableType( selections.get( 0 ).getNodeType() );
|
||||
}
|
||||
|
||||
return subQuery;
|
||||
}
|
||||
finally {
|
||||
|
|
|
@ -136,8 +136,13 @@ public class QueryParameterBindingsImpl implements QueryParameterBindings {
|
|||
|
||||
@Override
|
||||
public <P> QueryParameterBinding<P> getBinding(String name) {
|
||||
final QueryParameterImplementor<?> parameter = parameterMetadata.getQueryParameter( name );
|
||||
if ( parameter == null ) {
|
||||
throw new IllegalArgumentException( "Parameter does not exist: " + name );
|
||||
}
|
||||
|
||||
//noinspection unchecked
|
||||
return (QueryParameterBinding<P>) getBinding( parameterMetadata.getQueryParameter( name ) );
|
||||
return (QueryParameterBinding<P>) getBinding( parameter );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.hibernate.HibernateException;
|
|||
import org.hibernate.LockMode;
|
||||
import org.hibernate.LockOptions;
|
||||
import org.hibernate.NotYetImplementedFor6Exception;
|
||||
import org.hibernate.QueryException;
|
||||
import org.hibernate.boot.model.process.internal.InferredBasicValueResolver;
|
||||
import org.hibernate.dialect.function.TimestampaddFunction;
|
||||
import org.hibernate.dialect.function.TimestampdiffFunction;
|
||||
|
@ -54,6 +55,7 @@ import org.hibernate.metamodel.mapping.MappingModelExpressable;
|
|||
import org.hibernate.metamodel.mapping.ModelPart;
|
||||
import org.hibernate.metamodel.mapping.ModelPartContainer;
|
||||
import org.hibernate.metamodel.mapping.PluralAttributeMapping;
|
||||
import org.hibernate.metamodel.mapping.SelectionMapping;
|
||||
import org.hibernate.metamodel.mapping.internal.EmbeddedCollectionPart;
|
||||
import org.hibernate.metamodel.mapping.internal.EntityCollectionPart;
|
||||
import org.hibernate.metamodel.mapping.ordering.OrderByFragment;
|
||||
|
@ -524,8 +526,11 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
|||
public UpdateStatement visitUpdateStatement(SqmUpdateStatement sqmStatement) {
|
||||
Map<String, CteStatement> cteStatements = this.visitCteContainer( sqmStatement );
|
||||
|
||||
final String entityName = sqmStatement.getTarget().getEntityName();
|
||||
final EntityPersister entityDescriptor = getCreationContext().getDomainModel()
|
||||
final SqmRoot<?> sqmTarget = sqmStatement.getTarget();
|
||||
final String entityName = sqmTarget.getEntityName();
|
||||
|
||||
final EntityPersister entityDescriptor = getCreationContext()
|
||||
.getDomainModel()
|
||||
.getEntityDescriptor( entityName );
|
||||
assert entityDescriptor != null;
|
||||
|
||||
|
@ -538,7 +543,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
|||
);
|
||||
|
||||
try {
|
||||
final NavigablePath rootPath = sqmStatement.getTarget().getNavigablePath();
|
||||
final NavigablePath rootPath = sqmTarget.getNavigablePath();
|
||||
final TableGroup rootTableGroup = entityDescriptor.createRootTableGroup(
|
||||
rootPath,
|
||||
sqmStatement.getRoot().getAlias(),
|
||||
|
@ -549,12 +554,22 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
|||
getCreationContext()
|
||||
);
|
||||
|
||||
if ( !rootTableGroup.getTableReferenceJoins().isEmpty() ) {
|
||||
throw new HibernateException( "Not expecting multiple table references for an SQM DELETE" );
|
||||
if ( ! rootTableGroup.getTableReferenceJoins().isEmpty() ) {
|
||||
throw new HibernateException( "Not expecting multiple table references for an SQM UPDATE" );
|
||||
}
|
||||
|
||||
if ( sqmTarget.hasJoins() ) {
|
||||
throw new HibernateException( "SQM UPDATE does not support explicit joins" );
|
||||
}
|
||||
|
||||
getFromClauseAccess().registerTableGroup( rootPath, rootTableGroup );
|
||||
|
||||
// however, implicit joins are "ok" so long as they are embeddable-valued
|
||||
applyManipulationImplicitJoins(
|
||||
sqmTarget,
|
||||
rootTableGroup
|
||||
);
|
||||
|
||||
final List<Assignment> assignments = visitSetClause( sqmStatement.getSetClause() );
|
||||
|
||||
final FilterPredicate filterPredicate = FilterHelper.createFilterPredicate(
|
||||
|
@ -590,6 +605,25 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
|||
}
|
||||
}
|
||||
|
||||
private void applyManipulationImplicitJoins(SqmPath<?> sqmPath, TableGroup correspondingTableGroup) {
|
||||
consumeImplicitJoins(
|
||||
sqmPath,
|
||||
correspondingTableGroup,
|
||||
BaseSqmToSqlAstConverter::verifyManipulationImplicitJoin
|
||||
);
|
||||
}
|
||||
|
||||
private static void verifyManipulationImplicitJoin(SqmPath<?> joinedPath) {
|
||||
//noinspection StatementWithEmptyBody
|
||||
if ( joinedPath instanceof SqmEmbeddedValuedSimplePath<?> ) {
|
||||
// this is fine
|
||||
}
|
||||
else {
|
||||
// otherwise...
|
||||
throw new QueryException( "Manipulation query may only contain embeddable joins" );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Assignment> visitSetClause(SqmSetClause setClause) {
|
||||
final List<Assignment> assignments = new ArrayList<>( setClause.getAssignments().size() );
|
||||
|
@ -601,18 +635,16 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
|||
new SqlAstProcessingStateImpl(
|
||||
getCurrentProcessingState(),
|
||||
this,
|
||||
getCurrentClauseStack()::getCurrent
|
||||
) {
|
||||
getCurrentClauseStack()::getCurrent) {
|
||||
@Override
|
||||
public Expression resolveSqlExpression(
|
||||
String key,
|
||||
Function<SqlAstProcessingState, Expression> creator) {
|
||||
final Expression expression = getParentState().getSqlExpressionResolver()
|
||||
final Expression expression = getParentState()
|
||||
.getSqlExpressionResolver()
|
||||
.resolveSqlExpression( key, creator );
|
||||
assert expression instanceof ColumnReference;
|
||||
|
||||
targetColumnReferences.add( (ColumnReference) expression );
|
||||
|
||||
return expression;
|
||||
}
|
||||
},
|
||||
|
@ -634,18 +666,16 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
|||
new SqlAstProcessingStateImpl(
|
||||
getCurrentProcessingState(),
|
||||
this,
|
||||
getCurrentClauseStack()::getCurrent
|
||||
) {
|
||||
getCurrentClauseStack()::getCurrent) {
|
||||
@Override
|
||||
public Expression resolveSqlExpression(
|
||||
String key,
|
||||
Function<SqlAstProcessingState, Expression> creator) {
|
||||
final Expression expression = getParentState().getSqlExpressionResolver()
|
||||
final Expression expression = getParentState()
|
||||
.getSqlExpressionResolver()
|
||||
.resolveSqlExpression( key, creator );
|
||||
assert expression instanceof ColumnReference;
|
||||
|
||||
valueColumnReferences.add( (ColumnReference) expression );
|
||||
|
||||
return expression;
|
||||
}
|
||||
},
|
||||
|
@ -655,31 +685,18 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
|||
try {
|
||||
|
||||
if ( sqmAssignment.getValue() instanceof SqmParameter ) {
|
||||
final SqmParameter sqmParameter = (SqmParameter) sqmAssignment.getValue();
|
||||
final List<JdbcParameter> jdbcParametersForSqm = new ArrayList<>();
|
||||
final SqmParameter<?> sqmParameter = (SqmParameter<?>) sqmAssignment.getValue();
|
||||
|
||||
// create one JdbcParameter for each column in the assigned path
|
||||
assignedPathInterpretation.getExpressionType().forEachSelection(
|
||||
(columnIndex, selection) -> {
|
||||
final JdbcParameter jdbcParameter = new JdbcParameterImpl( selection.getJdbcMapping() );
|
||||
jdbcParametersForSqm.add( jdbcParameter );
|
||||
assignments.add(
|
||||
consumeSqmParameter(
|
||||
sqmParameter,
|
||||
(index, jdbcParameter) -> assignments.add(
|
||||
new Assignment(
|
||||
new ColumnReference(
|
||||
// we do not want a qualifier (table alias) here
|
||||
(String) null,
|
||||
selection,
|
||||
getCreationContext().getSessionFactory()
|
||||
),
|
||||
targetColumnReferences.get( index ),
|
||||
jdbcParameter
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
getJdbcParamsBySqmParam().computeIfAbsent( sqmParameter, k -> new ArrayList<>( 1 ) )
|
||||
.add( jdbcParametersForSqm );
|
||||
}
|
||||
else {
|
||||
final Expression valueExpression = (Expression) sqmAssignment.getValue().accept( this );
|
||||
|
||||
|
@ -1850,6 +1867,17 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
|||
}
|
||||
|
||||
private void consumeImplicitJoins(SqmPath<?> sqmPath, TableGroup tableGroup) {
|
||||
consumeImplicitJoins(
|
||||
sqmPath,
|
||||
tableGroup,
|
||||
(sqmSubPath) -> {}
|
||||
);
|
||||
}
|
||||
|
||||
private void consumeImplicitJoins(
|
||||
SqmPath<?> sqmPath,
|
||||
TableGroup tableGroup,
|
||||
Consumer<SqmPath<?>> implicitJoinChecker) {
|
||||
if ( log.isTraceEnabled() ) {
|
||||
log.tracef( "Visiting implicit joins for `%s`", sqmPath.getNavigablePath() );
|
||||
}
|
||||
|
@ -1859,6 +1887,9 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
|||
if ( log.isTraceEnabled() ) {
|
||||
log.tracef( "Starting implicit join handling for `%s`", joinedPath.getNavigablePath() );
|
||||
}
|
||||
|
||||
implicitJoinChecker.accept( joinedPath );
|
||||
|
||||
final FromClauseIndex fromClauseIndex = getFromClauseIndex();
|
||||
assert fromClauseIndex.findTableGroup( joinedPath.getLhs().getNavigablePath() ) == tableGroup;
|
||||
|
||||
|
@ -1882,7 +1913,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
|||
|
||||
fromClauseIndex.register( joinedPath, tableGroupJoin.getJoinedGroup() );
|
||||
|
||||
consumeImplicitJoins( joinedPath, tableGroupJoin.getJoinedGroup() );
|
||||
consumeImplicitJoins( joinedPath, tableGroupJoin.getJoinedGroup(), implicitJoinChecker );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -2146,8 +2177,42 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
|||
}
|
||||
|
||||
|
||||
protected Expression consumeSqmParameter(
|
||||
SqmParameter sqmParameter,
|
||||
BiConsumer<Integer,JdbcParameter> jdbcParameterConsumer) {
|
||||
final MappingModelExpressable valueMapping = determineValueMapping( sqmParameter );
|
||||
|
||||
final List<JdbcParameter> jdbcParametersForSqm = new ArrayList<>();
|
||||
|
||||
resolveSqmParameter(
|
||||
sqmParameter,
|
||||
valueMapping,
|
||||
(index,jdbcParameter) -> {
|
||||
jdbcParameterConsumer.accept( index, jdbcParameter );
|
||||
jdbcParametersForSqm.add( jdbcParameter );
|
||||
}
|
||||
);
|
||||
|
||||
this.jdbcParameters.addParameters( jdbcParametersForSqm );
|
||||
this.jdbcParamsBySqmParam
|
||||
.computeIfAbsent( sqmParameter, k -> new ArrayList<>( 1 ) )
|
||||
.add( jdbcParametersForSqm );
|
||||
|
||||
final QueryParameterImplementor<?> queryParameter = domainParameterXref.getQueryParameter( sqmParameter );
|
||||
final QueryParameterBinding<?> binding = domainParameterBindings.getBinding( queryParameter );
|
||||
binding.setType( valueMapping );
|
||||
return new SqmParameterInterpretation(
|
||||
sqmParameter,
|
||||
queryParameter,
|
||||
jdbcParametersForSqm,
|
||||
valueMapping,
|
||||
qp -> binding
|
||||
);
|
||||
}
|
||||
|
||||
protected Expression consumeSqmParameter(SqmParameter sqmParameter) {
|
||||
final MappingModelExpressable valueMapping = determineValueMapping( sqmParameter );
|
||||
|
||||
final List<JdbcParameter> jdbcParametersForSqm = new ArrayList<>();
|
||||
|
||||
resolveSqmParameter(
|
||||
|
@ -2157,7 +2222,8 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
|||
);
|
||||
|
||||
this.jdbcParameters.addParameters( jdbcParametersForSqm );
|
||||
this.jdbcParamsBySqmParam.computeIfAbsent( sqmParameter, k -> new ArrayList<>( 1 ) )
|
||||
this.jdbcParamsBySqmParam
|
||||
.computeIfAbsent( sqmParameter, k -> new ArrayList<>( 1 ) )
|
||||
.add( jdbcParametersForSqm );
|
||||
|
||||
final QueryParameterImplementor<?> queryParameter = domainParameterXref.getQueryParameter( sqmParameter );
|
||||
|
@ -2329,15 +2395,15 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
|
|||
private void resolveSqmParameter(
|
||||
SqmParameter expression,
|
||||
MappingModelExpressable valueMapping,
|
||||
Consumer<JdbcParameter> jdbcParameterConsumer) {
|
||||
BiConsumer<Integer,JdbcParameter> jdbcParameterConsumer) {
|
||||
if ( valueMapping instanceof Association ) {
|
||||
( (Association) valueMapping ).getForeignKeyDescriptor().forEachJdbcType(
|
||||
(index, jdbcMapping) -> jdbcParameterConsumer.accept( new JdbcParameterImpl( jdbcMapping ) )
|
||||
(index, jdbcMapping) -> jdbcParameterConsumer.accept( index, new JdbcParameterImpl( jdbcMapping ) )
|
||||
);
|
||||
}
|
||||
else {
|
||||
valueMapping.forEachJdbcType(
|
||||
(index, jdbcMapping) -> jdbcParameterConsumer.accept( new JdbcParameterImpl( jdbcMapping ) )
|
||||
(index, jdbcMapping) -> jdbcParameterConsumer.accept( index, new JdbcParameterImpl( jdbcMapping ) )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -327,8 +327,8 @@ public class SqmSubQuery<T> extends AbstractSqmSelectQuery<T> implements SqmSele
|
|||
@Override
|
||||
public void applyInferableType(SqmExpressable<?> type) {
|
||||
//noinspection unchecked
|
||||
// this.expressableType = (SqmExpressable) type;
|
||||
// setResultType( type == null ? null : type.getExpressableJavaTypeDescriptor().getJavaType() );
|
||||
this.expressableType = (SqmExpressable<T>) type;
|
||||
setResultType( type == null ? null : expressableType.getExpressableJavaTypeDescriptor().getJavaTypeClass() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -45,6 +45,9 @@ public interface SqlExpressionResolver {
|
|||
* @see #resolveSqlExpression
|
||||
*/
|
||||
static String createColumnReferenceKey(TableReference tableReference, String columnExpression) {
|
||||
assert tableReference != null : "tableReference expected to be non-null";
|
||||
assert columnExpression != null : "columnExpression expected to be non-null";
|
||||
|
||||
final String qualifier = tableReference.getIdentificationVariable() == null
|
||||
? tableReference.getTableExpression()
|
||||
: tableReference.getIdentificationVariable();
|
||||
|
|
|
@ -75,23 +75,23 @@ public class ColumnReference implements Expression, Assignable {
|
|||
if ( isFormula ) {
|
||||
this.readExpression = this.columnExpression;
|
||||
}
|
||||
else if ( customReadExpression == null ) {
|
||||
else if ( customReadExpression != null ) {
|
||||
this.readExpression = StringHelper.replace( customReadExpression, Template.TEMPLATE, qualifier );
|
||||
}
|
||||
else {
|
||||
this.readExpression = this.qualifier == null
|
||||
? this.columnExpression
|
||||
: this.qualifier + "." + this.columnExpression;
|
||||
}
|
||||
else {
|
||||
this.readExpression = customReadExpression;
|
||||
}
|
||||
|
||||
if ( isFormula ) {
|
||||
this.writeExpression = null;
|
||||
}
|
||||
else if ( customWriteExpression == null ) {
|
||||
this.writeExpression = DEFAULT_COLUMN_WRITE_EXPRESSION;
|
||||
else if ( customWriteExpression != null ) {
|
||||
this.writeExpression = StringHelper.replace( customWriteExpression, Template.TEMPLATE, qualifier );
|
||||
}
|
||||
else {
|
||||
this.writeExpression = customWriteExpression;
|
||||
this.writeExpression = DEFAULT_COLUMN_WRITE_EXPRESSION;
|
||||
}
|
||||
|
||||
this.jdbcMapping = jdbcMapping;
|
||||
|
|
|
@ -55,7 +55,7 @@ public class ResultsHelper {
|
|||
if ( existing != null ) {
|
||||
if ( fetchedModelPart.getNavigableRole().equals(
|
||||
existing.getInitializedPart().getNavigableRole() ) ) {
|
||||
ResultsLogger.LOGGER.debugf(
|
||||
ResultsLogger.LOGGER.tracef(
|
||||
"Returning previously-registered initializer : %s",
|
||||
existing
|
||||
);
|
||||
|
@ -64,7 +64,7 @@ public class ResultsHelper {
|
|||
}
|
||||
|
||||
final Initializer initializer = producer.get();
|
||||
ResultsLogger.LOGGER.debugf(
|
||||
ResultsLogger.LOGGER.tracef(
|
||||
"Registering initializer : %s",
|
||||
initializer
|
||||
);
|
||||
|
|
|
@ -11,6 +11,7 @@ import java.util.Collections;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.boot.Metadata;
|
||||
import org.hibernate.boot.model.naming.Identifier;
|
||||
import org.hibernate.boot.model.relational.InitCommand;
|
||||
|
@ -42,6 +43,8 @@ public class StandardTableExporter implements Exporter<Table> {
|
|||
table.getNameIdentifier()
|
||||
);
|
||||
|
||||
try {
|
||||
|
||||
final JdbcEnvironment jdbcEnvironment = metadata.getDatabase().getJdbcEnvironment();
|
||||
StringBuilder buf =
|
||||
new StringBuilder( tableCreateString( table.hasPrimaryKey() ) )
|
||||
|
@ -90,7 +93,8 @@ public class StandardTableExporter implements Exporter<Table> {
|
|||
buf.append( col.getSqlType( dialect, metadata ) );
|
||||
}
|
||||
buf.append( ' ' )
|
||||
.append( dialect.getIdentityColumnSupport().getIdentityColumnString( col.getSqlTypeCode( metadata ) ) );
|
||||
.append( dialect.getIdentityColumnSupport()
|
||||
.getIdentityColumnString( col.getSqlTypeCode( metadata ) ) );
|
||||
}
|
||||
else {
|
||||
buf.append( col.getSqlType( dialect, metadata ) );
|
||||
|
@ -155,6 +159,10 @@ public class StandardTableExporter implements Exporter<Table> {
|
|||
|
||||
return sqlStrings.toArray( new String[ sqlStrings.size() ] );
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new MappingException( "Error creating SQL create commands for table : " + tableName, e );
|
||||
}
|
||||
}
|
||||
|
||||
protected void applyComments(Table table, QualifiedName tableName, List<String> sqlStrings) {
|
||||
if ( dialect.supportsCommentOn() ) {
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.type;
|
||||
|
||||
import org.hibernate.metamodel.model.convert.spi.BasicValueConverter;
|
||||
|
||||
/**
|
||||
* Extension for BasicType impls which have an implied conversion
|
||||
*/
|
||||
public interface ConvertedBasicType<J> extends BasicType<J> {
|
||||
BasicValueConverter<J,?> getValueConverter();
|
||||
}
|
|
@ -9,8 +9,11 @@ package org.hibernate.type;
|
|||
import java.io.Serializable;
|
||||
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.metamodel.model.convert.spi.BasicValueConverter;
|
||||
import org.hibernate.query.CastType;
|
||||
import org.hibernate.type.descriptor.java.BooleanTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.java.CharacterTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.sql.CharTypeDescriptor;
|
||||
|
||||
/**
|
||||
|
@ -21,29 +24,35 @@ import org.hibernate.type.descriptor.sql.CharTypeDescriptor;
|
|||
*/
|
||||
public class TrueFalseType
|
||||
extends AbstractSingleColumnStandardBasicType<Boolean>
|
||||
implements PrimitiveType<Boolean>, DiscriminatorType<Boolean> {
|
||||
implements PrimitiveType<Boolean>, DiscriminatorType<Boolean>, ConvertedBasicType<Boolean> {
|
||||
|
||||
public static final TrueFalseType INSTANCE = new TrueFalseType();
|
||||
private static final TrueFalseConverter CONVERTER = new TrueFalseConverter();
|
||||
|
||||
public TrueFalseType() {
|
||||
super( CharTypeDescriptor.INSTANCE, new BooleanTypeDescriptor( 'T', 'F' ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "true_false";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getPrimitiveClass() {
|
||||
return boolean.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean stringToObject(String xml) throws Exception {
|
||||
return fromString( xml );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Serializable getDefaultValue() {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String objectToSQLString(Boolean value, Dialect dialect) throws Exception {
|
||||
return StringType.INSTANCE.objectToSQLString( value ? "T" : "F", dialect );
|
||||
|
@ -53,4 +62,47 @@ public class TrueFalseType
|
|||
public CastType getCastType() {
|
||||
return CastType.TF_BOOLEAN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasicValueConverter<Boolean, ?> getValueConverter() {
|
||||
return CONVERTER;
|
||||
}
|
||||
|
||||
private static class TrueFalseConverter implements BasicValueConverter<Boolean, Character> {
|
||||
@Override
|
||||
public Boolean toDomainValue(Character relationalForm) {
|
||||
if ( relationalForm == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ( 'T' == relationalForm ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( 'F' == relationalForm ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Character toRelationalValue(Boolean domainForm) {
|
||||
if ( domainForm == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return domainForm ? 'T' : 'F';
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaTypeDescriptor<Boolean> getDomainJavaDescriptor() {
|
||||
return BooleanTypeDescriptor.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaTypeDescriptor<Character> getRelationalJavaDescriptor() {
|
||||
return CharacterTypeDescriptor.INSTANCE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,8 +9,11 @@ package org.hibernate.type;
|
|||
import java.io.Serializable;
|
||||
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.metamodel.model.convert.spi.BasicValueConverter;
|
||||
import org.hibernate.query.CastType;
|
||||
import org.hibernate.type.descriptor.java.BooleanTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.java.CharacterTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
import org.hibernate.type.descriptor.sql.CharTypeDescriptor;
|
||||
|
||||
/**
|
||||
|
@ -21,29 +24,35 @@ import org.hibernate.type.descriptor.sql.CharTypeDescriptor;
|
|||
*/
|
||||
public class YesNoType
|
||||
extends AbstractSingleColumnStandardBasicType<Boolean>
|
||||
implements PrimitiveType<Boolean>, DiscriminatorType<Boolean> {
|
||||
implements PrimitiveType<Boolean>, DiscriminatorType<Boolean>, ConvertedBasicType<Boolean> {
|
||||
|
||||
public static final YesNoType INSTANCE = new YesNoType();
|
||||
private static final YesNoConverter CONVERTER = new YesNoConverter();
|
||||
|
||||
public YesNoType() {
|
||||
super( CharTypeDescriptor.INSTANCE, BooleanTypeDescriptor.INSTANCE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "yes_no";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getPrimitiveClass() {
|
||||
return boolean.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean stringToObject(String xml) throws Exception {
|
||||
return fromString( xml );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Serializable getDefaultValue() {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String objectToSQLString(Boolean value, Dialect dialect) throws Exception {
|
||||
return StringType.INSTANCE.objectToSQLString( value ? "Y" : "N", dialect );
|
||||
|
@ -53,4 +62,47 @@ public class YesNoType
|
|||
public CastType getCastType() {
|
||||
return CastType.YN_BOOLEAN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BasicValueConverter<Boolean, ?> getValueConverter() {
|
||||
return CONVERTER;
|
||||
}
|
||||
|
||||
private static class YesNoConverter implements BasicValueConverter<Boolean, Character> {
|
||||
@Override
|
||||
public Boolean toDomainValue(Character relationalForm) {
|
||||
if ( relationalForm == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ( 'Y' == relationalForm ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( 'N' == relationalForm ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Character toRelationalValue(Boolean domainForm) {
|
||||
if ( domainForm == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return domainForm ? 'Y' : 'N';
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaTypeDescriptor<Boolean> getDomainJavaDescriptor() {
|
||||
return BooleanTypeDescriptor.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaTypeDescriptor<Character> getRelationalJavaDescriptor() {
|
||||
return CharacterTypeDescriptor.INSTANCE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.type.descriptor;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
public interface JdbcBindingLogging {
|
||||
String NAME = "org.hibernate.orm.jdbc.bind";
|
||||
|
||||
Logger LOGGER = Logger.getLogger( NAME );
|
||||
|
||||
boolean TRACE_ENABLED = LOGGER.isTraceEnabled();
|
||||
boolean DEBUG_ENABLED = LOGGER.isDebugEnabled();
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.type.descriptor;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
public interface JdbcExtractingLogging {
|
||||
String NAME = "org.hibernate.orm.jdbc.extract";
|
||||
|
||||
Logger LOGGER = Logger.getLogger( NAME );
|
||||
|
||||
boolean TRACE_ENABLED = LOGGER.isTraceEnabled();
|
||||
boolean DEBUG_ENABLED = LOGGER.isDebugEnabled();
|
||||
|
||||
}
|
|
@ -10,7 +10,7 @@ import java.sql.CallableStatement;
|
|||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.hibernate.internal.CoreLogging;
|
||||
import org.hibernate.type.descriptor.JdbcBindingLogging;
|
||||
import org.hibernate.type.descriptor.JdbcTypeNameMapper;
|
||||
import org.hibernate.type.descriptor.ValueBinder;
|
||||
import org.hibernate.type.descriptor.WrapperOptions;
|
||||
|
@ -24,8 +24,6 @@ import org.jboss.logging.Logger;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public abstract class BasicBinder<J> implements ValueBinder<J> {
|
||||
private static final Logger log = CoreLogging.logger( BasicBinder.class );
|
||||
|
||||
private static final String BIND_MSG_TEMPLATE = "binding parameter [%s] as [%s] - [%s]";
|
||||
private static final String NULL_BIND_MSG_TEMPLATE = "binding parameter [%s] as [%s] - [null]";
|
||||
|
||||
|
@ -48,8 +46,8 @@ public abstract class BasicBinder<J> implements ValueBinder<J> {
|
|||
@Override
|
||||
public final void bind(PreparedStatement st, J value, int index, WrapperOptions options) throws SQLException {
|
||||
if ( value == null ) {
|
||||
if ( log.isTraceEnabled() ) {
|
||||
log.trace(
|
||||
if ( JdbcBindingLogging.TRACE_ENABLED ) {
|
||||
JdbcBindingLogging.LOGGER.trace(
|
||||
String.format(
|
||||
NULL_BIND_MSG_TEMPLATE,
|
||||
index,
|
||||
|
@ -60,8 +58,8 @@ public abstract class BasicBinder<J> implements ValueBinder<J> {
|
|||
st.setNull( index, sqlDescriptor.getSqlType() );
|
||||
}
|
||||
else {
|
||||
if ( log.isTraceEnabled() ) {
|
||||
log.trace(
|
||||
if ( JdbcBindingLogging.TRACE_ENABLED ) {
|
||||
JdbcBindingLogging.LOGGER.trace(
|
||||
String.format(
|
||||
BIND_MSG_TEMPLATE,
|
||||
index,
|
||||
|
@ -77,8 +75,8 @@ public abstract class BasicBinder<J> implements ValueBinder<J> {
|
|||
@Override
|
||||
public final void bind(CallableStatement st, J value, String name, WrapperOptions options) throws SQLException {
|
||||
if ( value == null ) {
|
||||
if ( log.isTraceEnabled() ) {
|
||||
log.trace(
|
||||
if ( JdbcBindingLogging.TRACE_ENABLED ) {
|
||||
JdbcBindingLogging.LOGGER.trace(
|
||||
String.format(
|
||||
NULL_BIND_MSG_TEMPLATE,
|
||||
name,
|
||||
|
@ -89,8 +87,8 @@ public abstract class BasicBinder<J> implements ValueBinder<J> {
|
|||
st.setNull( name, sqlDescriptor.getSqlType() );
|
||||
}
|
||||
else {
|
||||
if ( log.isTraceEnabled() ) {
|
||||
log.trace(
|
||||
if ( JdbcBindingLogging.TRACE_ENABLED ) {
|
||||
JdbcBindingLogging.LOGGER.trace(
|
||||
String.format(
|
||||
BIND_MSG_TEMPLATE,
|
||||
name,
|
||||
|
|
|
@ -10,22 +10,18 @@ import java.sql.CallableStatement;
|
|||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.hibernate.internal.CoreLogging;
|
||||
import org.hibernate.type.descriptor.JdbcExtractingLogging;
|
||||
import org.hibernate.type.descriptor.JdbcTypeNameMapper;
|
||||
import org.hibernate.type.descriptor.ValueExtractor;
|
||||
import org.hibernate.type.descriptor.WrapperOptions;
|
||||
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
/**
|
||||
* Convenience base implementation of {@link org.hibernate.type.descriptor.ValueExtractor}
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public abstract class BasicExtractor<J> implements ValueExtractor<J> {
|
||||
private static final Logger log = CoreLogging.logger( BasicExtractor.class );
|
||||
|
||||
private final JavaTypeDescriptor<J> javaDescriptor;
|
||||
private final SqlTypeDescriptor sqlDescriptor;
|
||||
|
||||
|
@ -46,8 +42,8 @@ public abstract class BasicExtractor<J> implements ValueExtractor<J> {
|
|||
public J extract(ResultSet rs, int paramIndex, WrapperOptions options) throws SQLException {
|
||||
final J value = doExtract( rs, paramIndex, options );
|
||||
if ( value == null || rs.wasNull() ) {
|
||||
if ( log.isTraceEnabled() ) {
|
||||
log.tracef(
|
||||
if ( JdbcExtractingLogging.TRACE_ENABLED ) {
|
||||
JdbcExtractingLogging.LOGGER.tracef(
|
||||
"extracted value ([%s] : [%s]) - [null]",
|
||||
paramIndex,
|
||||
JdbcTypeNameMapper.getTypeName( getSqlDescriptor().getSqlType() )
|
||||
|
@ -56,8 +52,8 @@ public abstract class BasicExtractor<J> implements ValueExtractor<J> {
|
|||
return null;
|
||||
}
|
||||
else {
|
||||
if ( log.isTraceEnabled() ) {
|
||||
log.tracef(
|
||||
if ( JdbcExtractingLogging.TRACE_ENABLED ) {
|
||||
JdbcExtractingLogging.LOGGER.tracef(
|
||||
"extracted value ([%s] : [%s]) - [%s]",
|
||||
paramIndex,
|
||||
JdbcTypeNameMapper.getTypeName( getSqlDescriptor().getSqlType() ),
|
||||
|
@ -84,8 +80,8 @@ public abstract class BasicExtractor<J> implements ValueExtractor<J> {
|
|||
public J extract(CallableStatement statement, int paramIndex, WrapperOptions options) throws SQLException {
|
||||
final J value = doExtract( statement, paramIndex, options );
|
||||
if ( value == null || statement.wasNull() ) {
|
||||
if ( log.isTraceEnabled() ) {
|
||||
log.tracef(
|
||||
if ( JdbcExtractingLogging.TRACE_ENABLED ) {
|
||||
JdbcExtractingLogging.LOGGER.tracef(
|
||||
"extracted procedure output parameter ([%s] : [%s]) - [null]",
|
||||
paramIndex,
|
||||
JdbcTypeNameMapper.getTypeName( getSqlDescriptor().getSqlType() )
|
||||
|
@ -94,8 +90,8 @@ public abstract class BasicExtractor<J> implements ValueExtractor<J> {
|
|||
return null;
|
||||
}
|
||||
else {
|
||||
if ( log.isTraceEnabled() ) {
|
||||
log.tracef(
|
||||
if ( JdbcExtractingLogging.TRACE_ENABLED ) {
|
||||
JdbcExtractingLogging.LOGGER.tracef(
|
||||
"extracted procedure output parameter ([%s] : [%s]) - [%s]",
|
||||
paramIndex,
|
||||
JdbcTypeNameMapper.getTypeName( getSqlDescriptor().getSqlType() ),
|
||||
|
@ -122,8 +118,8 @@ public abstract class BasicExtractor<J> implements ValueExtractor<J> {
|
|||
public J extract(CallableStatement statement, String paramName, WrapperOptions options) throws SQLException {
|
||||
final J value = doExtract( statement, paramName, options );
|
||||
if ( value == null || statement.wasNull() ) {
|
||||
if ( log.isTraceEnabled() ) {
|
||||
log.tracef(
|
||||
if ( JdbcExtractingLogging.TRACE_ENABLED ) {
|
||||
JdbcExtractingLogging.LOGGER.tracef(
|
||||
"extracted named procedure output parameter ([%s] : [%s]) - [null]",
|
||||
paramName,
|
||||
JdbcTypeNameMapper.getTypeName( getSqlDescriptor().getSqlType() )
|
||||
|
@ -132,8 +128,8 @@ public abstract class BasicExtractor<J> implements ValueExtractor<J> {
|
|||
return null;
|
||||
}
|
||||
else {
|
||||
if ( log.isTraceEnabled() ) {
|
||||
log.tracef(
|
||||
if ( JdbcExtractingLogging.TRACE_ENABLED ) {
|
||||
JdbcExtractingLogging.LOGGER.tracef(
|
||||
"extracted named procedure output parameter ([%s] : [%s]) - [%s]",
|
||||
paramName,
|
||||
JdbcTypeNameMapper.getTypeName( getSqlDescriptor().getSqlType() ),
|
||||
|
|
|
@ -48,8 +48,12 @@ import org.hibernate.boot.model.relational.Namespace;
|
|||
import org.hibernate.mapping.Column;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||
import org.junit.Test;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.DomainModelScope;
|
||||
import org.hibernate.testing.orm.junit.NotImplementedYet;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
@ -60,115 +64,121 @@ import static org.junit.Assert.fail;
|
|||
* @author Christian Beikov
|
||||
*/
|
||||
@TestForIssue( jiraKey = "HHH-11180" )
|
||||
public class ForeignKeyConstraintTest extends BaseNonConfigCoreFunctionalTestCase {
|
||||
|
||||
@Override
|
||||
protected Class<?>[] getAnnotatedClasses() {
|
||||
return new Class<?>[] {
|
||||
CreditCard.class,
|
||||
Person.class,
|
||||
Student.class,
|
||||
Professor.class,
|
||||
Vehicle.class,
|
||||
VehicleBuyInfo.class,
|
||||
Car.class,
|
||||
Truck.class,
|
||||
Company.class,
|
||||
PlanItem.class,
|
||||
Task.class
|
||||
};
|
||||
@DomainModel(
|
||||
annotatedClasses = {
|
||||
ForeignKeyConstraintTest.CreditCard.class,
|
||||
ForeignKeyConstraintTest.Person.class,
|
||||
ForeignKeyConstraintTest.Student.class,
|
||||
ForeignKeyConstraintTest.Professor.class,
|
||||
ForeignKeyConstraintTest.Vehicle.class,
|
||||
ForeignKeyConstraintTest.VehicleBuyInfo.class,
|
||||
ForeignKeyConstraintTest.Car.class,
|
||||
ForeignKeyConstraintTest.Truck.class,
|
||||
ForeignKeyConstraintTest.Company.class,
|
||||
ForeignKeyConstraintTest.PlanItem.class,
|
||||
ForeignKeyConstraintTest.Task.class
|
||||
}
|
||||
)
|
||||
@SessionFactory
|
||||
public class ForeignKeyConstraintTest {
|
||||
@Test
|
||||
public void testJoinColumn(DomainModelScope scope) {
|
||||
assertForeignKey( scope, "FK_CAR_OWNER", "OWNER_PERSON_ID" );
|
||||
assertForeignKey( scope, "FK_CAR_OWNER3", "OWNER_PERSON_ID3" );
|
||||
assertForeignKey( scope, "FK_PERSON_CC", "PERSON_CC_ID" );
|
||||
assertNoForeignKey( scope, "FK_CAR_OWNER2", "OWNER_PERSON_ID2" );
|
||||
assertNoForeignKey( scope, "FK_CAR_OWNER4", "OWNER_PERSON_ID4" );
|
||||
assertNoForeignKey( scope, "FK_PERSON_CC2", "PERSON_CC_ID2" );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJoinColumn() {
|
||||
assertForeignKey( "FK_CAR_OWNER", "OWNER_PERSON_ID" );
|
||||
assertForeignKey( "FK_CAR_OWNER3", "OWNER_PERSON_ID3" );
|
||||
assertForeignKey( "FK_PERSON_CC", "PERSON_CC_ID" );
|
||||
assertNoForeignKey( "FK_CAR_OWNER2", "OWNER_PERSON_ID2" );
|
||||
assertNoForeignKey( "FK_CAR_OWNER4", "OWNER_PERSON_ID4" );
|
||||
assertNoForeignKey( "FK_PERSON_CC2", "PERSON_CC_ID2" );
|
||||
public void testJoinColumns(DomainModelScope scope) {
|
||||
assertForeignKey( scope, "FK_STUDENT_CAR", "CAR_NR", "CAR_VENDOR_NR" );
|
||||
assertForeignKey( scope, "FK_STUDENT_CAR3", "CAR_NR3", "CAR_VENDOR_NR3" );
|
||||
assertNoForeignKey( scope, "FK_STUDENT_CAR2", "CAR_NR2", "CAR_VENDOR_NR2" );
|
||||
assertNoForeignKey( scope, "FK_STUDENT_CAR4", "CAR_NR4", "CAR_VENDOR_NR4" );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJoinColumns() {
|
||||
assertForeignKey( "FK_STUDENT_CAR", "CAR_NR", "CAR_VENDOR_NR" );
|
||||
assertForeignKey( "FK_STUDENT_CAR3", "CAR_NR3", "CAR_VENDOR_NR3" );
|
||||
assertNoForeignKey( "FK_STUDENT_CAR2", "CAR_NR2", "CAR_VENDOR_NR2" );
|
||||
assertNoForeignKey( "FK_STUDENT_CAR4", "CAR_NR4", "CAR_VENDOR_NR4" );
|
||||
public void testJoinTable(DomainModelScope scope) {
|
||||
assertForeignKey( scope, "FK_VEHICLE_BUY_INFOS_STUDENT", "STUDENT_ID" );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJoinTable() {
|
||||
assertForeignKey( "FK_VEHICLE_BUY_INFOS_STUDENT", "STUDENT_ID" );
|
||||
public void testJoinTableInverse(DomainModelScope scope) {
|
||||
assertForeignKey( scope, "FK_VEHICLE_BUY_INFOS_VEHICLE_BUY_INFO", "VEHICLE_BUY_INFO_ID" );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJoinTableInverse() {
|
||||
assertForeignKey( "FK_VEHICLE_BUY_INFOS_VEHICLE_BUY_INFO", "VEHICLE_BUY_INFO_ID" );
|
||||
public void testPrimaryKeyJoinColumn(DomainModelScope scope) {
|
||||
assertForeignKey( scope, "FK_STUDENT_PERSON", "PERSON_ID" );
|
||||
assertNoForeignKey( scope, "FK_PROFESSOR_PERSON", "PERSON_ID" );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPrimaryKeyJoinColumn() {
|
||||
assertForeignKey( "FK_STUDENT_PERSON", "PERSON_ID" );
|
||||
assertNoForeignKey( "FK_PROFESSOR_PERSON", "PERSON_ID" );
|
||||
public void testPrimaryKeyJoinColumns(DomainModelScope scope) {
|
||||
assertForeignKey( scope, "FK_CAR_VEHICLE", "CAR_NR", "VENDOR_NR" );
|
||||
assertNoForeignKey( scope, "FK_TRUCK_VEHICLE", "CAR_NR", "VENDOR_NR" );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPrimaryKeyJoinColumns() {
|
||||
assertForeignKey( "FK_CAR_VEHICLE", "CAR_NR", "VENDOR_NR" );
|
||||
assertNoForeignKey( "FK_TRUCK_VEHICLE", "CAR_NR", "VENDOR_NR" );
|
||||
public void testCollectionTable(DomainModelScope scope) {
|
||||
assertForeignKey( scope, "FK_OWNER_INFO_CAR", "CAR_NR", "VENDOR_NR" );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCollectionTable() {
|
||||
assertForeignKey( "FK_OWNER_INFO_CAR", "CAR_NR", "VENDOR_NR" );
|
||||
public void testMapKeyJoinColumn(DomainModelScope scope) {
|
||||
assertForeignKey( scope, "FK_OWNER_INFO_PERSON", "PERSON_ID" );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMapKeyJoinColumn() {
|
||||
assertForeignKey( "FK_OWNER_INFO_PERSON", "PERSON_ID" );
|
||||
public void testMapKeyJoinColumns(DomainModelScope scope) {
|
||||
assertForeignKey( scope, "FK_VEHICLE_BUY_INFOS_VEHICLE", "VEHICLE_NR", "VEHICLE_VENDOR_NR" );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMapKeyJoinColumns() {
|
||||
assertForeignKey( "FK_VEHICLE_BUY_INFOS_VEHICLE", "VEHICLE_NR", "VEHICLE_VENDOR_NR" );
|
||||
public void testMapForeignKeyJoinColumnCollection(DomainModelScope scope) {
|
||||
assertForeignKey( scope, "FK_PROPERTIES_TASK", "task_id" );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMapForeignKeyJoinColumnColection() {
|
||||
assertForeignKey( "FK_PROPERTIES_TASK", "task_id" );
|
||||
public void testMapForeignKeyCollection(DomainModelScope scope) {
|
||||
assertForeignKey( scope, "FK_ATTRIBUTES_TASK", "task_id" );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMapForeignKeyColection() {
|
||||
assertForeignKey( "FK_ATTRIBUTES_TASK", "task_id" );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAssociationOverride() {
|
||||
public void testAssociationOverride(DomainModelScope scope) {
|
||||
// class level association overrides
|
||||
assertForeignKey( "FK_COMPANY_OWNER", "OWNER_PERSON_ID" );
|
||||
assertForeignKey( "FK_COMPANY_CREDIT_CARD", "CREDIT_CARD_ID" );
|
||||
assertForeignKey( "FK_COMPANY_CREDIT_CARD3", "CREDIT_CARD_ID3" );
|
||||
assertNoForeignKey( "FK_COMPANY_OWNER2", "OWNER_PERSON_ID2" );
|
||||
assertNoForeignKey( "FK_COMPANY_CREDIT_CARD2", "CREDIT_CARD_ID2" );
|
||||
assertNoForeignKey( "FK_COMPANY_CREDIT_CARD4", "CREDIT_CARD_ID4" );
|
||||
assertForeignKey( scope, "FK_COMPANY_OWNER", "OWNER_PERSON_ID" );
|
||||
assertForeignKey( scope, "FK_COMPANY_CREDIT_CARD", "CREDIT_CARD_ID" );
|
||||
assertForeignKey( scope, "FK_COMPANY_CREDIT_CARD3", "CREDIT_CARD_ID3" );
|
||||
assertNoForeignKey( scope, "FK_COMPANY_OWNER2", "OWNER_PERSON_ID2" );
|
||||
assertNoForeignKey( scope, "FK_COMPANY_CREDIT_CARD2", "CREDIT_CARD_ID2" );
|
||||
assertNoForeignKey( scope, "FK_COMPANY_CREDIT_CARD4", "CREDIT_CARD_ID4" );
|
||||
|
||||
// embeddable association overrides
|
||||
assertForeignKey( "FK_COMPANY_CARD", "AO_CI_CC_ID" );
|
||||
assertNoForeignKey( "FK_COMPANY_CARD2", "AO_CI_CC_ID2" );
|
||||
assertForeignKey( "FK_COMPANY_CARD3", "AO_CI_CC_ID3" );
|
||||
assertNoForeignKey( "FK_COMPANY_CARD4", "AO_CI_CC_ID4" );
|
||||
assertForeignKey( scope, "FK_COMPANY_CARD", "AO_CI_CC_ID" );
|
||||
assertNoForeignKey( scope, "FK_COMPANY_CARD2", "AO_CI_CC_ID2" );
|
||||
assertForeignKey( scope, "FK_COMPANY_CARD3", "AO_CI_CC_ID3" );
|
||||
assertNoForeignKey( scope, "FK_COMPANY_CARD4", "AO_CI_CC_ID4" );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSecondaryTable() {
|
||||
assertForeignKey( "FK_CAR_DETAILS_CAR", "CAR_NR", "CAR_VENDOR_NR" );
|
||||
public void testSecondaryTable(DomainModelScope scope) {
|
||||
assertForeignKey( scope, "FK_CAR_DETAILS_CAR", "CAR_NR", "CAR_VENDOR_NR" );
|
||||
}
|
||||
|
||||
private void assertForeignKey(String foreignKeyName, String... columns) {
|
||||
@Test
|
||||
@NotImplementedYet( strict = false, reason = "Problem with non-root-entity based FKs" )
|
||||
public void testGet(SessionFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
session -> session.get( Student.class, 1l )
|
||||
);
|
||||
}
|
||||
|
||||
private void assertForeignKey(DomainModelScope scope, String foreignKeyName, String... columns) {
|
||||
Set<String> columnSet = new LinkedHashSet<>( Arrays.asList( columns ) );
|
||||
for ( Namespace namespace : metadata().getDatabase().getNamespaces() ) {
|
||||
for ( Namespace namespace : scope.getDomainModel().getDatabase().getNamespaces() ) {
|
||||
for ( org.hibernate.mapping.Table table : namespace.getTables() ) {
|
||||
Iterator<org.hibernate.mapping.ForeignKey> fkItr = table.getForeignKeyIterator();
|
||||
while ( fkItr.hasNext() ) {
|
||||
|
@ -189,18 +199,8 @@ public class ForeignKeyConstraintTest extends BaseNonConfigCoreFunctionalTestCas
|
|||
fail( "ForeignKey '" + foreignKeyName + "' could not be found!" );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGet(){
|
||||
inTransaction(
|
||||
session -> {
|
||||
session.get( Student.class, 1l );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
private void assertNoForeignKey(String foreignKeyName, String... columns) {
|
||||
Set<String> columnSet = new LinkedHashSet<>( Arrays.asList( columns ) );
|
||||
for ( Namespace namespace : metadata().getDatabase().getNamespaces() ) {
|
||||
private void assertNoForeignKey(DomainModelScope scope, String foreignKeyName, String... columns) {
|
||||
for ( Namespace namespace : scope.getDomainModel().getDatabase().getNamespaces() ) {
|
||||
for ( org.hibernate.mapping.Table table : namespace.getTables() ) {
|
||||
Iterator<org.hibernate.mapping.ForeignKey> fkItr = table.getForeignKeyIterator();
|
||||
while ( fkItr.hasNext() ) {
|
||||
|
@ -324,6 +324,7 @@ public class ForeignKeyConstraintTest extends BaseNonConfigCoreFunctionalTestCas
|
|||
public static class Vehicle {
|
||||
@EmbeddedId
|
||||
public VehicleId id;
|
||||
public String name;
|
||||
}
|
||||
|
||||
@Embeddable
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.metamodel.mapping;
|
||||
package org.hibernate.orm.test.mapping;
|
||||
|
||||
import java.util.Date;
|
||||
import javax.persistence.Column;
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.metamodel.mapping;
|
||||
package org.hibernate.orm.test.mapping;
|
||||
|
||||
import java.sql.Statement;
|
||||
import java.sql.Types;
|
|
@ -1,4 +1,4 @@
|
|||
package org.hibernate.orm.test.metamodel.mapping.array;
|
||||
package org.hibernate.orm.test.mapping.array;
|
||||
|
||||
import java.util.List;
|
||||
import javax.persistence.ElementCollection;
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.metamodel.mapping.cid.aggregated;
|
||||
package org.hibernate.orm.test.mapping.cid.aggregated;
|
||||
|
||||
import java.io.Serializable;
|
||||
import javax.persistence.Column;
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.metamodel.mapping.cid.nonaggregated;
|
||||
package org.hibernate.orm.test.mapping.cid.nonaggregated;
|
||||
|
||||
import java.io.Serializable;
|
||||
import javax.persistence.Column;
|
|
@ -8,4 +8,4 @@
|
|||
/**
|
||||
* Testing support of composite identifier mappings
|
||||
*/
|
||||
package org.hibernate.orm.test.metamodel.mapping.cid;
|
||||
package org.hibernate.orm.test.mapping.cid;
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.metamodel.mapping.collections;
|
||||
package org.hibernate.orm.test.mapping.collections;
|
||||
|
||||
import org.hibernate.Hibernate;
|
||||
import org.hibernate.collection.spi.PersistentCollection;
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.metamodel.mapping.collections;
|
||||
package org.hibernate.orm.test.mapping.collections;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.metamodel.mapping.collections;
|
||||
package org.hibernate.orm.test.mapping.collections;
|
||||
|
||||
import org.hibernate.metamodel.mapping.AttributeMapping;
|
||||
import org.hibernate.metamodel.mapping.EntityMappingType;
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.metamodel.mapping.collections;
|
||||
package org.hibernate.orm.test.mapping.collections;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.hibernate.orm.test.metamodel.mapping.collections;
|
||||
package org.hibernate.orm.test.mapping.collections;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.metamodel.contributed;
|
||||
package org.hibernate.orm.test.mapping.contributed;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Collection;
|
||||
|
@ -245,7 +245,7 @@ public class BasicContributorTests {
|
|||
final ClassLoaderService classLoaderService = buildingContext.getBootstrapContext()
|
||||
.getServiceRegistry()
|
||||
.getService( ClassLoaderService.class );
|
||||
final InputStream inputStream = classLoaderService.locateResourceStream( "org/hibernate/orm/test/metamodel/contributed/BasicContributorTests.hbm.xml" );
|
||||
final InputStream inputStream = classLoaderService.locateResourceStream( "org/hibernate/orm/test/mapping/contributed/BasicContributorTests.hbm.xml" );
|
||||
final Binding<JaxbHbmHibernateMapping> jaxbBinding = mappingBinder.bind( inputStream, origin );
|
||||
final JaxbHbmHibernateMapping jaxbRoot = jaxbBinding.getRoot();
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.metamodel.contributed;
|
||||
package org.hibernate.orm.test.mapping.contributed;
|
||||
|
||||
import org.hibernate.boot.spi.AdditionalJaxbMappingProducer;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
|
@ -12,6 +12,8 @@ import javax.persistence.criteria.Root;
|
|||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.type.descriptor.JdbcBindingLogging;
|
||||
import org.hibernate.type.descriptor.JdbcExtractingLogging;
|
||||
import org.hibernate.type.descriptor.sql.BasicBinder;
|
||||
import org.hibernate.type.descriptor.sql.BasicExtractor;
|
||||
|
||||
|
@ -36,13 +38,13 @@ public class EnumTypeTest extends BaseCoreFunctionalTestCase {
|
|||
@Rule
|
||||
public LoggerInspectionRule binderLogInspection = new LoggerInspectionRule( Logger.getMessageLogger(
|
||||
CoreMessageLogger.class,
|
||||
BasicBinder.class.getName()
|
||||
JdbcBindingLogging.NAME
|
||||
) );
|
||||
|
||||
@Rule
|
||||
public LoggerInspectionRule extractorLogInspection = new LoggerInspectionRule( Logger.getMessageLogger(
|
||||
CoreMessageLogger.class,
|
||||
BasicExtractor.class.getName()
|
||||
JdbcExtractingLogging.NAME
|
||||
) );
|
||||
|
||||
private Person person;
|
||||
|
|
|
@ -12,141 +12,130 @@ import javax.persistence.Enumerated;
|
|||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.type.descriptor.sql.BasicBinder;
|
||||
import org.hibernate.type.descriptor.sql.BasicExtractor;
|
||||
import org.hibernate.type.descriptor.JdbcBindingLogging;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
import org.hibernate.testing.logger.LoggerInspectionRule;
|
||||
import org.hibernate.testing.logger.Triggerable;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.Logger;
|
||||
import org.hibernate.testing.orm.junit.MessageKeyInspection;
|
||||
import org.hibernate.testing.orm.junit.MessageKeyWatcher;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* @author Vlad Mihacea
|
||||
*/
|
||||
public class OrdinalEnumTypeTest extends BaseCoreFunctionalTestCase {
|
||||
|
||||
@Rule
|
||||
public LoggerInspectionRule binderLogInspection = new LoggerInspectionRule( Logger.getMessageLogger(
|
||||
CoreMessageLogger.class,
|
||||
BasicBinder.class.getName()
|
||||
) );
|
||||
|
||||
@Rule
|
||||
public LoggerInspectionRule extractorLogInspection = new LoggerInspectionRule( Logger.getMessageLogger(
|
||||
CoreMessageLogger.class,
|
||||
BasicExtractor.class.getName()
|
||||
) );
|
||||
|
||||
private Person person;
|
||||
|
||||
private Triggerable binderTriggerable;
|
||||
|
||||
private Triggerable extractorTriggerable;
|
||||
|
||||
@Override
|
||||
protected Class<?>[] getAnnotatedClasses() {
|
||||
return new Class[] {
|
||||
Person.class
|
||||
};
|
||||
@MessageKeyInspection(
|
||||
logger = @Logger( loggerName = JdbcBindingLogging.NAME ),
|
||||
messageKey = "binding parameter ["
|
||||
)
|
||||
@DomainModel( annotatedClasses = OrdinalEnumTypeTest.Person.class )
|
||||
@SessionFactory
|
||||
public class OrdinalEnumTypeTest {
|
||||
@BeforeEach
|
||||
protected void createTestData(SessionFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
(session) -> {
|
||||
final Person person = Person.person( Gender.MALE, HairColor.BROWN );
|
||||
session.persist( person );
|
||||
session.persist( Person.person( Gender.MALE, HairColor.BLACK ) );
|
||||
session.persist( Person.person( Gender.FEMALE, HairColor.BROWN ) );
|
||||
session.persist( Person.person( Gender.FEMALE, HairColor.BLACK ) );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void prepareTest() {
|
||||
doInHibernate( this::sessionFactory, s -> {
|
||||
this.person = Person.person( Gender.MALE, HairColor.BROWN );
|
||||
s.persist( person );
|
||||
s.persist( Person.person( Gender.MALE, HairColor.BLACK ) );
|
||||
s.persist( Person.person( Gender.FEMALE, HairColor.BROWN ) );
|
||||
s.persist( Person.person( Gender.FEMALE, HairColor.BLACK ) );
|
||||
} );
|
||||
|
||||
binderTriggerable = binderLogInspection.watchForLogMessages( "binding parameter" );
|
||||
extractorTriggerable = extractorLogInspection.watchForLogMessages( "extracted value" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isCleanupTestDataRequired() {
|
||||
return true;
|
||||
@AfterEach
|
||||
public void dropTestData(SessionFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
(session) -> session.createQuery( "delete Person" ).executeUpdate()
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue(jiraKey = "HHH-12978")
|
||||
public void testEnumAsBindParameterAndExtract() {
|
||||
doInHibernate( this::sessionFactory, s -> {
|
||||
binderTriggerable.reset();
|
||||
extractorTriggerable.reset();
|
||||
public void testEnumAsBindParameterAndExtract(SessionFactoryScope scope, MessageKeyWatcher loggingWatcher) {
|
||||
scope.inTransaction(
|
||||
(session) -> {
|
||||
session.createQuery( "select p.id from Person p where p.id = :id", Long.class )
|
||||
.setParameter( "id", 1 )
|
||||
.list();
|
||||
|
||||
s.createQuery( "select p.id from Person p where p.id = :id", Long.class )
|
||||
.setParameter( "id", person.getId() )
|
||||
.getSingleResult();
|
||||
assertTrue( loggingWatcher.wasTriggered() );
|
||||
}
|
||||
);
|
||||
|
||||
assertTrue( binderTriggerable.wasTriggered() );
|
||||
assertTrue( extractorTriggerable.wasTriggered() );
|
||||
} );
|
||||
loggingWatcher.reset();
|
||||
|
||||
doInHibernate( this::sessionFactory, s -> {
|
||||
binderTriggerable.reset();
|
||||
extractorTriggerable.reset();
|
||||
|
||||
s.createQuery(
|
||||
"select p.gender from Person p where p.gender = :gender and p.hairColor = :hairColor",
|
||||
Gender.class
|
||||
)
|
||||
scope.inTransaction(
|
||||
(session) -> {
|
||||
final String qry = "select p.gender from Person p where p.gender = :gender and p.hairColor = :hairColor";
|
||||
session.createQuery( qry, Gender.class )
|
||||
.setParameter( "gender", Gender.MALE )
|
||||
.setParameter( "hairColor", HairColor.BROWN )
|
||||
.getSingleResult();
|
||||
|
||||
assertTrue( binderTriggerable.wasTriggered() );
|
||||
assertTrue( extractorTriggerable.wasTriggered() );
|
||||
} );
|
||||
assertTrue( loggingWatcher.wasTriggered() );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue(jiraKey = "HHH-10282")
|
||||
public void hqlTestEnumShortHandSyntax() {
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
public void hqlTestEnumShortHandSyntax(SessionFactoryScope scope, MessageKeyWatcher loggingWatcher) {
|
||||
scope.inTransaction(
|
||||
(session) -> {
|
||||
session.createQuery(
|
||||
"select id from Person where originalHairColor = BLONDE")
|
||||
.getResultList();
|
||||
} );
|
||||
|
||||
assertTrue( loggingWatcher.wasTriggered() );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue(jiraKey = "HHH-10282")
|
||||
public void hqlTestEnumQualifiedShortHandSyntax() {
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
session.createQuery(
|
||||
"select id from Person where originalHairColor = HairColor.BLONDE")
|
||||
.getResultList();
|
||||
} );
|
||||
public void hqlTestEnumQualifiedShortHandSyntax(SessionFactoryScope scope, MessageKeyWatcher loggingWatcher) {
|
||||
final String qry = "select id from Person where originalHairColor = HairColor.BLONDE";
|
||||
scope.inTransaction(
|
||||
(session) -> {
|
||||
session.createQuery( qry ).getResultList();
|
||||
|
||||
assertTrue( loggingWatcher.wasTriggered() );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue(jiraKey = "HHH-10282")
|
||||
public void hqlTestEnumShortHandSyntaxInPredicate() {
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
session.createQuery(
|
||||
"select id from Person where originalHairColor in (BLONDE, BROWN)")
|
||||
.getResultList();
|
||||
} );
|
||||
public void hqlTestEnumShortHandSyntaxInPredicate(SessionFactoryScope scope, MessageKeyWatcher loggingWatcher) {
|
||||
scope.inTransaction(
|
||||
(session) -> {
|
||||
final String qry = "select id from Person where originalHairColor in (BLONDE, BROWN)";
|
||||
session.createQuery( qry ).getResultList();
|
||||
|
||||
assertTrue( loggingWatcher.wasTriggered() );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue(jiraKey = "HHH-10282")
|
||||
public void hqlTestEnumQualifiedShortHandSyntaxInPredicate() {
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
session.createQuery(
|
||||
"select id from Person where originalHairColor in (HairColor.BLONDE, HairColor.BROWN)")
|
||||
.getResultList();
|
||||
} );
|
||||
public void hqlTestEnumQualifiedShortHandSyntaxInPredicate(SessionFactoryScope scope, MessageKeyWatcher loggingWatcher) {
|
||||
scope.inTransaction(
|
||||
(session) -> {
|
||||
final String qry = "select id from Person where originalHairColor in (HairColor.BLONDE, HairColor.BROWN)";
|
||||
session.createQuery( qry ).getResultList();
|
||||
|
||||
assertTrue( loggingWatcher.wasTriggered() );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Entity(name = "Person")
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
|
||||
<!--
|
||||
~ Hibernate, Relational Persistence for Idiomatic Java
|
||||
~
|
||||
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
~ See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
-->
|
||||
<!DOCTYPE hibernate-mapping PUBLIC
|
||||
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
|
||||
<hibernate-mapping>
|
||||
|
||||
<class name="org.hibernate.orm.test.mapping.formula.EntityOfFormulas" table="formulas">
|
||||
<id name="id" />
|
||||
<property name="realValue" column="real_value" />
|
||||
<property name="stringFormula" formula="real_value || ' a'" />
|
||||
<property name="integerFormula" formula="real_value + 1" />
|
||||
</class>
|
||||
|
||||
</hibernate-mapping>
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* 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.orm.test.mapping.formula;
|
||||
|
||||
public class EntityOfFormulas {
|
||||
private Integer id;
|
||||
private Integer realValue;
|
||||
private String stringFormula;
|
||||
private Integer integerFormula;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getRealValue() {
|
||||
return realValue;
|
||||
}
|
||||
|
||||
public void setRealValue(Integer realValue) {
|
||||
this.realValue = realValue;
|
||||
}
|
||||
|
||||
public String getStringFormula() {
|
||||
return stringFormula;
|
||||
}
|
||||
|
||||
public void setStringFormula(String stringFormula) {
|
||||
this.stringFormula = stringFormula;
|
||||
}
|
||||
|
||||
public Integer getIntegerFormula() {
|
||||
return integerFormula;
|
||||
}
|
||||
|
||||
public void setIntegerFormula(Integer integerFormula) {
|
||||
this.integerFormula = integerFormula;
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.orm.test.formula;
|
||||
package org.hibernate.orm.test.mapping.formula;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
|
@ -63,6 +63,13 @@ public class FormulaBasicsTest {
|
|||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
void testHqlAmbiguous(SessionFactoryScope scope) {
|
||||
scope.inTransaction( session -> {
|
||||
session.createQuery( "select a, b from Account a, Account b" ).list();
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCriteria(SessionFactoryScope scope) {
|
||||
scope.inTransaction( session -> {
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* 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.orm.test.mapping.formula;
|
||||
|
||||
import java.sql.Types;
|
||||
|
||||
import org.hibernate.mapping.BasicValue;
|
||||
import org.hibernate.mapping.Formula;
|
||||
import org.hibernate.mapping.Property;
|
||||
import org.hibernate.mapping.Selectable;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.DomainModelScope;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||
import org.hibernate.testing.orm.junit.SessionFactoryScope;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@DomainModel( xmlMappings = "org/hibernate/orm/test/mapping/formula/EntityOfFormulas.hbm.xml")
|
||||
@SessionFactory
|
||||
public class FormulaFromHbmTests {
|
||||
@Test
|
||||
public void mappingAssertions(DomainModelScope scope) {
|
||||
scope.withHierarchy(
|
||||
EntityOfFormulas.class,
|
||||
(rootClass) -> {
|
||||
final Property stringFormula = rootClass.getProperty( "stringFormula" );
|
||||
{
|
||||
final int[] sqlTypes = stringFormula.getType().sqlTypes( scope.getDomainModel() );
|
||||
assertThat( sqlTypes.length, is( 1 ) );
|
||||
assertThat( sqlTypes[ 0 ], is( Types.VARCHAR ) );
|
||||
|
||||
final Selectable selectable = ( (BasicValue) stringFormula.getValue() ).getColumn();
|
||||
assertThat( selectable, instanceOf( Formula.class ) );
|
||||
}
|
||||
|
||||
final Property integerFormula = rootClass.getProperty( "integerFormula" );
|
||||
{
|
||||
final int[] sqlTypes = integerFormula.getType().sqlTypes( scope.getDomainModel() );
|
||||
assertThat( sqlTypes.length, is( 1 ) );
|
||||
assertThat( sqlTypes[ 0 ], is( Types.INTEGER ) );
|
||||
|
||||
final Selectable selectable = ( (BasicValue) integerFormula.getValue() ).getColumn();
|
||||
assertThat( selectable, instanceOf( Formula.class ) );
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBasicHqlUse(SessionFactoryScope scope) {
|
||||
scope.inTransaction(
|
||||
(session) -> session.createQuery( "from EntityOfFormulas" ).list()
|
||||
);
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.orm.test.formula;
|
||||
package org.hibernate.orm.test.mapping.formula;
|
||||
|
||||
import java.util.List;
|
||||
import javax.persistence.Entity;
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.metamodel.mapping.formula;
|
||||
package org.hibernate.orm.test.mapping.formula;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.orm.test.formula;
|
||||
package org.hibernate.orm.test.mapping.formula;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.orm.test.formula;
|
||||
package org.hibernate.orm.test.mapping.formula;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.orm.test.formula;
|
||||
package org.hibernate.orm.test.mapping.formula;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.metamodel.mapping.inheritance;
|
||||
package org.hibernate.orm.test.mapping.inheritance;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.metamodel.mapping.inheritance;
|
||||
package org.hibernate.orm.test.mapping.inheritance;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.metamodel.mapping.inheritance;
|
||||
package org.hibernate.orm.test.mapping.inheritance;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.metamodel.mapping.inheritance;
|
||||
package org.hibernate.orm.test.mapping.inheritance;
|
||||
|
||||
import java.util.List;
|
||||
import javax.persistence.DiscriminatorColumn;
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.metamodel.mapping.inheritance.joined;
|
||||
package org.hibernate.orm.test.mapping.inheritance.joined;
|
||||
|
||||
import java.sql.Statement;
|
||||
import java.util.List;
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.metamodel.mapping.inheritance.joined;
|
||||
package org.hibernate.orm.test.mapping.inheritance.joined;
|
||||
|
||||
import java.sql.Statement;
|
||||
import java.util.List;
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.metamodel.mapping.inheritance.joined;
|
||||
package org.hibernate.orm.test.mapping.inheritance.joined;
|
||||
|
||||
import java.sql.Statement;
|
||||
import java.util.List;
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.metamodel.mapping.inheritance.joined;
|
||||
package org.hibernate.orm.test.mapping.inheritance.joined;
|
||||
|
||||
import java.sql.Statement;
|
||||
import java.util.List;
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.metamodel.mapping.inheritance.tableperclass;
|
||||
package org.hibernate.orm.test.mapping.inheritance.tableperclass;
|
||||
|
||||
import java.util.List;
|
||||
import javax.persistence.DiscriminatorColumn;
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.metamodel.mapping.inheritance.tableperclass;
|
||||
package org.hibernate.orm.test.mapping.inheritance.tableperclass;
|
||||
|
||||
import java.util.List;
|
||||
import javax.persistence.Entity;
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.metamodel.mapping.inheritance.tableperclass;
|
||||
package org.hibernate.orm.test.mapping.inheritance.tableperclass;
|
||||
|
||||
import java.util.List;
|
||||
import javax.persistence.Entity;
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.manytomany;
|
||||
package org.hibernate.orm.test.mapping.manytomany;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.manytomany;
|
||||
package org.hibernate.orm.test.mapping.manytomany;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.manytomany;
|
||||
package org.hibernate.orm.test.mapping.manytomany;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.manytoone;
|
||||
package org.hibernate.orm.test.mapping.manytoone;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
|
@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test;
|
|||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hibernate.orm.test.manytoone.ManyToOneBidirectionalCircularityTest.*;
|
||||
import static org.hibernate.orm.test.mapping.manytoone.ManyToOneBidirectionalCircularityTest.*;
|
||||
|
||||
/**
|
||||
* @author Andrea Boriero
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.manytoone;
|
||||
package org.hibernate.orm.test.mapping.manytoone;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
|
@ -19,17 +19,12 @@ import org.junit.jupiter.api.Test;
|
|||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hibernate.orm.test.manytoone.ManyToOneBidirectionalTest.*;
|
||||
import static org.hibernate.orm.test.mapping.manytoone.ManyToOneBidirectionalTest.*;
|
||||
|
||||
/**
|
||||
* @author Andrea Boriero
|
||||
*/
|
||||
@DomainModel(
|
||||
annotatedClasses = {
|
||||
EntityTest.class,
|
||||
EntityTest2.class
|
||||
}
|
||||
)
|
||||
@DomainModel( annotatedClasses = { EntityTest.class, EntityTest2.class } )
|
||||
@SessionFactory(statementInspectorClass = SQLStatementInspector.class)
|
||||
public class ManyToOneBidirectionalTest {
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.metamodel.mapping.manytoone;
|
||||
package org.hibernate.orm.test.mapping.manytoone;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.metamodel.mapping.manytoone;
|
||||
package org.hibernate.orm.test.mapping.manytoone;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.onetomany;
|
||||
package org.hibernate.orm.test.mapping.onetomany;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.onetomany;
|
||||
package org.hibernate.orm.test.mapping.onetomany;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.onetomany;
|
||||
package org.hibernate.orm.test.mapping.onetomany;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.onetomany;
|
||||
package org.hibernate.orm.test.mapping.onetomany;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.onetomany;
|
||||
package org.hibernate.orm.test.mapping.onetomany;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashSet;
|
||||
|
@ -17,9 +17,9 @@ import javax.persistence.ManyToOne;
|
|||
import javax.persistence.OneToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.orm.test.onetomany.OneToManyTest.Card;
|
||||
import org.hibernate.orm.test.onetomany.OneToManyTest.CardField;
|
||||
import org.hibernate.orm.test.onetomany.OneToManyTest.Key;
|
||||
import org.hibernate.orm.test.mapping.onetomany.OneToManyTest.Card;
|
||||
import org.hibernate.orm.test.mapping.onetomany.OneToManyTest.CardField;
|
||||
import org.hibernate.orm.test.mapping.onetomany.OneToManyTest.Key;
|
||||
|
||||
import org.hibernate.testing.jdbc.SQLStatementInspector;
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.metamodel.mapping.onetoone;
|
||||
package org.hibernate.orm.test.mapping.onetoone;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.metamodel.mapping.onetoone;
|
||||
package org.hibernate.orm.test.mapping.onetoone;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.metamodel.mapping.onetoone;
|
||||
package org.hibernate.orm.test.mapping.onetoone;
|
||||
|
||||
import org.hibernate.metamodel.mapping.ForeignKeyDescriptor;
|
||||
import org.hibernate.metamodel.mapping.ModelPart;
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.metamodel.mapping.onetoone;
|
||||
package org.hibernate.orm.test.mapping.onetoone;
|
||||
|
||||
import org.hibernate.metamodel.mapping.ForeignKeyDescriptor;
|
||||
import org.hibernate.metamodel.mapping.ModelPart;
|
|
@ -1,12 +1,12 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
|
||||
//$Id$
|
||||
package org.hibernate.orm.test.onetoone;
|
||||
package org.hibernate.orm.test.mapping.onetoone;
|
||||
|
||||
import org.hibernate.AnnotationException;
|
||||
import org.hibernate.SessionFactory;
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* 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>.
|
||||
* 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.orm.test.onetoone;
|
||||
package org.hibernate.orm.test.mapping.onetoone;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* 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>.
|
||||
* 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.orm.test.onetoone;
|
||||
package org.hibernate.orm.test.mapping.onetoone;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
|
@ -1,17 +1,11 @@
|
|||
/*
|
||||
* 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>.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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.orm.test.onetoone;
|
||||
|
||||
package org.hibernate.orm.test.mapping.onetoone;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.FetchType;
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* 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>.
|
||||
* 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.orm.test.onetoone;
|
||||
package org.hibernate.orm.test.mapping.onetoone;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* 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>.
|
||||
* 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.orm.test.onetoone;
|
||||
package org.hibernate.orm.test.mapping.onetoone;
|
||||
|
||||
import java.util.Map;
|
||||
import javax.persistence.CascadeType;
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* 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>.
|
||||
* 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.orm.test.onetoone;
|
||||
package org.hibernate.orm.test.mapping.onetoone;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.orm.test.onetoone;
|
||||
package org.hibernate.orm.test.mapping.onetoone;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
|
@ -20,14 +20,12 @@ import org.junit.jupiter.api.Test;
|
|||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.hibernate.orm.test.onetoone.ToOneSelfReferenceTest.EntityTest;
|
||||
import static org.hibernate.orm.test.mapping.onetoone.ToOneSelfReferenceTest.EntityTest;
|
||||
|
||||
/**
|
||||
* @author Andrea Boriero
|
||||
*/
|
||||
@DomainModel(annotatedClasses = {
|
||||
EntityTest.class
|
||||
})
|
||||
@DomainModel( annotatedClasses = { EntityTest.class } )
|
||||
@SessionFactory(statementInspectorClass = SQLStatementInspector.class)
|
||||
public class ToOneSelfReferenceTest {
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.orm.test.onetoone.hhh9798;
|
||||
package org.hibernate.orm.test.mapping.onetoone.hhh9798;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.GeneratedValue;
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.orm.test.onetoone.hhh9798;
|
||||
package org.hibernate.orm.test.mapping.onetoone.hhh9798;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.orm.test.onetoone.hhh9798;
|
||||
package org.hibernate.orm.test.mapping.onetoone.hhh9798;
|
||||
|
||||
import java.util.Date;
|
||||
import javax.persistence.Entity;
|
|
@ -4,7 +4,7 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.orm.test.onetoone.hhh9798;
|
||||
package org.hibernate.orm.test.mapping.onetoone.hhh9798;
|
||||
|
||||
public enum ShipmentState {
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
//$Id: A320.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $
|
||||
package org.hibernate.orm.test.onetoone.primarykey;
|
||||
package org.hibernate.orm.test.mapping.onetoone.primarykey;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.OneToOne;
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
//$Id: A320.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $
|
||||
package org.hibernate.orm.test.onetoone.primarykey;
|
||||
package org.hibernate.orm.test.mapping.onetoone.primarykey;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
//$Id: A320.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $
|
||||
package org.hibernate.orm.test.onetoone.primarykey;
|
||||
package org.hibernate.orm.test.mapping.onetoone.primarykey;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue