fix some warnings and other misc cleanups to .cfg package
This commit is contained in:
parent
e80892b77f
commit
d4f934881c
|
@ -89,7 +89,7 @@ public class AnnotatedJoinColumn extends AnnotatedColumn {
|
|||
|
||||
//Due to @AnnotationOverride overriding rules, I don't want the constructor to be public
|
||||
private AnnotatedJoinColumn() {
|
||||
setMappedBy( BinderHelper.ANNOTATION_STRING_DEFAULT );
|
||||
setMappedBy("");
|
||||
}
|
||||
|
||||
//Due to @AnnotationOverride overriding rules, I don't want the constructor to be public
|
||||
|
|
|
@ -2843,7 +2843,7 @@ public final class AnnotationBinder {
|
|||
|
||||
private static void setVersionInformation(XProperty property, PropertyBinder propertyBinder) {
|
||||
propertyBinder.getBasicValueBinder().setVersion( true );
|
||||
if(property.isAnnotationPresent( Source.class )) {
|
||||
if ( property.isAnnotationPresent( Source.class ) ) {
|
||||
Source source = property.getAnnotation( Source.class );
|
||||
propertyBinder.getBasicValueBinder().setTimestampVersionType( source.value().typeName() );
|
||||
}
|
||||
|
@ -2866,7 +2866,7 @@ public final class AnnotationBinder {
|
|||
XProperty idXProperty = inferredData.getProperty();
|
||||
|
||||
final Annotation generatorAnnotation =
|
||||
HCANNHelper.findContainingAnnotation( idXProperty, IdGeneratorType.class, buildingContext );
|
||||
HCANNHelper.findContainingAnnotation( idXProperty, IdGeneratorType.class);
|
||||
if ( generatorAnnotation != null ) {
|
||||
idValue.setCustomIdGeneratorCreator( new CustomIdGeneratorCreator( generatorAnnotation, idXProperty ) );
|
||||
}
|
||||
|
@ -2883,7 +2883,7 @@ public final class AnnotationBinder {
|
|||
: "assigned";
|
||||
String generatorName = generatedValue != null
|
||||
? generatedValue.generator()
|
||||
: BinderHelper.ANNOTATION_STRING_DEFAULT;
|
||||
: "";
|
||||
if ( isComponent ) {
|
||||
//a component must not have any generator
|
||||
generatorType = "assigned";
|
||||
|
|
|
@ -58,17 +58,17 @@ public class BaselineSessionEventsListenerBuilder {
|
|||
arr[0] = buildStatsListener();
|
||||
arr[1] = buildAutoListener( autoListener );
|
||||
}
|
||||
else if ( !addStats && !addAutoListener ) {
|
||||
arr = EMPTY;
|
||||
}
|
||||
else if ( !addStats && addAutoListener ) {
|
||||
arr = new SessionEventListener[1];
|
||||
arr[0] = buildAutoListener( autoListener );
|
||||
}
|
||||
else { //Last case: if ( addStats && !addAutoListener )
|
||||
else if ( addStats && !addAutoListener ) {
|
||||
arr = new SessionEventListener[1];
|
||||
arr[0] = buildStatsListener();
|
||||
}
|
||||
else {//if ( !addStats && !addAutoListener )
|
||||
arr = EMPTY;
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
|
|
|
@ -72,8 +72,6 @@ import static org.hibernate.cfg.AnnotatedColumn.buildColumnOrFormulaFromAnnotati
|
|||
*/
|
||||
public class BinderHelper {
|
||||
|
||||
public static final String ANNOTATION_STRING_DEFAULT = "";
|
||||
|
||||
private static final Logger log = CoreLogging.logger( BinderHelper.class );
|
||||
|
||||
private BinderHelper() {
|
||||
|
|
|
@ -32,13 +32,13 @@ import org.hibernate.mapping.Table;
|
|||
|
||||
*/
|
||||
public class ClassPropertyHolder extends AbstractPropertyHolder {
|
||||
private PersistentClass persistentClass;
|
||||
private final PersistentClass persistentClass;
|
||||
private Map<String, Join> joins;
|
||||
private transient Map<String, Join> joinsPerRealTableName;
|
||||
private EntityBinder entityBinder;
|
||||
private final Map<XClass, InheritanceState> inheritanceStatePerClass;
|
||||
|
||||
private Map<String,AttributeConversionInfo> attributeConversionInfoMap;
|
||||
private final Map<String,AttributeConversionInfo> attributeConversionInfoMap;
|
||||
|
||||
public ClassPropertyHolder(
|
||||
PersistentClass persistentClass,
|
||||
|
@ -232,7 +232,7 @@ public class ClassPropertyHolder extends AbstractPropertyHolder {
|
|||
}
|
||||
|
||||
private void addPropertyToMappedSuperclass(Property prop, XClass declaringClass) {
|
||||
final Class type = getContext().getBootstrapContext().getReflectionManager().toClass( declaringClass );
|
||||
final Class<?> type = getContext().getBootstrapContext().getReflectionManager().toClass( declaringClass );
|
||||
MappedSuperclass superclass = getContext().getMetadataCollector().getMappedSuperclass( type );
|
||||
superclass.addDeclaredProperty( prop );
|
||||
}
|
||||
|
|
|
@ -52,8 +52,8 @@ public class CollectionPropertyHolder extends AbstractPropertyHolder {
|
|||
private boolean canElementBeConverted = true;
|
||||
private boolean canKeyBeConverted = true;
|
||||
|
||||
private Map<String,AttributeConversionInfo> elementAttributeConversionInfoMap;
|
||||
private Map<String,AttributeConversionInfo> keyAttributeConversionInfoMap;
|
||||
private final Map<String,AttributeConversionInfo> elementAttributeConversionInfoMap;
|
||||
private final Map<String,AttributeConversionInfo> keyAttributeConversionInfoMap;
|
||||
|
||||
public CollectionPropertyHolder(
|
||||
Collection collection,
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
*/
|
||||
package org.hibernate.cfg;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -33,16 +32,10 @@ public abstract class CollectionSecondPass implements SecondPass {
|
|||
|
||||
MetadataBuildingContext buildingContext;
|
||||
Collection collection;
|
||||
private Map localInheritedMetas;
|
||||
|
||||
public CollectionSecondPass(MetadataBuildingContext buildingContext, Collection collection, Map inheritedMetas) {
|
||||
this.collection = collection;
|
||||
this.buildingContext = buildingContext;
|
||||
this.localInheritedMetas = inheritedMetas;
|
||||
}
|
||||
|
||||
public CollectionSecondPass(MetadataBuildingContext buildingContext, Collection collection) {
|
||||
this( buildingContext, collection, Collections.EMPTY_MAP );
|
||||
this.collection = collection;
|
||||
this.buildingContext = buildingContext;
|
||||
}
|
||||
|
||||
public void doSecondPass(Map<String, PersistentClass> persistentClasses)
|
||||
|
@ -51,7 +44,7 @@ public abstract class CollectionSecondPass implements SecondPass {
|
|||
LOG.debugf( "Second pass for collection: %s", collection.getRole() );
|
||||
}
|
||||
|
||||
secondPass( persistentClasses, localInheritedMetas ); // using local since the inheritedMetas at this point is not the correct map since it is always the empty map
|
||||
secondPass( persistentClasses );
|
||||
collection.createAllKeys();
|
||||
|
||||
if ( LOG.isDebugEnabled() ) {
|
||||
|
@ -69,8 +62,7 @@ public abstract class CollectionSecondPass implements SecondPass {
|
|||
}
|
||||
}
|
||||
|
||||
abstract public void secondPass(Map persistentClasses, Map inheritedMetas)
|
||||
throws MappingException;
|
||||
abstract public void secondPass(Map<String, PersistentClass> persistentClasses) throws MappingException;
|
||||
|
||||
private static String columns(Value val) {
|
||||
StringBuilder columns = new StringBuilder();
|
||||
|
|
|
@ -60,13 +60,13 @@ import org.hibernate.mapping.Table;
|
|||
public class ComponentPropertyHolder extends AbstractPropertyHolder {
|
||||
//TODO introduce an overrideTable() method for columns held by sec table rather than the hack
|
||||
// joinsPerRealTableName in ClassPropertyHolder
|
||||
private Component component;
|
||||
private boolean isOrWithinEmbeddedId;
|
||||
private boolean isWithinElementCollection;
|
||||
private final Component component;
|
||||
private final boolean isOrWithinEmbeddedId;
|
||||
private final boolean isWithinElementCollection;
|
||||
|
||||
// private boolean virtual;
|
||||
private String embeddedAttributeName;
|
||||
private Map<String,AttributeConversionInfo> attributeConversionInfoMap;
|
||||
private final String embeddedAttributeName;
|
||||
private final Map<String,AttributeConversionInfo> attributeConversionInfoMap;
|
||||
|
||||
public ComponentPropertyHolder(
|
||||
Component component,
|
||||
|
@ -244,15 +244,8 @@ public class ComponentPropertyHolder extends AbstractPropertyHolder {
|
|||
|
||||
@Override
|
||||
protected AttributeConversionInfo locateAttributeConversionInfo(XProperty property) {
|
||||
final String propertyName = property.getName();
|
||||
|
||||
// conversions on parent would have precedence
|
||||
AttributeConversionInfo conversion = locateAttributeConversionInfo( propertyName );
|
||||
if ( conversion != null ) {
|
||||
return conversion;
|
||||
}
|
||||
|
||||
return null;
|
||||
return locateAttributeConversionInfo( property.getName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -364,18 +357,16 @@ public class ComponentPropertyHolder extends AbstractPropertyHolder {
|
|||
}
|
||||
|
||||
private String extractUserPropertyName(String redundantString, String propertyName) {
|
||||
String result = null;
|
||||
String className = component.getOwner().getClassName();
|
||||
if ( propertyName.startsWith( className )
|
||||
boolean specialCase = propertyName.startsWith(className)
|
||||
&& propertyName.length() > className.length() + 2 + redundantString.length() // .id.
|
||||
&& propertyName.substring(
|
||||
className.length() + 1, className.length() + 1 + redundantString.length()
|
||||
).equals( redundantString )
|
||||
) {
|
||||
//remove id we might be in a @IdCLass case
|
||||
result = className + propertyName.substring( className.length() + 1 + redundantString.length() );
|
||||
&& propertyName.substring( className.length() + 1, className.length() + 1 + redundantString.length() )
|
||||
.equals(redundantString);
|
||||
if (specialCase) {
|
||||
//remove id we might be in a @IdClass case
|
||||
return className + propertyName.substring( className.length() + 1 + redundantString.length() );
|
||||
}
|
||||
return result;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
package org.hibernate.cfg;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
|
@ -94,9 +93,9 @@ public class Configuration {
|
|||
// used during processing mappings
|
||||
private ImplicitNamingStrategy implicitNamingStrategy;
|
||||
private PhysicalNamingStrategy physicalNamingStrategy;
|
||||
private List<BasicType> basicTypes = new ArrayList<>();
|
||||
private final List<BasicType<?>> basicTypes = new ArrayList<>();
|
||||
private List<UserTypeRegistration> userTypeRegistrations;
|
||||
private List<TypeContributor> typeContributorRegistrations = new ArrayList<>();
|
||||
private final List<TypeContributor> typeContributorRegistrations = new ArrayList<>();
|
||||
private Map<String, NamedHqlQueryDefinition> namedQueries;
|
||||
private Map<String, NamedNativeQueryDefinition> namedSqlQueries;
|
||||
private Map<String, NamedProcedureCallDefinition> namedProcedureCallMap;
|
||||
|
@ -105,7 +104,7 @@ public class Configuration {
|
|||
|
||||
private Map<String, SqmFunctionDescriptor> customFunctionDescriptors;
|
||||
private List<AuxiliaryDatabaseObject> auxiliaryDatabaseObjectList;
|
||||
private HashMap<Class, ConverterDescriptor> attributeConverterDescriptorsByClass;
|
||||
private HashMap<Class<?>, ConverterDescriptor> attributeConverterDescriptorsByClass;
|
||||
|
||||
// used to build SF
|
||||
private StandardServiceRegistryBuilder standardServiceRegistryBuilder;
|
||||
|
@ -411,9 +410,8 @@ public class Configuration {
|
|||
* @return The dom "deserialized" from the cached file.
|
||||
*
|
||||
* @throws SerializationException Indicates a problem deserializing the cached dom tree
|
||||
* @throws FileNotFoundException Indicates that the cached file was not found or was not usable.
|
||||
*/
|
||||
public Configuration addCacheableFileStrictly(File xmlFile) throws SerializationException, FileNotFoundException {
|
||||
public Configuration addCacheableFileStrictly(File xmlFile) throws SerializationException {
|
||||
metadataSources.addCacheableFileStrictly( xmlFile );
|
||||
return this;
|
||||
}
|
||||
|
@ -644,7 +642,7 @@ public class Configuration {
|
|||
}
|
||||
|
||||
if ( !basicTypes.isEmpty() ) {
|
||||
for ( BasicType basicType : basicTypes ) {
|
||||
for ( BasicType<?> basicType : basicTypes ) {
|
||||
metadataBuilder.applyBasicType( basicType );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
package org.hibernate.cfg;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.mapping.JoinedSubclass;
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
import org.hibernate.mapping.RootClass;
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.cfg;
|
||||
|
||||
import java.util.Locale;
|
||||
import org.hibernate.AssertionFailure;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
|
|
|
@ -22,8 +22,8 @@ public abstract class FkSecondPass implements SecondPass {
|
|||
* Fairly hacky but IBM VM sometimes returns the same hashCode for 2 different objects
|
||||
* TODO is it doable to rely on the Ejb3JoinColumn names? Not sure as they could be inferred
|
||||
*/
|
||||
private int uniqueCounter;
|
||||
private static AtomicInteger globalCounter = new AtomicInteger();
|
||||
private final int uniqueCounter;
|
||||
private static final AtomicInteger globalCounter = new AtomicInteger();
|
||||
|
||||
public FkSecondPass(SimpleValue value, AnnotatedJoinColumn[] columns) {
|
||||
this.value = value;
|
||||
|
@ -31,10 +31,6 @@ public abstract class FkSecondPass implements SecondPass {
|
|||
this.uniqueCounter = globalCounter.getAndIncrement();
|
||||
}
|
||||
|
||||
public int getUniqueCounter() {
|
||||
return uniqueCounter;
|
||||
}
|
||||
|
||||
public Value getValue() {
|
||||
return value;
|
||||
}
|
||||
|
@ -45,9 +41,7 @@ public abstract class FkSecondPass implements SecondPass {
|
|||
|
||||
FkSecondPass that = (FkSecondPass) o;
|
||||
|
||||
if ( uniqueCounter != that.uniqueCounter ) return false;
|
||||
|
||||
return true;
|
||||
return uniqueCounter == that.uniqueCounter;
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
|
|
|
@ -19,11 +19,11 @@ import org.hibernate.mapping.SimpleValue;
|
|||
* @author Andrea Boriero
|
||||
*/
|
||||
public class IdGeneratorResolverSecondPass implements SecondPass {
|
||||
private SimpleValue id;
|
||||
private XProperty idXProperty;
|
||||
private String generatorType;
|
||||
private String generatorName;
|
||||
private MetadataBuildingContext buildingContext;
|
||||
private final SimpleValue id;
|
||||
private final XProperty idXProperty;
|
||||
private final String generatorType;
|
||||
private final String generatorName;
|
||||
private final MetadataBuildingContext buildingContext;
|
||||
private IdentifierGeneratorDefinition localIdentifierGeneratorDefinition;
|
||||
|
||||
public IdGeneratorResolverSecondPass(
|
||||
|
|
|
@ -45,14 +45,6 @@ public class IndexOrUniqueKeySecondPass implements SecondPass {
|
|||
this.unique = false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Build an index
|
||||
*/
|
||||
public IndexOrUniqueKeySecondPass(String indexName, AnnotatedColumn column, MetadataBuildingContext buildingContext) {
|
||||
this( indexName, column, buildingContext, false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an index if unique is false or a Unique Key if unique is true
|
||||
*/
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.cfg;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.MappingException;
|
||||
|
@ -17,10 +18,9 @@ import org.hibernate.mapping.SimpleValue;
|
|||
/**
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
@SuppressWarnings({"serial", "unchecked"})
|
||||
public class JoinedSubclassFkSecondPass extends FkSecondPass {
|
||||
private JoinedSubclass entity;
|
||||
private MetadataBuildingContext buildingContext;
|
||||
private final JoinedSubclass entity;
|
||||
private final MetadataBuildingContext buildingContext;
|
||||
|
||||
public JoinedSubclassFkSecondPass(
|
||||
JoinedSubclass entity,
|
||||
|
|
|
@ -25,7 +25,7 @@ public enum MetadataSourceType {
|
|||
|
||||
private final String name;
|
||||
|
||||
private MetadataSourceType(String name) {
|
||||
MetadataSourceType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
|
|
@ -183,7 +183,7 @@ public class OneToOneSecondPass implements SecondPass {
|
|||
if ( otherSideJoin != null ) {
|
||||
//@OneToOne @JoinTable
|
||||
Join mappedByJoin = buildJoinFromMappedBySide(
|
||||
(PersistentClass) persistentClasses.get( ownerEntity ), otherSideProperty, otherSideJoin
|
||||
persistentClasses.get( ownerEntity ), otherSideProperty, otherSideJoin
|
||||
);
|
||||
ManyToOne manyToOne = new ManyToOne( buildingContext, mappedByJoin.getTable() );
|
||||
//FIXME use ignore not found here
|
||||
|
|
|
@ -14,8 +14,8 @@ import org.hibernate.internal.util.StringHelper;
|
|||
* @author Emmanuel Bernard
|
||||
*/
|
||||
public class WrappedInferredData implements PropertyData {
|
||||
private PropertyData wrappedInferredData;
|
||||
private String propertyName;
|
||||
private final PropertyData wrappedInferredData;
|
||||
private final String propertyName;
|
||||
|
||||
public XClass getClassOrElement() throws MappingException {
|
||||
return wrappedInferredData.getClassOrElement();
|
||||
|
|
|
@ -54,8 +54,6 @@ import org.hibernate.annotations.common.reflection.XClass;
|
|||
import org.hibernate.annotations.common.reflection.XProperty;
|
||||
import org.hibernate.boot.model.TypeDefinition;
|
||||
import org.hibernate.boot.model.convert.spi.ConverterDescriptor;
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.boot.registry.selector.spi.StrategySelector;
|
||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||
import org.hibernate.cfg.AccessType;
|
||||
import org.hibernate.cfg.AnnotatedColumn;
|
||||
|
@ -132,10 +130,6 @@ public class BasicValueBinder<T> implements JdbcTypeIndicators {
|
|||
private final Kind kind;
|
||||
private final MetadataBuildingContext buildingContext;
|
||||
|
||||
private final ClassLoaderService classLoaderService;
|
||||
private final StrategySelector strategySelector;
|
||||
|
||||
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// in-flight info
|
||||
|
@ -179,14 +173,6 @@ public class BasicValueBinder<T> implements JdbcTypeIndicators {
|
|||
|
||||
this.kind = kind;
|
||||
this.buildingContext = buildingContext;
|
||||
|
||||
this.classLoaderService = buildingContext.getBootstrapContext()
|
||||
.getServiceRegistry()
|
||||
.getService( ClassLoaderService.class );
|
||||
|
||||
this.strategySelector = buildingContext.getBootstrapContext()
|
||||
.getServiceRegistry()
|
||||
.getService( StrategySelector.class );
|
||||
}
|
||||
|
||||
|
||||
|
@ -308,17 +294,11 @@ public class BasicValueBinder<T> implements JdbcTypeIndicators {
|
|||
|
||||
// If we get into this method we know that there is a Java type for the value
|
||||
// and that it is safe to load on the app classloader.
|
||||
final Class modelJavaType = resolveJavaType( modelTypeXClass, buildingContext );
|
||||
final Class<?> modelJavaType = resolveJavaType( modelTypeXClass );
|
||||
if ( modelJavaType == null ) {
|
||||
throw new IllegalStateException( "BasicType requires Java type" );
|
||||
}
|
||||
|
||||
final Class modelPropertyJavaType = buildingContext.getBootstrapContext()
|
||||
.getReflectionManager()
|
||||
.toClass( modelXProperty.getType() );
|
||||
|
||||
final boolean isMap = Map.class.isAssignableFrom( modelPropertyJavaType );
|
||||
|
||||
if ( kind != Kind.LIST_INDEX && kind != Kind.MAP_KEY ) {
|
||||
isLob = modelXProperty.isAnnotationPresent( Lob.class );
|
||||
}
|
||||
|
@ -404,9 +384,7 @@ public class BasicValueBinder<T> implements JdbcTypeIndicators {
|
|||
throw new MappingException( "idbag mapping missing @CollectionId" );
|
||||
}
|
||||
|
||||
final ManagedBeanRegistry beanRegistry = buildingContext.getBootstrapContext()
|
||||
.getServiceRegistry()
|
||||
.getService( ManagedBeanRegistry.class );
|
||||
final ManagedBeanRegistry beanRegistry = getManagedBeanRegistry();
|
||||
|
||||
explicitBasicTypeName = null;
|
||||
implicitJavaTypeAccess = (typeConfiguration) -> null;
|
||||
|
@ -490,6 +468,12 @@ public class BasicValueBinder<T> implements JdbcTypeIndicators {
|
|||
final String generator = collectionIdAnn.generator();
|
||||
}
|
||||
|
||||
private ManagedBeanRegistry getManagedBeanRegistry() {
|
||||
return buildingContext.getBootstrapContext()
|
||||
.getServiceRegistry()
|
||||
.getService(ManagedBeanRegistry.class);
|
||||
}
|
||||
|
||||
private void prepareMapKey(
|
||||
XProperty mapAttribute,
|
||||
XClass modelPropertyTypeXClass) {
|
||||
|
@ -500,9 +484,7 @@ public class BasicValueBinder<T> implements JdbcTypeIndicators {
|
|||
else {
|
||||
mapKeyClass = modelPropertyTypeXClass;
|
||||
}
|
||||
final Class<?> implicitJavaType = buildingContext.getBootstrapContext()
|
||||
.getReflectionManager()
|
||||
.toClass( mapKeyClass );
|
||||
final Class<?> implicitJavaType = resolveJavaType( mapKeyClass );
|
||||
|
||||
implicitJavaTypeAccess = (typeConfiguration) -> implicitJavaType;
|
||||
|
||||
|
@ -516,17 +498,12 @@ public class BasicValueBinder<T> implements JdbcTypeIndicators {
|
|||
temporalPrecision = mapKeyTemporalAnn.value();
|
||||
}
|
||||
|
||||
final ManagedBeanRegistry managedBeanRegistry = buildingContext.getBootstrapContext()
|
||||
.getServiceRegistry()
|
||||
.getService( ManagedBeanRegistry.class );
|
||||
|
||||
explicitJdbcTypeAccess = typeConfiguration -> {
|
||||
final MapKeyJdbcType jdbcTypeAnn = findAnnotation( mapAttribute, MapKeyJdbcType.class );
|
||||
if ( jdbcTypeAnn != null ) {
|
||||
final Class<? extends JdbcType> jdbcTypeImpl = normalizeJdbcType( jdbcTypeAnn.value() );
|
||||
if ( jdbcTypeImpl != null ) {
|
||||
final ManagedBean<? extends JdbcType> jdbcTypeBean = managedBeanRegistry.getBean( jdbcTypeImpl );
|
||||
return jdbcTypeBean.getBeanInstance();
|
||||
return getManagedBeanRegistry().getBean( jdbcTypeImpl ).getBeanInstance();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -546,14 +523,14 @@ public class BasicValueBinder<T> implements JdbcTypeIndicators {
|
|||
if ( javaTypeAnn != null ) {
|
||||
final Class<? extends BasicJavaType<?>> jdbcTypeImpl = normalizeJavaType( javaTypeAnn.value() );
|
||||
if ( jdbcTypeImpl != null ) {
|
||||
final ManagedBean<? extends BasicJavaType> jdbcTypeBean = managedBeanRegistry.getBean( jdbcTypeImpl );
|
||||
final ManagedBean<? extends BasicJavaType> jdbcTypeBean = getManagedBeanRegistry().getBean( jdbcTypeImpl );
|
||||
return jdbcTypeBean.getBeanInstance();
|
||||
}
|
||||
}
|
||||
|
||||
final MapKeyClass mapKeyClassAnn = mapAttribute.getAnnotation( MapKeyClass.class );
|
||||
if ( mapKeyClassAnn != null ) {
|
||||
return (BasicJavaType) typeConfiguration.getJavaTypeRegistry().getDescriptor( mapKeyClassAnn.value() );
|
||||
return (BasicJavaType<?>) typeConfiguration.getJavaTypeRegistry().getDescriptor( mapKeyClassAnn.value() );
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -564,7 +541,7 @@ public class BasicValueBinder<T> implements JdbcTypeIndicators {
|
|||
if ( mutabilityAnn != null ) {
|
||||
final Class<? extends MutabilityPlan<?>> mutability = normalizeMutability( mutabilityAnn.value() );
|
||||
if ( mutability != null ) {
|
||||
final ManagedBean<? extends MutabilityPlan<?>> jtdBean = managedBeanRegistry.getBean( mutability );
|
||||
final ManagedBean<? extends MutabilityPlan<?>> jtdBean = getManagedBeanRegistry().getBean( mutability );
|
||||
return jtdBean.getBeanInstance();
|
||||
}
|
||||
}
|
||||
|
@ -583,7 +560,7 @@ public class BasicValueBinder<T> implements JdbcTypeIndicators {
|
|||
if ( converterDescriptor != null ) {
|
||||
final Mutability converterMutabilityAnn = converterDescriptor.getAttributeConverterClass().getAnnotation( Mutability.class );
|
||||
if ( converterMutabilityAnn != null ) {
|
||||
final ManagedBean<? extends MutabilityPlan<?>> jtdBean = managedBeanRegistry.getBean( converterMutabilityAnn.value() );
|
||||
final ManagedBean<? extends MutabilityPlan<?>> jtdBean = getManagedBeanRegistry().getBean( converterMutabilityAnn.value() );
|
||||
return jtdBean.getBeanInstance();
|
||||
}
|
||||
|
||||
|
@ -646,18 +623,10 @@ public class BasicValueBinder<T> implements JdbcTypeIndicators {
|
|||
|
||||
private void prepareCollectionElement(XProperty attributeXProperty, XClass elementTypeXClass) {
|
||||
|
||||
Class<T> javaType;
|
||||
//noinspection unchecked
|
||||
if ( elementTypeXClass == null && attributeXProperty.isArray() ) {
|
||||
javaType = buildingContext.getBootstrapContext()
|
||||
.getReflectionManager()
|
||||
.toClass( attributeXProperty.getElementClass() );
|
||||
}
|
||||
else {
|
||||
javaType = buildingContext.getBootstrapContext()
|
||||
.getReflectionManager()
|
||||
.toClass( elementTypeXClass );
|
||||
}
|
||||
XClass xclass = elementTypeXClass == null && attributeXProperty.isArray()
|
||||
? attributeXProperty.getElementClass()
|
||||
: elementTypeXClass;
|
||||
Class<?> javaType = resolveJavaType( xclass );
|
||||
|
||||
implicitJavaTypeAccess = typeConfiguration -> javaType;
|
||||
|
||||
|
@ -706,9 +675,7 @@ public class BasicValueBinder<T> implements JdbcTypeIndicators {
|
|||
else {
|
||||
switch ( timeZoneStorageType ) {
|
||||
case AUTO:
|
||||
final Dialect dialect = buildingContext.getBootstrapContext().getServiceRegistry()
|
||||
.getService( JdbcServices.class ).getDialect();
|
||||
if ( dialect.getTimeZoneSupport() == TimeZoneSupport.NATIVE ) {
|
||||
if ( getDialect().getTimeZoneSupport() == TimeZoneSupport.NATIVE ) {
|
||||
column = null;
|
||||
type = null;
|
||||
break;
|
||||
|
@ -796,7 +763,7 @@ public class BasicValueBinder<T> implements JdbcTypeIndicators {
|
|||
timeZoneStorageType = null;
|
||||
}
|
||||
|
||||
normalSupplementalDetails( attributeXProperty, buildingContext );
|
||||
normalSupplementalDetails( attributeXProperty);
|
||||
|
||||
// layer in support for JPA's approach for specifying a specific Java type for the collection elements...
|
||||
final ElementCollection elementCollectionAnn = attributeXProperty.getAnnotation( ElementCollection.class );
|
||||
|
@ -805,23 +772,21 @@ public class BasicValueBinder<T> implements JdbcTypeIndicators {
|
|||
&& elementCollectionAnn.targetClass() != void.class ) {
|
||||
final Function<TypeConfiguration, BasicJavaType> original = explicitJavaTypeAccess;
|
||||
explicitJavaTypeAccess = (typeConfiguration) -> {
|
||||
final BasicJavaType originalResult = original.apply( typeConfiguration );
|
||||
final BasicJavaType<?> originalResult = original.apply( typeConfiguration );
|
||||
if ( originalResult != null ) {
|
||||
return originalResult;
|
||||
}
|
||||
|
||||
return (BasicJavaType) typeConfiguration
|
||||
return (BasicJavaType<?>) typeConfiguration
|
||||
.getJavaTypeRegistry()
|
||||
.getDescriptor( elementCollectionAnn.targetClass() );
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void prepareBasicAttribute(String declaringClassName, XProperty attributeDescriptor, XClass attributeType) {
|
||||
final Class<T> javaType = buildingContext.getBootstrapContext()
|
||||
.getReflectionManager()
|
||||
.toClass( attributeType );
|
||||
|
||||
final Class<?> javaType = resolveJavaType( attributeType );
|
||||
|
||||
implicitJavaTypeAccess = typeConfiguration -> javaType;
|
||||
|
||||
|
@ -867,7 +832,7 @@ public class BasicValueBinder<T> implements JdbcTypeIndicators {
|
|||
this.enumType = null;
|
||||
}
|
||||
|
||||
normalSupplementalDetails( attributeDescriptor, buildingContext );
|
||||
normalSupplementalDetails( attributeDescriptor);
|
||||
}
|
||||
|
||||
private void prepareAnyDiscriminator(XProperty modelXProperty) {
|
||||
|
@ -891,8 +856,8 @@ public class BasicValueBinder<T> implements JdbcTypeIndicators {
|
|||
return String.class;
|
||||
};
|
||||
|
||||
normalJdbcTypeDetails( modelXProperty, buildingContext );
|
||||
normalMutabilityDetails( modelXProperty, buildingContext );
|
||||
normalJdbcTypeDetails( modelXProperty);
|
||||
normalMutabilityDetails( modelXProperty );
|
||||
|
||||
// layer AnyDiscriminator into the JdbcType resolution
|
||||
final Function<TypeConfiguration, JdbcType> originalJdbcTypeResolution = explicitJdbcTypeAccess;
|
||||
|
@ -913,18 +878,13 @@ public class BasicValueBinder<T> implements JdbcTypeIndicators {
|
|||
private void prepareAnyKey(XProperty modelXProperty) {
|
||||
implicitJavaTypeAccess = (typeConfiguration) -> null;
|
||||
|
||||
final ManagedBeanRegistry managedBeanRegistry = buildingContext.getBootstrapContext()
|
||||
.getServiceRegistry()
|
||||
.getService( ManagedBeanRegistry.class );
|
||||
|
||||
explicitJavaTypeAccess = (typeConfiguration) -> {
|
||||
final AnyKeyJavaType javaTypeAnn = findAnnotation( modelXProperty, AnyKeyJavaType.class );
|
||||
if ( javaTypeAnn != null ) {
|
||||
final Class<? extends BasicJavaType<?>> javaType = normalizeJavaType( javaTypeAnn.value() );
|
||||
|
||||
if ( javaType != null ) {
|
||||
final ManagedBean<? extends BasicJavaType<?>> jtdBean = managedBeanRegistry.getBean( javaType );
|
||||
return jtdBean.getBeanInstance();
|
||||
return getManagedBeanRegistry().getBean( javaType ).getBeanInstance();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -944,7 +904,7 @@ public class BasicValueBinder<T> implements JdbcTypeIndicators {
|
|||
if ( jdbcTypeAnn != null ) {
|
||||
final Class<? extends JdbcType> jdbcType = normalizeJdbcType( jdbcTypeAnn.value() );
|
||||
if ( jdbcType != null ) {
|
||||
final ManagedBean<? extends JdbcType> jtdBean = managedBeanRegistry.getBean( jdbcType );
|
||||
final ManagedBean<? extends JdbcType> jtdBean = getManagedBeanRegistry().getBean( jdbcType );
|
||||
return jtdBean.getBeanInstance();
|
||||
}
|
||||
}
|
||||
|
@ -960,20 +920,14 @@ public class BasicValueBinder<T> implements JdbcTypeIndicators {
|
|||
};
|
||||
}
|
||||
|
||||
private void normalJdbcTypeDetails(
|
||||
XProperty attributeXProperty,
|
||||
MetadataBuildingContext buildingContext) {
|
||||
explicitJdbcTypeAccess = (typeConfiguration) -> {
|
||||
final ManagedBeanRegistry managedBeanRegistry = buildingContext.getBootstrapContext()
|
||||
.getServiceRegistry()
|
||||
.getService( ManagedBeanRegistry.class );
|
||||
private void normalJdbcTypeDetails(XProperty attributeXProperty) {
|
||||
explicitJdbcTypeAccess = typeConfiguration -> {
|
||||
|
||||
final org.hibernate.annotations.JdbcType jdbcTypeAnn = findAnnotation( attributeXProperty, org.hibernate.annotations.JdbcType.class );
|
||||
if ( jdbcTypeAnn != null ) {
|
||||
final Class<? extends JdbcType> jdbcType = normalizeJdbcType( jdbcTypeAnn.value() );
|
||||
if ( jdbcType != null ) {
|
||||
final ManagedBean<? extends JdbcType> jdbcTypeBean = managedBeanRegistry.getBean( jdbcType );
|
||||
return jdbcTypeBean.getBeanInstance();
|
||||
return getManagedBeanRegistry().getBean( jdbcType ).getBeanInstance();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -989,20 +943,14 @@ public class BasicValueBinder<T> implements JdbcTypeIndicators {
|
|||
};
|
||||
}
|
||||
|
||||
private void normalMutabilityDetails(
|
||||
XProperty attributeXProperty,
|
||||
MetadataBuildingContext buildingContext) {
|
||||
final ManagedBeanRegistry managedBeanRegistry = buildingContext.getBootstrapContext()
|
||||
.getServiceRegistry()
|
||||
.getService( ManagedBeanRegistry.class );
|
||||
private void normalMutabilityDetails(XProperty attributeXProperty) {
|
||||
|
||||
explicitMutabilityAccess = typeConfiguration -> {
|
||||
final Mutability mutabilityAnn = findAnnotation( attributeXProperty, Mutability.class );
|
||||
if ( mutabilityAnn != null ) {
|
||||
final Class<? extends MutabilityPlan<?>> mutability = normalizeMutability( mutabilityAnn.value() );
|
||||
if ( mutability != null ) {
|
||||
final ManagedBean<? extends MutabilityPlan<?>> jtdBean = managedBeanRegistry.getBean( mutability );
|
||||
return jtdBean.getBeanInstance();
|
||||
return getManagedBeanRegistry().getBean( mutability ).getBeanInstance();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1025,7 +973,7 @@ public class BasicValueBinder<T> implements JdbcTypeIndicators {
|
|||
if ( converterDescriptor != null ) {
|
||||
final Mutability converterMutabilityAnn = converterDescriptor.getAttributeConverterClass().getAnnotation( Mutability.class );
|
||||
if ( converterMutabilityAnn != null ) {
|
||||
final ManagedBean<? extends MutabilityPlan<?>> jtdBean = managedBeanRegistry.getBean( converterMutabilityAnn.value() );
|
||||
final ManagedBean<? extends MutabilityPlan<?>> jtdBean = getManagedBeanRegistry().getBean( converterMutabilityAnn.value() );
|
||||
return jtdBean.getBeanInstance();
|
||||
}
|
||||
|
||||
|
@ -1046,12 +994,7 @@ public class BasicValueBinder<T> implements JdbcTypeIndicators {
|
|||
};
|
||||
}
|
||||
|
||||
private void normalSupplementalDetails(
|
||||
XProperty attributeXProperty,
|
||||
MetadataBuildingContext buildingContext) {
|
||||
final ManagedBeanRegistry managedBeanRegistry = buildingContext.getBootstrapContext()
|
||||
.getServiceRegistry()
|
||||
.getService( ManagedBeanRegistry.class );
|
||||
private void normalSupplementalDetails(XProperty attributeXProperty) {
|
||||
|
||||
explicitJavaTypeAccess = typeConfiguration -> {
|
||||
final org.hibernate.annotations.JavaType javaTypeAnn = findAnnotation( attributeXProperty, org.hibernate.annotations.JavaType.class );
|
||||
|
@ -1059,14 +1002,14 @@ public class BasicValueBinder<T> implements JdbcTypeIndicators {
|
|||
final Class<? extends BasicJavaType<?>> javaType = normalizeJavaType( javaTypeAnn.value() );
|
||||
|
||||
if ( javaType != null ) {
|
||||
final ManagedBean<? extends BasicJavaType<?>> jtdBean = managedBeanRegistry.getBean( javaType );
|
||||
final ManagedBean<? extends BasicJavaType<?>> jtdBean = getManagedBeanRegistry().getBean( javaType );
|
||||
return jtdBean.getBeanInstance();
|
||||
}
|
||||
}
|
||||
|
||||
final Target targetAnn = findAnnotation( attributeXProperty, Target.class );
|
||||
if ( targetAnn != null ) {
|
||||
return (BasicJavaType) typeConfiguration
|
||||
return (BasicJavaType<?>) typeConfiguration
|
||||
.getJavaTypeRegistry()
|
||||
.getDescriptor( targetAnn.value() );
|
||||
}
|
||||
|
@ -1074,8 +1017,8 @@ public class BasicValueBinder<T> implements JdbcTypeIndicators {
|
|||
return null;
|
||||
};
|
||||
|
||||
normalJdbcTypeDetails( attributeXProperty, buildingContext );
|
||||
normalMutabilityDetails( attributeXProperty, buildingContext );
|
||||
normalJdbcTypeDetails( attributeXProperty);
|
||||
normalMutabilityDetails( attributeXProperty );
|
||||
|
||||
final Enumerated enumeratedAnn = attributeXProperty.getAnnotation( Enumerated.class );
|
||||
if ( enumeratedAnn != null ) {
|
||||
|
@ -1089,38 +1032,22 @@ public class BasicValueBinder<T> implements JdbcTypeIndicators {
|
|||
}
|
||||
|
||||
private static Class<? extends UserType<?>> normalizeUserType(Class<? extends UserType<?>> userType) {
|
||||
if ( userType == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return userType;
|
||||
}
|
||||
|
||||
private Class<? extends JdbcType> normalizeJdbcType(Class<? extends JdbcType> jdbcType) {
|
||||
if ( jdbcType == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return jdbcType;
|
||||
}
|
||||
|
||||
private static Class<? extends BasicJavaType<?>> normalizeJavaType(Class<? extends BasicJavaType<?>> javaType) {
|
||||
if ( javaType == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return javaType;
|
||||
}
|
||||
|
||||
private Class<? extends MutabilityPlan<?>> normalizeMutability(Class<? extends MutabilityPlan<?>> mutability) {
|
||||
if ( mutability == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return mutability;
|
||||
}
|
||||
|
||||
private static Class resolveJavaType(XClass returnedClassOrElement, MetadataBuildingContext buildingContext) {
|
||||
private Class<?> resolveJavaType(XClass returnedClassOrElement) {
|
||||
return buildingContext.getBootstrapContext()
|
||||
.getReflectionManager()
|
||||
.toClass( returnedClassOrElement );
|
||||
|
@ -1130,7 +1057,6 @@ public class BasicValueBinder<T> implements JdbcTypeIndicators {
|
|||
return buildingContext.getBuildingOptions()
|
||||
.getServiceRegistry()
|
||||
.getService( JdbcServices.class )
|
||||
.getJdbcEnvironment()
|
||||
.getDialect();
|
||||
}
|
||||
|
||||
|
@ -1446,7 +1372,7 @@ public class BasicValueBinder<T> implements JdbcTypeIndicators {
|
|||
return null;
|
||||
}
|
||||
|
||||
return normalizeUserType( (Class) customType.value() );
|
||||
return normalizeUserType( customType.value() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -104,6 +104,7 @@ import org.hibernate.mapping.SimpleValue;
|
|||
import org.hibernate.mapping.Table;
|
||||
import org.hibernate.metamodel.CollectionClassification;
|
||||
import org.hibernate.metamodel.spi.EmbeddableInstantiator;
|
||||
import org.hibernate.persister.collection.CollectionPersister;
|
||||
import org.hibernate.resource.beans.spi.ManagedBean;
|
||||
import org.hibernate.resource.beans.spi.ManagedBeanRegistry;
|
||||
import org.hibernate.usertype.ParameterizedType;
|
||||
|
@ -143,7 +144,7 @@ import static org.hibernate.engine.spi.ExecuteUpdateResultCheckStyle.fromExterna
|
|||
* @author inger
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
@SuppressWarnings({"unchecked", "deprecation"})
|
||||
@SuppressWarnings("deprecation")
|
||||
public abstract class CollectionBinder {
|
||||
private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, CollectionBinder.class.getName());
|
||||
|
||||
|
@ -730,8 +731,10 @@ public abstract class CollectionBinder {
|
|||
private void bindCustomPersister() {
|
||||
Persister persisterAnn = property.getAnnotation( Persister.class );
|
||||
if ( persisterAnn != null ) {
|
||||
//noinspection rawtypes
|
||||
collection.setCollectionPersisterClass( (Class) persisterAnn.impl() );
|
||||
//noinspection unchecked
|
||||
Class<? extends CollectionPersister> persister =
|
||||
(Class<? extends CollectionPersister>) persisterAnn.impl();
|
||||
collection.setCollectionPersisterClass( persister );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1033,9 +1036,8 @@ public abstract class CollectionBinder {
|
|||
final TableBinder assocTableBinder,
|
||||
final MetadataBuildingContext buildingContext) {
|
||||
return new CollectionSecondPass( buildingContext, collection ) {
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public void secondPass(Map persistentClasses, Map inheritedMetas) throws MappingException {
|
||||
public void secondPass(Map<String, PersistentClass> persistentClasses) throws MappingException {
|
||||
bindStarToManySecondPass(
|
||||
persistentClasses,
|
||||
collType,
|
||||
|
@ -1808,7 +1810,7 @@ public abstract class CollectionBinder {
|
|||
property,
|
||||
elementClass,
|
||||
collValue.getOwnerEntityName(),
|
||||
holder.resolveElementAttributeConverterDescriptor(property, elementClass )
|
||||
holder.resolveElementAttributeConverterDescriptor( property, elementClass )
|
||||
);
|
||||
elementBinder.setPersistentClassName( propertyHolder.getEntityName() );
|
||||
elementBinder.setAccessType( accessType );
|
||||
|
|
|
@ -13,7 +13,6 @@ import org.hibernate.Internal;
|
|||
import org.hibernate.annotations.common.reflection.XAnnotatedElement;
|
||||
import org.hibernate.annotations.common.reflection.XProperty;
|
||||
import org.hibernate.annotations.common.reflection.java.JavaXMember;
|
||||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||
|
||||
/**
|
||||
* Manage the various fun-ness of dealing with HCANN...
|
||||
|
@ -92,9 +91,7 @@ public final class HCANNHelper {
|
|||
*/
|
||||
public static <A extends Annotation, T extends Annotation> A findContainingAnnotation(
|
||||
XAnnotatedElement xAnnotatedElement,
|
||||
Class<T> annotationType,
|
||||
MetadataBuildingContext context) {
|
||||
// xAnnotatedElement = id-prop
|
||||
Class<T> annotationType) {
|
||||
|
||||
for ( int i = 0; i < xAnnotatedElement.getAnnotations().length; i++ ) {
|
||||
final Annotation annotation = xAnnotatedElement.getAnnotations()[ i ];
|
||||
|
|
|
@ -38,7 +38,10 @@ import jakarta.persistence.Column;
|
|||
* @author Emmanuel Bernard
|
||||
*/
|
||||
public class IdBagBinder extends BagBinder {
|
||||
public IdBagBinder(Supplier<ManagedBean<? extends UserCollectionType>> customTypeBeanResolver, MetadataBuildingContext buildingContext) {
|
||||
|
||||
public IdBagBinder(
|
||||
Supplier<ManagedBean<? extends UserCollectionType>> customTypeBeanResolver,
|
||||
MetadataBuildingContext buildingContext) {
|
||||
super( customTypeBeanResolver, buildingContext );
|
||||
}
|
||||
|
||||
|
@ -106,7 +109,8 @@ public class IdBagBinder extends BagBinder {
|
|||
idColumn.setNullable( false );
|
||||
}
|
||||
|
||||
final BasicValueBinder<?> valueBinder = new BasicValueBinder<>( BasicValueBinder.Kind.COLLECTION_ID, buildingContext );
|
||||
final BasicValueBinder<?> valueBinder =
|
||||
new BasicValueBinder<>( BasicValueBinder.Kind.COLLECTION_ID, buildingContext );
|
||||
|
||||
final Table table = collection.getCollectionTable();
|
||||
valueBinder.setTable( table );
|
||||
|
|
|
@ -27,7 +27,6 @@ import org.hibernate.mapping.IndexBackref;
|
|||
import org.hibernate.mapping.List;
|
||||
import org.hibernate.mapping.OneToMany;
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
import org.hibernate.mapping.SemanticsResolver;
|
||||
import org.hibernate.mapping.SimpleValue;
|
||||
import org.hibernate.resource.beans.spi.ManagedBean;
|
||||
import org.hibernate.usertype.UserCollectionType;
|
||||
|
@ -40,7 +39,6 @@ import org.jboss.logging.Logger;
|
|||
* @author Matthew Inger
|
||||
* @author Emmanuel Bernard
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class ListBinder extends CollectionBinder {
|
||||
private static final CoreMessageLogger LOG = Logger.getMessageLogger( CoreMessageLogger.class, ListBinder.class.getName() );
|
||||
|
||||
|
@ -77,7 +75,7 @@ public class ListBinder extends CollectionBinder {
|
|||
final MetadataBuildingContext buildingContext) {
|
||||
return new CollectionSecondPass( getBuildingContext(), ListBinder.this.collection ) {
|
||||
@Override
|
||||
public void secondPass(Map persistentClasses, Map inheritedMetas)
|
||||
public void secondPass(Map<String, PersistentClass> persistentClasses)
|
||||
throws MappingException {
|
||||
bindStarToManySecondPass(
|
||||
persistentClasses,
|
||||
|
@ -100,26 +98,21 @@ public class ListBinder extends CollectionBinder {
|
|||
|
||||
private void bindIndex(XProperty property, XClass collType, final MetadataBuildingContext buildingContext) {
|
||||
final PropertyHolder valueHolder = PropertyHolderBuilder.buildPropertyHolder(
|
||||
this.collection,
|
||||
StringHelper.qualify( this.collection.getRole(), "key" ),
|
||||
collection,
|
||||
StringHelper.qualify( collection.getRole(), "key" ),
|
||||
null,
|
||||
null,
|
||||
propertyHolder,
|
||||
getBuildingContext()
|
||||
);
|
||||
|
||||
final List listValueMapping = (List) this.collection;
|
||||
|
||||
if ( indexColumn.isImplicit() ) {
|
||||
// create it
|
||||
assert true;
|
||||
}
|
||||
final List listValueMapping = (List) collection;
|
||||
|
||||
if ( !listValueMapping.isOneToMany() ) {
|
||||
indexColumn.forceNotNull();
|
||||
}
|
||||
indexColumn.setPropertyHolder( valueHolder );
|
||||
final BasicValueBinder valueBinder = new BasicValueBinder( BasicValueBinder.Kind.LIST_INDEX, buildingContext );
|
||||
final BasicValueBinder<?> valueBinder = new BasicValueBinder<>( BasicValueBinder.Kind.LIST_INDEX, buildingContext );
|
||||
valueBinder.setColumns( new AnnotatedColumn[] { indexColumn } );
|
||||
valueBinder.setReturnedClassName( Integer.class.getName() );
|
||||
valueBinder.setType( property, collType, null, null );
|
||||
|
|
|
@ -94,7 +94,7 @@ public class MapBinder extends CollectionBinder {
|
|||
final TableBinder assocTableBinder,
|
||||
final MetadataBuildingContext buildingContext) {
|
||||
return new CollectionSecondPass( buildingContext, MapBinder.this.collection ) {
|
||||
public void secondPass(Map persistentClasses, Map inheritedMetas)
|
||||
public void secondPass(Map<String, PersistentClass> persistentClasses)
|
||||
throws MappingException {
|
||||
bindStarToManySecondPass(
|
||||
persistentClasses, collType, fkJoinColumns, keyColumns, inverseColumns, elementColumns,
|
||||
|
@ -154,7 +154,7 @@ public class MapBinder extends CollectionBinder {
|
|||
|
||||
private void bindKeyFromAssociationTable(
|
||||
XClass collType,
|
||||
Map persistentClasses,
|
||||
Map<String, PersistentClass> persistentClasses,
|
||||
String mapKeyPropertyName,
|
||||
XProperty property,
|
||||
boolean isEmbedded,
|
||||
|
@ -164,7 +164,7 @@ public class MapBinder extends CollectionBinder {
|
|||
String targetPropertyName) {
|
||||
if ( mapKeyPropertyName != null ) {
|
||||
//this is an EJB3 @MapKey
|
||||
PersistentClass associatedClass = (PersistentClass) persistentClasses.get( collType.getName() );
|
||||
PersistentClass associatedClass = persistentClasses.get( collType.getName() );
|
||||
if ( associatedClass == null ) throw new AnnotationException( "Associated class not found: " + collType );
|
||||
Property mapProperty = BinderHelper.findPropertyByName( associatedClass, mapKeyPropertyName );
|
||||
if ( mapProperty == null ) {
|
||||
|
@ -202,7 +202,7 @@ public class MapBinder extends CollectionBinder {
|
|||
else {
|
||||
mapKeyType = property.getMapKey().getName();
|
||||
}
|
||||
PersistentClass collectionEntity = (PersistentClass) persistentClasses.get( mapKeyType );
|
||||
PersistentClass collectionEntity = persistentClasses.get( mapKeyType );
|
||||
boolean isIndexOfEntities = collectionEntity != null;
|
||||
ManyToOne element = null;
|
||||
org.hibernate.mapping.Map mapValue = (org.hibernate.mapping.Map) this.collection;
|
||||
|
|
|
@ -71,7 +71,7 @@ public class PropertyBinder {
|
|||
private boolean insertable = true;
|
||||
private boolean updatable = true;
|
||||
private String cascade;
|
||||
private BasicValueBinder basicValueBinder;
|
||||
private BasicValueBinder<?> basicValueBinder;
|
||||
private XClass declaringClass;
|
||||
private boolean declaringClassSet;
|
||||
private boolean embedded;
|
||||
|
@ -99,7 +99,6 @@ public class PropertyBinder {
|
|||
private XClass returnedClass;
|
||||
private boolean isId;
|
||||
private Map<XClass, InheritanceState> inheritanceStatePerClass;
|
||||
private Property mappingProperty;
|
||||
|
||||
public void setInsertable(boolean insertable) {
|
||||
this.insertable = insertable;
|
||||
|
@ -180,7 +179,7 @@ public class PropertyBinder {
|
|||
final String containerClassName = holder.getClassName();
|
||||
holder.startingProperty( property );
|
||||
|
||||
basicValueBinder = new BasicValueBinder( BasicValueBinder.Kind.ATTRIBUTE, buildingContext );
|
||||
basicValueBinder = new BasicValueBinder<>( BasicValueBinder.Kind.ATTRIBUTE, buildingContext );
|
||||
basicValueBinder.setPropertyName( name );
|
||||
basicValueBinder.setReturnedClassName( returnedClassName );
|
||||
basicValueBinder.setColumns( columns );
|
||||
|
@ -202,7 +201,7 @@ public class PropertyBinder {
|
|||
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
private void callAttributeBinders(Property prop) {
|
||||
final Annotation containingAnnotation = findContainingAnnotation( property, AttributeBinderType.class, buildingContext );
|
||||
final Annotation containingAnnotation = findContainingAnnotation( property, AttributeBinderType.class);
|
||||
if ( containingAnnotation != null ) {
|
||||
final AttributeBinderType binderAnn = containingAnnotation.annotationType().getAnnotation( AttributeBinderType.class );
|
||||
try {
|
||||
|
@ -302,30 +301,29 @@ public class PropertyBinder {
|
|||
public Property makeProperty() {
|
||||
validateMake();
|
||||
LOG.debugf( "Building property %s", name );
|
||||
Property prop = new Property();
|
||||
prop.setName( name );
|
||||
prop.setValue( value );
|
||||
prop.setLazy( lazy );
|
||||
prop.setLazyGroup( lazyGroup );
|
||||
prop.setCascade( cascade );
|
||||
prop.setPropertyAccessorName( accessType.getType() );
|
||||
prop.setReturnedClassName( returnedClassName );
|
||||
Property property = new Property();
|
||||
property.setName( name );
|
||||
property.setValue( value );
|
||||
property.setLazy( lazy );
|
||||
property.setLazyGroup( lazyGroup );
|
||||
property.setCascade( cascade );
|
||||
property.setPropertyAccessorName( accessType.getType() );
|
||||
property.setReturnedClassName( returnedClassName );
|
||||
|
||||
if ( property != null ) {
|
||||
handleNaturalId( prop );
|
||||
prop.setValueGenerationStrategy( determineValueGenerationStrategy( property ) );
|
||||
if ( this.property != null ) {
|
||||
handleNaturalId( property );
|
||||
property.setValueGenerationStrategy( determineValueGenerationStrategy(this.property) );
|
||||
// HHH-4635 -- needed for dialect-specific property ordering
|
||||
prop.setLob( property.isAnnotationPresent(Lob.class) );
|
||||
property.setLob( this.property.isAnnotationPresent(Lob.class) );
|
||||
}
|
||||
|
||||
prop.setInsertable( insertable );
|
||||
prop.setUpdateable( updatable );
|
||||
property.setInsertable( insertable );
|
||||
property.setUpdateable( updatable );
|
||||
|
||||
inferOptimisticLocking(prop);
|
||||
inferOptimisticLocking(property);
|
||||
|
||||
LOG.tracev( "Cascading {0} with {1}", name, cascade );
|
||||
this.mappingProperty = prop;
|
||||
return prop;
|
||||
return property;
|
||||
}
|
||||
|
||||
private void handleNaturalId(Property prop) {
|
||||
|
@ -516,7 +514,7 @@ public class PropertyBinder {
|
|||
}
|
||||
|
||||
private boolean isToOneValue(Value value) {
|
||||
return ToOne.class.isInstance( value );
|
||||
return value instanceof ToOne;
|
||||
}
|
||||
|
||||
public void setProperty(XProperty property) {
|
||||
|
@ -527,7 +525,7 @@ public class PropertyBinder {
|
|||
this.returnedClass = returnedClass;
|
||||
}
|
||||
|
||||
public BasicValueBinder getBasicValueBinder() {
|
||||
public BasicValueBinder<?> getBasicValueBinder() {
|
||||
return basicValueBinder;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ import org.hibernate.annotations.OrderBy;
|
|||
import org.hibernate.boot.spi.MetadataBuildingContext;
|
||||
import org.hibernate.mapping.Collection;
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
import org.hibernate.mapping.SemanticsResolver;
|
||||
import org.hibernate.resource.beans.spi.ManagedBean;
|
||||
import org.hibernate.usertype.UserCollectionType;
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
package org.hibernate.cfg.annotations;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import jakarta.persistence.UniqueConstraint;
|
||||
|
||||
|
@ -596,8 +595,8 @@ public class TableBinder {
|
|||
else if ( value instanceof DependantValue ) {
|
||||
String propertyName = columns[0].getPropertyName();
|
||||
if ( propertyName != null ) {
|
||||
Collection collection = (Collection) referencedEntity.getRecursiveProperty( propertyName )
|
||||
.getValue();
|
||||
Collection collection = (Collection)
|
||||
referencedEntity.getRecursiveProperty( propertyName ).getValue();
|
||||
referencedPropertyName = collection.getReferencedPropertyName();
|
||||
}
|
||||
else {
|
||||
|
@ -712,18 +711,19 @@ public class TableBinder {
|
|||
|
||||
public static void linkJoinColumnWithValueOverridingNameIfImplicit(
|
||||
PersistentClass referencedEntity,
|
||||
Value v,
|
||||
Value value,
|
||||
AnnotatedJoinColumn[] columns,
|
||||
SimpleValue value) {
|
||||
Iterator<Selectable> columnIterator = v.getColumnIterator();
|
||||
for (AnnotatedJoinColumn joinCol : columns) {
|
||||
Column synthCol = (Column) columnIterator.next();
|
||||
SimpleValue simpleValue) {
|
||||
List<Column> valueColumns = value.getColumns();
|
||||
for ( int i = 0; i < columns.length; i++ ) {
|
||||
AnnotatedJoinColumn joinCol = columns[i];
|
||||
Column synthCol = valueColumns.get(i);
|
||||
if ( joinCol.isNameDeferred() ) {
|
||||
//this has to be the default value
|
||||
joinCol.linkValueUsingDefaultColumnNaming( synthCol, referencedEntity, value );
|
||||
joinCol.linkValueUsingDefaultColumnNaming( synthCol, referencedEntity, simpleValue );
|
||||
}
|
||||
else {
|
||||
joinCol.linkWithValue( value );
|
||||
joinCol.linkWithValue( simpleValue );
|
||||
joinCol.overrideFromReferencedColumnIfNecessary( synthCol );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ public class BeanValidationEventListener
|
|||
);
|
||||
|
||||
private ValidatorFactory factory;
|
||||
private ConcurrentHashMap<EntityPersister, Set<String>> associationsPerEntityPersister = new ConcurrentHashMap<>();
|
||||
private final ConcurrentHashMap<EntityPersister, Set<String>> associationsPerEntityPersister = new ConcurrentHashMap<>();
|
||||
private GroupsPerOperation groupsPerOperation;
|
||||
boolean initialized;
|
||||
|
||||
|
@ -59,18 +59,18 @@ public class BeanValidationEventListener
|
|||
* @param factory The {@code ValidatorFactory} to use to create {@code Validator} instance(s)
|
||||
* @param settings Configured properties
|
||||
*/
|
||||
public BeanValidationEventListener(ValidatorFactory factory, Map settings, ClassLoaderService classLoaderService) {
|
||||
public BeanValidationEventListener(ValidatorFactory factory, Map<String,Object> settings, ClassLoaderService classLoaderService) {
|
||||
init( factory, settings, classLoaderService );
|
||||
}
|
||||
|
||||
public void initialize(Map settings, ClassLoaderService classLoaderService) {
|
||||
public void initialize(Map<String,Object> settings, ClassLoaderService classLoaderService) {
|
||||
if ( !initialized ) {
|
||||
ValidatorFactory factory = Validation.buildDefaultValidatorFactory();
|
||||
init( factory, settings, classLoaderService );
|
||||
}
|
||||
}
|
||||
|
||||
private void init(ValidatorFactory factory, Map settings, ClassLoaderService classLoaderService) {
|
||||
private void init(ValidatorFactory factory, Map<String,Object> settings, ClassLoaderService classLoaderService) {
|
||||
this.factory = factory;
|
||||
groupsPerOperation = GroupsPerOperation.from( settings, new ClassLoaderAccessImpl( classLoaderService ) );
|
||||
initialized = true;
|
||||
|
|
|
@ -13,10 +13,12 @@ import java.util.Set;
|
|||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.boot.Metadata;
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.boot.spi.BootstrapContext;
|
||||
import org.hibernate.engine.config.spi.ConfigurationService;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.integrator.spi.Integrator;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.service.spi.ServiceRegistryImplementor;
|
||||
import org.hibernate.service.spi.SessionFactoryServiceRegistry;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
@ -47,11 +49,10 @@ public class BeanValidationIntegrator implements Integrator {
|
|||
*
|
||||
* @param object The supposed ValidatorFactory instance
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void validateFactory(Object object) {
|
||||
try {
|
||||
// this direct usage of ClassLoader should be fine since the classes exist in the same jar
|
||||
final Class activatorClass = BeanValidationIntegrator.class.getClassLoader().loadClass( ACTIVATOR_CLASS_NAME );
|
||||
final Class<?> activatorClass = BeanValidationIntegrator.class.getClassLoader().loadClass( ACTIVATOR_CLASS_NAME );
|
||||
try {
|
||||
final Method validateMethod = activatorClass.getMethod( VALIDATE_SUPPLIED_FACTORY_METHOD_NAME, Object.class );
|
||||
try {
|
||||
|
@ -83,10 +84,10 @@ public class BeanValidationIntegrator implements Integrator {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void integrate(
|
||||
final Metadata metadata,
|
||||
final SessionFactoryImplementor sessionFactory,
|
||||
final SessionFactoryServiceRegistry serviceRegistry) {
|
||||
public void integrate(Metadata metadata,
|
||||
BootstrapContext bootstrapContext,
|
||||
SessionFactoryImplementor sessionFactory) {
|
||||
ServiceRegistryImplementor serviceRegistry = sessionFactory.getServiceRegistry();
|
||||
final ConfigurationService cfgService = serviceRegistry.getService( ConfigurationService.class );
|
||||
// IMPL NOTE : see the comments on ActivationContext.getValidationModes() as to why this is multi-valued...
|
||||
Object modeSetting = cfgService.getSettings().get( MODE_PROPERTY );
|
||||
|
@ -108,8 +109,7 @@ public class BeanValidationIntegrator implements Integrator {
|
|||
if ( isBeanValidationApiAvailable( classLoaderService ) ) {
|
||||
// and if so, call out to the TypeSafeActivator
|
||||
try {
|
||||
final Class typeSafeActivatorClass = loadTypeSafeActivatorClass( classLoaderService );
|
||||
@SuppressWarnings("unchecked")
|
||||
final Class<?> typeSafeActivatorClass = loadTypeSafeActivatorClass( classLoaderService );
|
||||
final Method activateMethod = typeSafeActivatorClass.getMethod( ACTIVATE_METHOD_NAME, ActivationContext.class );
|
||||
final ActivationContext activationContext = new ActivationContext() {
|
||||
@Override
|
||||
|
@ -129,7 +129,7 @@ public class BeanValidationIntegrator implements Integrator {
|
|||
|
||||
@Override
|
||||
public SessionFactoryServiceRegistry getServiceRegistry() {
|
||||
return serviceRegistry;
|
||||
return (SessionFactoryServiceRegistry) serviceRegistry;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -137,8 +137,8 @@ public class BeanValidationIntegrator implements Integrator {
|
|||
activateMethod.invoke( null, activationContext );
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
if ( HibernateException.class.isInstance( e.getTargetException() ) ) {
|
||||
throw ( (HibernateException) e.getTargetException() );
|
||||
if ( e.getTargetException() instanceof HibernateException ) {
|
||||
throw (HibernateException) e.getTargetException();
|
||||
}
|
||||
throw new IntegrationException( "Error activating Bean Validation integration", e.getTargetException() );
|
||||
}
|
||||
|
@ -160,17 +160,16 @@ public class BeanValidationIntegrator implements Integrator {
|
|||
private boolean isBeanValidationApiAvailable(ClassLoaderService classLoaderService) {
|
||||
try {
|
||||
classLoaderService.classForName( BV_CHECK_CLASS );
|
||||
return true;
|
||||
}
|
||||
catch (Exception e) {
|
||||
try {
|
||||
classLoaderService.classForName( JAKARTA_BV_CHECK_CLASS );
|
||||
return true;
|
||||
}
|
||||
catch (Exception e2) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -187,7 +186,7 @@ public class BeanValidationIntegrator implements Integrator {
|
|||
}
|
||||
}
|
||||
|
||||
private Class loadTypeSafeActivatorClass(ClassLoaderService classLoaderService) {
|
||||
private Class<?> loadTypeSafeActivatorClass(ClassLoaderService classLoaderService) {
|
||||
try {
|
||||
return classLoaderService.classForName( ACTIVATOR_CLASS_NAME );
|
||||
}
|
||||
|
|
|
@ -16,8 +16,8 @@ public class DuplicationStrategyImpl implements DuplicationStrategy {
|
|||
|
||||
@Override
|
||||
public boolean areMatch(Object listener, Object original) {
|
||||
return listener.getClass().equals( original.getClass() ) &&
|
||||
BeanValidationEventListener.class.equals( listener.getClass() );
|
||||
return listener.getClass().equals( original.getClass() )
|
||||
&& BeanValidationEventListener.class.equals( listener.getClass() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -28,7 +28,7 @@ public class GroupsPerOperation {
|
|||
private static final Class<?>[] DEFAULT_GROUPS = new Class<?>[] { Default.class };
|
||||
private static final Class<?>[] EMPTY_GROUPS = new Class<?>[] { };
|
||||
|
||||
private Map<Operation, Class<?>[]> groupsPerOperation = CollectionHelper.mapOfSize( 4 );
|
||||
private final Map<Operation, Class<?>[]> groupsPerOperation = CollectionHelper.mapOfSize( 4 );
|
||||
|
||||
private GroupsPerOperation() {
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ public class HibernateTraversableResolver implements TraversableResolver {
|
|||
if ( traversableProperty.getName() == null ) {
|
||||
throw new AssertionFailure(
|
||||
"TraversableResolver being passed a traversableProperty with null name. pathToTraversableObject: "
|
||||
+ path.toString() );
|
||||
+ path );
|
||||
}
|
||||
path.append( traversableProperty.getName() );
|
||||
|
||||
|
|
|
@ -160,7 +160,7 @@ class TypeSafeActivator {
|
|||
public static void applyRelationalConstraints(
|
||||
ValidatorFactory factory,
|
||||
Collection<PersistentClass> persistentClasses,
|
||||
Map settings,
|
||||
Map<String,Object> settings,
|
||||
Dialect dialect,
|
||||
ClassLoaderAccess classLoaderAccess) {
|
||||
Class<?>[] groupsArray = GroupsPerOperation.buildGroupsForOperation(
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
*/
|
||||
package org.hibernate.cfg.beanvalidation;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -26,7 +25,7 @@ public enum ValidationMode {
|
|||
|
||||
private final String externalForm;
|
||||
|
||||
private ValidationMode(String externalForm) {
|
||||
ValidationMode(String externalForm) {
|
||||
this.externalForm = externalForm;
|
||||
}
|
||||
|
||||
|
@ -36,8 +35,7 @@ public enum ValidationMode {
|
|||
modes.add( ValidationMode.AUTO );
|
||||
}
|
||||
else {
|
||||
final String[] modesInString = modeProperty.toString().split( "," );
|
||||
for ( String modeInString : modesInString ) {
|
||||
for ( String modeInString : modeProperty.toString().split( "," ) ) {
|
||||
modes.add( getMode(modeInString) );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,17 +28,14 @@ import jakarta.persistence.AttributeConverter;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public class ConvertedJdbcMapping<T> implements JdbcMapping {
|
||||
private final ManagedBean<AttributeConverter<?, ?>> converterBean;
|
||||
|
||||
private final JavaType<T> domainJtd;
|
||||
private final JavaType<?> relationalJtd;
|
||||
private final JdbcType jdbcType;
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public ConvertedJdbcMapping(
|
||||
ManagedBean<AttributeConverter<?, ?>> converterBean,
|
||||
TypeConfiguration typeConfiguration) {
|
||||
this.converterBean = converterBean;
|
||||
|
||||
final JavaTypeRegistry jtdRegistry = typeConfiguration.getJavaTypeRegistry();
|
||||
final JavaType<? extends AttributeConverter<?,?>> converterJtd = jtdRegistry.resolveDescriptor( converterBean.getBeanClass() );
|
||||
|
@ -50,6 +47,7 @@ public class ConvertedJdbcMapping<T> implements JdbcMapping {
|
|||
this.domainJtd = jtdRegistry.resolveDescriptor( domainJavaClass );
|
||||
this.relationalJtd = jtdRegistry.resolveDescriptor( relationalJavaClass );
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
final JpaAttributeConverterImpl converterDescriptor = new JpaAttributeConverterImpl(
|
||||
converterBean,
|
||||
converterJtd,
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
*/
|
||||
package org.hibernate.cfg.internal;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.MappingException;
|
||||
|
|
|
@ -71,10 +71,11 @@ public class UnsavedValueFactory {
|
|||
}
|
||||
|
||||
/**
|
||||
* Return the UnsavedValueStrategy for determining whether an entity instance is
|
||||
* unsaved based on the version. If an explicit strategy is not specified, determine the
|
||||
* unsaved value by instantiating an instance of the entity and reading the value of its
|
||||
* version property, or if that is not possible, using the java default value for the type
|
||||
* Return the {@link org.hibernate.engine.spi.UnsavedValueStrategy} for determining
|
||||
* whether an entity instance is unsaved based on the version. If an explicit strategy
|
||||
* is not specified, determine the unsaved value by instantiating an instance of the
|
||||
* entity and reading the value of its version property, or if that is not possible,
|
||||
* using the java default value for the type.
|
||||
*/
|
||||
public static <T> VersionValue getUnsavedVersionValue(
|
||||
KeyValue bootVersionMapping,
|
||||
|
@ -84,8 +85,9 @@ public class UnsavedValueFactory {
|
|||
final String unsavedValue = bootVersionMapping.getNullValue();
|
||||
if ( unsavedValue == null ) {
|
||||
if ( getter != null && templateInstanceAccess != null ) {
|
||||
Object templateInstance = templateInstanceAccess.get();
|
||||
@SuppressWarnings("unchecked")
|
||||
final T defaultValue = (T) getter.get( templateInstanceAccess.get() );
|
||||
final T defaultValue = (T) getter.get( templateInstance );
|
||||
|
||||
// if the version of a newly instantiated object is not the same
|
||||
// as the version seed value, use that as the unsaved-value
|
||||
|
@ -98,18 +100,18 @@ public class UnsavedValueFactory {
|
|||
return VersionValue.UNDEFINED;
|
||||
}
|
||||
}
|
||||
else if ( "undefined".equals( unsavedValue ) ) {
|
||||
return VersionValue.UNDEFINED;
|
||||
}
|
||||
else if ( "null".equals( unsavedValue ) ) {
|
||||
return VersionValue.NULL;
|
||||
}
|
||||
else if ( "negative".equals( unsavedValue ) ) {
|
||||
return VersionValue.NEGATIVE;
|
||||
}
|
||||
else {
|
||||
// this should not happen since the DTD prevents it
|
||||
throw new MappingException( "Could not parse version unsaved-value: " + unsavedValue );
|
||||
switch (unsavedValue) {
|
||||
case "undefined":
|
||||
return VersionValue.UNDEFINED;
|
||||
case "null":
|
||||
return VersionValue.NULL;
|
||||
case "negative":
|
||||
return VersionValue.NEGATIVE;
|
||||
default:
|
||||
// this should not happen since the DTD prevents it
|
||||
throw new MappingException("Could not parse version unsaved-value: " + unsavedValue);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -165,18 +167,18 @@ public class UnsavedValueFactory {
|
|||
return VersionValue.UNDEFINED;
|
||||
}
|
||||
}
|
||||
else if ( "undefined".equals( versionUnsavedValue ) ) {
|
||||
return VersionValue.UNDEFINED;
|
||||
}
|
||||
else if ( "null".equals( versionUnsavedValue ) ) {
|
||||
return VersionValue.NULL;
|
||||
}
|
||||
else if ( "negative".equals( versionUnsavedValue ) ) {
|
||||
return VersionValue.NEGATIVE;
|
||||
}
|
||||
else {
|
||||
// this should not happen since the DTD prevents it
|
||||
throw new MappingException( "Could not parse version unsaved-value: " + versionUnsavedValue );
|
||||
switch (versionUnsavedValue) {
|
||||
case "undefined":
|
||||
return VersionValue.UNDEFINED;
|
||||
case "null":
|
||||
return VersionValue.NULL;
|
||||
case "negative":
|
||||
return VersionValue.NEGATIVE;
|
||||
default:
|
||||
// this should not happen since the DTD prevents it
|
||||
throw new MappingException("Could not parse version unsaved-value: " + versionUnsavedValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ public class MergeListPreAndPostPersistTest extends BaseCoreFunctionalTestCase {
|
|||
new PreInsertEventListener() {
|
||||
@Override
|
||||
public boolean onPreInsert(PreInsertEvent event) {
|
||||
if ( Order.class.isInstance( event.getEntity() ) ) {
|
||||
if ( event.getEntity() instanceof Order ) {
|
||||
assertEquals( order, event.getEntity());
|
||||
assertEquals( order.items, ( (Order) event.getEntity() ).items );
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ public class MergeListPreAndPostPersistTest extends BaseCoreFunctionalTestCase {
|
|||
EventType.POST_INSERT,
|
||||
new PostInsertEventListener() {
|
||||
public void onPostInsert(PostInsertEvent event) {
|
||||
if ( Order.class.isInstance( event.getEntity() ) ) {
|
||||
if ( event.getEntity() instanceof Order ) {
|
||||
assertEquals( order, event.getEntity());
|
||||
assertEquals( order.items, ( (Order) event.getEntity() ).items );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue