diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/Tuplizer.java b/hibernate-core/src/main/java/org/hibernate/annotations/Tuplizer.java index 1f8037cf33..c92e6e8864 100644 --- a/hibernate-core/src/main/java/org/hibernate/annotations/Tuplizer.java +++ b/hibernate-core/src/main/java/org/hibernate/annotations/Tuplizer.java @@ -1,50 +1,50 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * Copyright (c) 2010, Red Hat Inc. or third-party contributors as - * indicated by the @author tags or express copyright attribution - * statements applied by the authors. All third-party contributions are - * distributed under license by Red Hat Inc. - * - * This copyrighted material is made available to anyone wishing to use, modify, - * copy, or redistribute it subject to the terms and conditions of the GNU - * Lesser General Public License, as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY - * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this distribution; if not, write to: - * Free Software Foundation, Inc. - * 51 Franklin Street, Fifth Floor - * Boston, MA 02110-1301 USA - */ -package org.hibernate.annotations; -import java.lang.annotation.Retention; - -import org.hibernate.EntityMode; - -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -/** - * Define a tuplizer for an entity or a component - * @author Emmanuel Bernard - */ -@java.lang.annotation.Target( {TYPE, FIELD, METHOD} ) -@Retention( RUNTIME ) -public @interface Tuplizer { - /** tuplizer implementation */ - Class impl(); - /** - * either pojo, dynamic-map or dom4j - * @deprecated should use #entityModeType instead - */ - @Deprecated - String entityMode() default "pojo"; - EntityMode entityModeType() default EntityMode.POJO; -} +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2010, Red Hat Inc. or third-party contributors as + * indicated by the @author tags or express copyright attribution + * statements applied by the authors. All third-party contributions are + * distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ +package org.hibernate.annotations; +import java.lang.annotation.Retention; + +import org.hibernate.EntityMode; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +/** + * Define a tuplizer for an entity or a component + * @author Emmanuel Bernard + */ +@java.lang.annotation.Target( {TYPE, FIELD, METHOD} ) +@Retention( RUNTIME ) +public @interface Tuplizer { + /** tuplizer implementation */ + Class impl(); + /** + * either pojo, dynamic-map + * @deprecated should use #entityModeType instead + */ + @Deprecated + String entityMode() default "pojo"; + EntityMode entityModeType() default EntityMode.POJO; +} diff --git a/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultLoadEventListener.java b/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultLoadEventListener.java index ea0ce79ae6..2fd264104b 100644 --- a/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultLoadEventListener.java +++ b/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultLoadEventListener.java @@ -325,7 +325,7 @@ public class DefaultLoadEventListener extends AbstractLockUpgradeEventListener i } return existing; } - LOG.trace( "Creating new proxy for entity" ); + LOG.trace( "Creating new proxy for entity: " + event.getEntityClassName() ); // return new uninitialized proxy Object proxy = persister.createProxy( event.getEntityId(), event.getSession() ); persistenceContext.getBatchFetchQueue().addBatchLoadableEntityKey( keyToLoad ); diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/OneToManyPluralAttributeElementSourceImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/OneToManyPluralAttributeElementSourceImpl.java index a3d5b3010b..835c584fc0 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/OneToManyPluralAttributeElementSourceImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/OneToManyPluralAttributeElementSourceImpl.java @@ -28,6 +28,7 @@ import java.util.Collections; import org.hibernate.AssertionFailure; import org.hibernate.engine.spi.CascadeStyle; import org.hibernate.metamodel.internal.source.annotations.attribute.PluralAssociationAttribute; +import org.hibernate.metamodel.internal.source.annotations.util.EnumConversionHelper; import org.hibernate.metamodel.spi.source.OneToManyPluralAttributeElementSource; /** @@ -52,8 +53,7 @@ public class OneToManyPluralAttributeElementSourceImpl implements OneToManyPlura @Override public Iterable getCascadeStyles() { - // TODO - return Collections.emptyList(); + return EnumConversionHelper.cascadeTypeToCascadeStyleSet( associationAttribute.getCascadeTypes(), associationAttribute.getContext() ); } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/PluralAttributeSourceImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/PluralAttributeSourceImpl.java index 8c6ed5d4f4..62791a77ce 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/PluralAttributeSourceImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/PluralAttributeSourceImpl.java @@ -73,6 +73,11 @@ public class PluralAttributeSourceImpl implements PluralAttributeSource, Orderab return elementSource; } + @Override + public String getMappedBy() { + return associationAttribute.getMappedBy(); + } + private PluralAttributeElementSource determineElementSource() { switch ( associationAttribute.getNature() ) { case MANY_TO_MANY: diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/ToOneAttributeSourceImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/ToOneAttributeSourceImpl.java index d8d8cef08b..738a12db73 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/ToOneAttributeSourceImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/ToOneAttributeSourceImpl.java @@ -161,6 +161,11 @@ public class ToOneAttributeSourceImpl extends SingularAttributeSourceImpl implem } } + @Override + public boolean isUnWrapProxy() { + return associationAttribute.isUnWrapProxy(); + } + @Override public String toString() { final StringBuilder sb = new StringBuilder(); diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/attribute/AssociationAttribute.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/attribute/AssociationAttribute.java index 58f9529e1c..096cdf78bb 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/attribute/AssociationAttribute.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/attribute/AssociationAttribute.java @@ -37,6 +37,8 @@ import org.jboss.jandex.AnnotationValue; import org.jboss.jandex.DotName; import org.jboss.logging.Logger; +import org.hibernate.annotations.FetchMode; +import org.hibernate.annotations.LazyToOneOption; import org.hibernate.annotations.NotFoundAction; import org.hibernate.engine.FetchStyle; import org.hibernate.internal.CoreMessageLogger; @@ -69,6 +71,7 @@ public class AssociationAttribute extends MappedAttribute { private final Set cascadeTypes; private final boolean isOptional; private final boolean isLazy; + private final boolean isUnWrapProxy; private final boolean isOrphanRemoval; private final FetchStyle fetchStyle; private final boolean mapsId; @@ -116,6 +119,7 @@ public class AssociationAttribute extends MappedAttribute { this.mappedBy = determineMappedByAttributeName( associationAnnotation ); this.isOptional = determineOptionality( associationAnnotation ); this.isLazy = determineIsLazy( associationAnnotation ); + this.isUnWrapProxy = determinIsUnwrapProxy(); this.isOrphanRemoval = determineOrphanRemoval( associationAnnotation ); this.cascadeTypes = determineCascadeTypes( associationAnnotation ); this.joinColumnValues = determineJoinColumnAnnotations( annotations ); @@ -180,6 +184,10 @@ public class AssociationAttribute extends MappedAttribute { return isLazy; } + public boolean isUnWrapProxy() { + return isUnWrapProxy; + } + @Override public boolean isOptional() { return isOptional; @@ -238,6 +246,14 @@ public class AssociationAttribute extends MappedAttribute { return NotFoundAction.IGNORE.equals( action ); } + private boolean determinIsUnwrapProxy() { + AnnotationInstance lazyToOne = JandexHelper.getSingleAnnotation( annotations(), HibernateDotNames.LAZY_TO_ONE ); + if ( lazyToOne != null ) { + return JandexHelper.getEnumValue( lazyToOne, "value", LazyToOneOption.class ) == LazyToOneOption.NO_PROXY; + } + return false; + } + private boolean determineOptionality(AnnotationInstance associationAnnotation) { boolean optional = true; @@ -260,7 +276,30 @@ public class AssociationAttribute extends MappedAttribute { protected boolean determineIsLazy(AnnotationInstance associationAnnotation) { FetchType fetchType = JandexHelper.getEnumValue( associationAnnotation, "fetch", FetchType.class ); - return FetchType.LAZY == fetchType; + boolean lazy = fetchType == FetchType.LAZY; + final AnnotationInstance lazyToOneAnnotation = JandexHelper.getSingleAnnotation( + annotations(), + HibernateDotNames.LAZY_TO_ONE + ); + if ( lazyToOneAnnotation != null ) { + LazyToOneOption option = JandexHelper.getEnumValue( lazyToOneAnnotation, "value", LazyToOneOption.class ); + lazy = option != LazyToOneOption.FALSE; + } + + if ( associationAnnotation.value( "fetch" ) != null ) { + lazy = FetchType.LAZY == fetchType; + } + final AnnotationInstance fetchAnnotation = JandexHelper.getSingleAnnotation( + annotations(), + HibernateDotNames.FETCH + ); + if ( fetchAnnotation != null ) { + lazy = JandexHelper.getEnumValue( fetchAnnotation, "value", FetchMode.class ) != FetchMode.JOIN; + } + if ( getFetchStyle() != null ) { + lazy = getFetchStyle() != FetchStyle.JOIN; + } + return lazy; } private String determineReferencedEntityType(AnnotationInstance associationAnnotation, Class referencedAttributeType) { diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/attribute/PluralAssociationAttribute.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/attribute/PluralAssociationAttribute.java index 84a4ee2dd5..fbea99447b 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/attribute/PluralAssociationAttribute.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/attribute/PluralAssociationAttribute.java @@ -26,12 +26,15 @@ package org.hibernate.metamodel.internal.source.annotations.attribute; import java.util.List; import java.util.Map; +import javax.persistence.FetchType; + import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.ClassInfo; import org.jboss.jandex.DotName; import org.hibernate.AnnotationException; import org.hibernate.annotations.CacheConcurrencyStrategy; +import org.hibernate.annotations.FetchMode; import org.hibernate.annotations.LazyCollectionOption; import org.hibernate.annotations.OnDeleteAction; import org.hibernate.annotations.SortType; @@ -230,8 +233,11 @@ public class PluralAssociationAttribute extends AssociationAttribute { AnnotationInstance orderColumnAnnotation = JandexHelper.getSingleAnnotation( annotations, JPADotNames.ORDER_COLUMN ); AnnotationInstance indexColumnAnnotation = JandexHelper.getSingleAnnotation( annotations, HibernateDotNames.INDEX_COLUMN ); - if(orderColumnAnnotation!=null && indexColumnAnnotation!=null){ - throw new MappingException( "@OrderColumn and @IndexColumn can't be used together on property: " + getRole() ,getContext().getOrigin() ); + if ( orderColumnAnnotation != null && indexColumnAnnotation != null ) { + throw new MappingException( + "@OrderColumn and @IndexColumn can't be used together on property: " + getRole(), + getContext().getOrigin() + ); } this.isIndexed = orderColumnAnnotation != null || indexColumnAnnotation != null; @@ -276,9 +282,11 @@ public class PluralAssociationAttribute extends AssociationAttribute { } return entityPersisterClass; } + @Override protected boolean determineIsLazy(AnnotationInstance associationAnnotation) { - boolean lazy = super.determineIsLazy( associationAnnotation ); + FetchType fetchType = JandexHelper.getEnumValue( associationAnnotation, "fetch", FetchType.class ); + boolean lazy = fetchType == FetchType.LAZY; final AnnotationInstance lazyCollectionAnnotationInstance = JandexHelper.getSingleAnnotation( annotations(), HibernateDotNames.LAZY_COLLECTION @@ -289,9 +297,19 @@ public class PluralAssociationAttribute extends AssociationAttribute { "value", LazyCollectionOption.class ); - return lazyOption == LazyCollectionOption.TRUE; + lazy = !( lazyOption == LazyCollectionOption.FALSE ); } + final AnnotationInstance fetchAnnotation = JandexHelper.getSingleAnnotation( + annotations(), + HibernateDotNames.FETCH + ); + if ( fetchAnnotation != null && fetchAnnotation.value() != null ) { + FetchMode fetchMode = FetchMode.valueOf( fetchAnnotation.value( ).asEnum().toUpperCase() ); + if ( fetchMode == FetchMode.JOIN ) { + lazy = false; + } + } return lazy; } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/entity/ConfiguredClass.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/entity/ConfiguredClass.java index 52b107d9da..b021c2048f 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/entity/ConfiguredClass.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/entity/ConfiguredClass.java @@ -44,6 +44,7 @@ import org.hibernate.AssertionFailure; import org.hibernate.EntityMode; import org.hibernate.HibernateException; import org.hibernate.internal.CoreMessageLogger; +import org.hibernate.internal.util.StringHelper; import org.hibernate.metamodel.internal.source.annotations.AnnotationBindingContext; import org.hibernate.metamodel.internal.source.annotations.attribute.AssociationAttribute; import org.hibernate.metamodel.internal.source.annotations.attribute.AttributeOverride; @@ -526,10 +527,10 @@ public class ConfiguredClass { if ( embeddableClassInfo == null ) { final String msg = String.format( "Attribute '%s#%s' is annotated with @Embedded, but '%s' does not seem to be annotated " + - "with @Embeddable. Are all annotated classes added to the configuration?", - getConfiguredClass().getSimpleName(), + "with @Embeddable.\n Are all annotated classes added to the configuration?", + getConfiguredClass().getName(), attributeName, - type.getSimpleName() + type.getName() ); throw new AnnotationException( msg ); } @@ -669,6 +670,9 @@ public class ConfiguredClass { } private Class resolveCollectionValuedReferenceType(ResolvedMember resolvedMember) { + if ( resolvedMember.getType().isArray() ) { + return resolvedMember.getType().getArrayElementType().getErasedType(); + } if ( resolvedMember.getType().getTypeParameters().isEmpty() ) { return null; // no generic at all } @@ -752,28 +756,44 @@ public class ConfiguredClass { final AnnotationInstance tuplizersAnnotation = JandexHelper.getSingleAnnotation( classInfo, HibernateDotNames.TUPLIZERS ); - if ( tuplizersAnnotation == null ) { - return null; - } - - AnnotationInstance[] annotations = JandexHelper.getValue( - tuplizersAnnotation, - "value", - AnnotationInstance[].class + final AnnotationInstance tuplizerAnnotation = JandexHelper.getSingleAnnotation( + classInfo, + HibernateDotNames.TUPLIZER ); - - AnnotationInstance pojoTuplizerAnnotation = null; - for ( AnnotationInstance tuplizerAnnotation : annotations ) { - if ( EntityMode.valueOf( tuplizerAnnotation.value( "entityModeType" ).asEnum() ) == EntityMode.POJO ) { - pojoTuplizerAnnotation = tuplizerAnnotation; - break; + if ( tuplizersAnnotation != null ) { + AnnotationInstance[] annotations = JandexHelper.getValue( + tuplizersAnnotation, + "value", + AnnotationInstance[].class + ); + for ( final AnnotationInstance annotationInstance : annotations ) { + final String impl = findTuplizerImpl( annotationInstance ); + if ( StringHelper.isNotEmpty( impl ) ) { + return impl; + } } } - - String customTuplizer = null; - if ( pojoTuplizerAnnotation != null ) { - customTuplizer = pojoTuplizerAnnotation.value( "impl" ).asString(); + else if ( tuplizerAnnotation != null ) { + final String impl = findTuplizerImpl( tuplizerAnnotation ); + if ( StringHelper.isNotEmpty( impl ) ) { + return impl; + } } - return customTuplizer; + return null; + } + + private String findTuplizerImpl(final AnnotationInstance tuplizerAnnotation) { + EntityMode mode; + if ( tuplizerAnnotation.value( "entityModeType" ) != null ) { + mode = EntityMode.valueOf( tuplizerAnnotation.value( "entityModeType" ).asEnum() ); + } + else if ( tuplizerAnnotation.value( "entityMode" ) != null ) { + mode = EntityMode.parse( tuplizerAnnotation.value( "entityMode" ).asString() ); + } + else { + mode = EntityMode.POJO; + } + return mode == EntityMode.POJO ? tuplizerAnnotation.value( "impl" ).asString() : null; + } } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/entity/EntityClass.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/entity/EntityClass.java index 77dae8640c..ff6d45882d 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/entity/EntityClass.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/entity/EntityClass.java @@ -82,7 +82,7 @@ public class EntityClass extends ConfiguredClass { private final List synchronizedTableNames; private final int batchSize; - private boolean isMutable; + private boolean isImmutable; private boolean isExplicitPolymorphism; private OptimisticLockStyle optimisticLockStyle; private String whereClause; @@ -152,7 +152,7 @@ public class EntityClass extends ConfiguredClass { } public boolean isMutable() { - return isMutable; + return !isImmutable; } public OptimisticLockStyle getOptimisticLockStyle() { @@ -287,11 +287,16 @@ public class EntityClass extends ConfiguredClass { optimisticLockStyle = OptimisticLockStyle.valueOf( optimisticLockType.name() ); AnnotationInstance hibernateImmutableAnnotation = JandexHelper.getSingleAnnotation( getClassInfo(), HibernateDotNames.IMMUTABLE, ClassInfo.class ); - isMutable = hibernateImmutableAnnotation == null - && hibernateEntityAnnotation != null - && hibernateEntityAnnotation.value( "mutable" ) != null - && hibernateEntityAnnotation.value( "mutable" ).asBoolean(); + if ( hibernateImmutableAnnotation != null ) { + isImmutable = true; + } + else if (hibernateEntityAnnotation != null + && hibernateEntityAnnotation.value( "mutable" ) != null){ + isImmutable = !hibernateEntityAnnotation.value( "mutable" ).asBoolean(); + } else { + isImmutable = false; + } final AnnotationInstance whereAnnotation = JandexHelper.getSingleAnnotation( getClassInfo(), HibernateDotNames.WHERE diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/ManyToOneAttributeSourceImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/ManyToOneAttributeSourceImpl.java index b9874278b3..67bdcf3aed 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/ManyToOneAttributeSourceImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/hbm/ManyToOneAttributeSourceImpl.java @@ -127,6 +127,14 @@ class ManyToOneAttributeSourceImpl extends AbstractHbmSourceNode implements ToOn return getFetchTiming() != FetchTiming.IMMEDIATE; } + @Override + public boolean isUnWrapProxy() { + final String lazySelection = manyToOneElement.getLazy() != null + ? manyToOneElement.getLazy().value() + : null; + return lazySelection != null && lazySelection.equals( "no-proxy" ); + } + @Override public SingularAttributeBinding.NaturalIdMutability getNaturalIdMutability() { return naturalIdMutability; diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/spi/binding/ManyToOneAttributeBinding.java b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/binding/ManyToOneAttributeBinding.java index 4af0566bd3..392df13f64 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/spi/binding/ManyToOneAttributeBinding.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/binding/ManyToOneAttributeBinding.java @@ -53,7 +53,7 @@ public class ManyToOneAttributeBinding private CascadeStyle cascadeStyle; private FetchTiming fetchTiming; private FetchStyle fetchStyle; - + private boolean isUnWrapProxy; public ManyToOneAttributeBinding( AttributeBindingContainer container, SingularAttribute attribute, @@ -180,6 +180,14 @@ public class ManyToOneAttributeBinding } } + public boolean isUnWrapProxy() { + return isUnWrapProxy; + } + + public void setUnWrapProxy(boolean unWrapProxy) { + isUnWrapProxy = unWrapProxy; + } + @Override public final EntityBinding getReferencedEntityBinding() { return referencedEntityBinding; diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/spi/binding/SingularAssociationAttributeBinding.java b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/binding/SingularAssociationAttributeBinding.java index 37b0b36898..5770808b07 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/spi/binding/SingularAssociationAttributeBinding.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/binding/SingularAssociationAttributeBinding.java @@ -41,4 +41,6 @@ public interface SingularAssociationAttributeBinding extends SingularAttributeBi public EntityBinding getReferencedEntityBinding(); public SingularAttributeBinding getReferencedAttributeBinding(); + public boolean isUnWrapProxy(); + public void setUnWrapProxy(boolean unWrapProxy); } \ No newline at end of file diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/ToOneAttributeSource.java b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/ToOneAttributeSource.java index 8a5b537578..acf8b9cb0c 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/ToOneAttributeSource.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/source/ToOneAttributeSource.java @@ -43,6 +43,6 @@ public interface ToOneAttributeSource * @return The name of the referenced entity */ public String getReferencedEntityName(); - + public boolean isUnWrapProxy(); public List getDefaultNamingStrategies(final String entityName, final String tableName, final AttributeBinding referencedAttributeBinding); } diff --git a/hibernate-core/src/main/java/org/hibernate/type/EnumType.java b/hibernate-core/src/main/java/org/hibernate/type/EnumType.java index 0cf1a17d5f..081bd39247 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/EnumType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/EnumType.java @@ -250,16 +250,25 @@ public class EnumType implements EnhancedUserType, DynamicParameterizedType, Ser @Override public String objectToSQLString(Object value) { + if(enumValueMapper==null){ + guessTypeOfEnumValueMapper( sqlType ); + } return enumValueMapper.objectToSQLString( (Enum) value ); } @Override public String toXMLString(Object value) { + if(enumValueMapper==null){ + guessTypeOfEnumValueMapper( sqlType ); + } return enumValueMapper.toXMLString( (Enum) value ); } @Override public Object fromXMLString(String xmlValue) { + if(enumValueMapper==null){ + guessTypeOfEnumValueMapper( sqlType ); + } return enumValueMapper.fromXMLString( xmlValue ); }