From 78c8c6fb6a5e2f6ac759c3e599c0fed73c0a1aa4 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Thu, 20 May 2010 21:55:28 +0000 Subject: [PATCH] HHH-5248 - Introduce CompositeType interface (to replace AbstractComponentType interface) git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@19572 1b8cb986-b30d-0410-93ca-fae66ebed9b2 --- .../HibernateTraversableResolver.java | 27 +++- .../java/org/hibernate/criterion/Example.java | 19 ++- .../org/hibernate/criterion/InExpression.java | 11 +- .../java/org/hibernate/engine/Cascade.java | 6 +- .../org/hibernate/engine/ForeignKeys.java | 9 +- .../org/hibernate/engine/Nullability.java | 13 +- .../hibernate/event/def/AbstractVisitor.java | 12 +- .../def/DefaultRefreshEventListener.java | 10 +- .../hibernate/event/def/ReattachVisitor.java | 9 +- .../org/hibernate/event/def/WrapVisitor.java | 9 +- .../java/org/hibernate/loader/JoinWalker.java | 19 ++- .../loader/entity/EntityJoinWalker.java | 21 ++- .../java/org/hibernate/mapping/Property.java | 6 +- .../AbstractCollectionPersister.java | 11 +- .../CompositeElementPropertyMapping.java | 11 +- .../entity/AbstractEntityPersister.java | 18 +-- .../entity/AbstractPropertyMapping.java | 9 +- .../org/hibernate/proxy/ProxyFactory.java | 11 +- .../proxy/dom4j/Dom4jProxyFactory.java | 23 ++- .../hibernate/proxy/map/MapProxyFactory.java | 29 ++-- .../proxy/pojo/BasicLazyInitializer.java | 20 +-- .../pojo/cglib/CGLIBLazyInitializer.java | 40 +++-- .../proxy/pojo/cglib/CGLIBProxyFactory.java | 11 +- .../proxy/pojo/cglib/SerializableProxy.java | 29 ++-- .../javassist/JavassistLazyInitializer.java | 13 +- .../pojo/javassist/JavassistProxyFactory.java | 11 +- .../pojo/javassist/SerializableProxy.java | 29 ++-- .../tuple/entity/AbstractEntityTuplizer.java | 11 +- .../tuple/entity/Dom4jEntityTuplizer.java | 52 +++--- .../tuple/entity/EntityMetamodel.java | 23 ++- .../tuple/entity/PojoEntityTuplizer.java | 20 +-- .../hibernate/type/AbstractComponentType.java | 44 +---- .../main/java/org/hibernate/type/AnyType.java | 2 +- .../org/hibernate/type/ComponentType.java | 2 +- .../hibernate/type/CompositeCustomType.java | 2 +- .../org/hibernate/type/CompositeType.java | 151 ++++++++++++++++++ .../main/java/org/hibernate/type/Type.java | 6 +- .../java/org/hibernate/type/TypeHelper.java | 2 +- 38 files changed, 430 insertions(+), 321 deletions(-) create mode 100644 core/src/main/java/org/hibernate/type/CompositeType.java diff --git a/annotations/src/main/java/org/hibernate/cfg/beanvalidation/HibernateTraversableResolver.java b/annotations/src/main/java/org/hibernate/cfg/beanvalidation/HibernateTraversableResolver.java index 8f2f14a12f..17e2650fc6 100644 --- a/annotations/src/main/java/org/hibernate/cfg/beanvalidation/HibernateTraversableResolver.java +++ b/annotations/src/main/java/org/hibernate/cfg/beanvalidation/HibernateTraversableResolver.java @@ -1,3 +1,26 @@ +/* + * 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.cfg.beanvalidation; import java.lang.annotation.ElementType; @@ -11,9 +34,9 @@ import org.hibernate.persister.entity.EntityPersister; import org.hibernate.Hibernate; import org.hibernate.annotations.common.AssertionFailure; import org.hibernate.engine.SessionFactoryImplementor; +import org.hibernate.type.CompositeType; import org.hibernate.type.Type; import org.hibernate.type.CollectionType; -import org.hibernate.type.AbstractComponentType; /** * Use Hibernate metadata to ignore cascade on entities. @@ -56,7 +79,7 @@ public class HibernateTraversableResolver implements TraversableResolver { else if ( type.isEntityType() || type.isAnyType() ) { associations.add( prefix + name ); } else if ( type.isComponentType() ) { - AbstractComponentType componentType = (AbstractComponentType) type; + CompositeType componentType = (CompositeType) type; addAssociationsToTheSetForAllProperties( componentType.getPropertyNames(), componentType.getSubtypes(), diff --git a/core/src/main/java/org/hibernate/criterion/Example.java b/core/src/main/java/org/hibernate/criterion/Example.java index 8b0f0f7b76..0ec55c60cc 100644 --- a/core/src/main/java/org/hibernate/criterion/Example.java +++ b/core/src/main/java/org/hibernate/criterion/Example.java @@ -1,10 +1,10 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as + * 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 Middleware LLC. + * 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 @@ -20,7 +20,6 @@ * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA - * */ package org.hibernate.criterion; @@ -35,7 +34,7 @@ import org.hibernate.EntityMode; import org.hibernate.HibernateException; import org.hibernate.engine.TypedValue; import org.hibernate.persister.entity.EntityPersister; -import org.hibernate.type.AbstractComponentType; +import org.hibernate.type.CompositeType; import org.hibernate.type.Type; import org.hibernate.util.StringHelper; @@ -218,7 +217,7 @@ public class Example implements Criterion { appendComponentCondition( propertyName, propertyValue, - (AbstractComponentType) propertyTypes[i], + (CompositeType) propertyTypes[i], criteria, criteriaQuery, buf @@ -261,7 +260,7 @@ public class Example implements Criterion { if (isPropertyIncluded) { if ( propertyTypes[i].isComponentType() ) { - addComponentTypedValues(name, value, (AbstractComponentType) type, list, criteria, criteriaQuery); + addComponentTypedValues(name, value, (CompositeType) type, list, criteria, criteriaQuery); } else { addPropertyTypedValue(value, type, list); @@ -296,7 +295,7 @@ public class Example implements Criterion { protected void addComponentTypedValues( String path, Object component, - AbstractComponentType type, + CompositeType type, List list, Criteria criteria, CriteriaQuery criteriaQuery) @@ -312,7 +311,7 @@ public class Example implements Criterion { String subpath = StringHelper.qualify( path, propertyNames[i] ); if ( isPropertyIncluded(value, subpath, subtype) ) { if ( subtype.isComponentType() ) { - addComponentTypedValues(subpath, value, (AbstractComponentType) subtype, list, criteria, criteriaQuery); + addComponentTypedValues(subpath, value, (CompositeType) subtype, list, criteria, criteriaQuery); } else { addPropertyTypedValue(value, subtype, list); @@ -356,7 +355,7 @@ public class Example implements Criterion { protected void appendComponentCondition( String path, Object component, - AbstractComponentType type, + CompositeType type, Criteria criteria, CriteriaQuery criteriaQuery, StringBuffer buf) @@ -375,7 +374,7 @@ public class Example implements Criterion { appendComponentCondition( subpath, value, - (AbstractComponentType) subtype, + (CompositeType) subtype, criteria, criteriaQuery, buf diff --git a/core/src/main/java/org/hibernate/criterion/InExpression.java b/core/src/main/java/org/hibernate/criterion/InExpression.java index 024340097c..04ad9cce2e 100644 --- a/core/src/main/java/org/hibernate/criterion/InExpression.java +++ b/core/src/main/java/org/hibernate/criterion/InExpression.java @@ -1,10 +1,10 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as + * 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 Middleware LLC. + * 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 @@ -20,7 +20,6 @@ * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA - * */ package org.hibernate.criterion; @@ -29,10 +28,8 @@ import java.util.ArrayList; import org.hibernate.Criteria; import org.hibernate.EntityMode; import org.hibernate.HibernateException; - import org.hibernate.engine.TypedValue; - -import org.hibernate.type.AbstractComponentType; +import org.hibernate.type.CompositeType; import org.hibernate.type.Type; import org.hibernate.util.StringHelper; @@ -84,7 +81,7 @@ public class InExpression implements Criterion { ArrayList list = new ArrayList(); Type type = criteriaQuery.getTypeUsingProjection(criteria, propertyName); if ( type.isComponentType() ) { - AbstractComponentType actype = (AbstractComponentType) type; + CompositeType actype = (CompositeType) type; Type[] types = actype.getSubtypes(); for ( int j=0; j keyManyToOneTargetIndices, OuterJoinableAssociation joinWithCompositeId, - ComponentType componentType) { + CompositeType componentType) { for ( Type subType : componentType.getSubtypes() ) { if ( subType.isEntityType() ) { Integer index = locateKeyManyToOneTargetIndex( joinWithCompositeId, (EntityType) subType ); @@ -231,7 +228,7 @@ public class EntityJoinWalker extends AbstractEntityJoinWalker { findKeyManyToOneTargetIndices( keyManyToOneTargetIndices, joinWithCompositeId, - (ComponentType) subType + (CompositeType) subType ); } } diff --git a/core/src/main/java/org/hibernate/mapping/Property.java b/core/src/main/java/org/hibernate/mapping/Property.java index e87a7857d7..9a1afd5ecd 100644 --- a/core/src/main/java/org/hibernate/mapping/Property.java +++ b/core/src/main/java/org/hibernate/mapping/Property.java @@ -27,16 +27,16 @@ import java.io.Serializable; import java.util.Iterator; import java.util.StringTokenizer; +import org.hibernate.EntityMode; import org.hibernate.MappingException; import org.hibernate.PropertyNotFoundException; -import org.hibernate.EntityMode; import org.hibernate.engine.CascadeStyle; import org.hibernate.engine.Mapping; import org.hibernate.property.Getter; import org.hibernate.property.PropertyAccessor; import org.hibernate.property.PropertyAccessorFactory; import org.hibernate.property.Setter; -import org.hibernate.type.AbstractComponentType; +import org.hibernate.type.CompositeType; import org.hibernate.type.Type; import org.hibernate.util.ArrayHelper; @@ -109,7 +109,7 @@ public class Property implements Serializable, MetaAttributable { public CascadeStyle getCascadeStyle() throws MappingException { Type type = value.getType(); if ( type.isComponentType() && !type.isAnyType() ) { - AbstractComponentType actype = (AbstractComponentType) type; + CompositeType actype = (CompositeType) type; int length = actype.getSubtypes().length; for ( int i=0; i - * Essentially equivalent to contructor injection, but contracted + * Essentially equivalent to constructor injection, but contracted * here via interface. * * @param entityName The name of the entity for which this factory should @@ -69,7 +68,7 @@ public interface ProxyFactory { Set interfaces, Method getIdentifierMethod, Method setIdentifierMethod, - AbstractComponentType componentIdType) throws HibernateException; + CompositeType componentIdType) throws HibernateException; /** * Create a new proxy instance diff --git a/core/src/main/java/org/hibernate/proxy/dom4j/Dom4jProxyFactory.java b/core/src/main/java/org/hibernate/proxy/dom4j/Dom4jProxyFactory.java index 7827eefc3c..58f3390610 100644 --- a/core/src/main/java/org/hibernate/proxy/dom4j/Dom4jProxyFactory.java +++ b/core/src/main/java/org/hibernate/proxy/dom4j/Dom4jProxyFactory.java @@ -1,10 +1,10 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as + * 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 Middleware LLC. + * 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 @@ -20,19 +20,18 @@ * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA - * */ package org.hibernate.proxy.dom4j; -import org.hibernate.HibernateException; -import org.hibernate.proxy.ProxyFactory; -import org.hibernate.proxy.HibernateProxy; -import org.hibernate.type.AbstractComponentType; -import org.hibernate.engine.SessionImplementor; - -import java.util.Set; -import java.lang.reflect.Method; import java.io.Serializable; +import java.lang.reflect.Method; +import java.util.Set; + +import org.hibernate.HibernateException; +import org.hibernate.engine.SessionImplementor; +import org.hibernate.proxy.HibernateProxy; +import org.hibernate.proxy.ProxyFactory; +import org.hibernate.type.CompositeType; /** * Builds proxies for "dom4j" entity representations. @@ -52,7 +51,7 @@ public class Dom4jProxyFactory implements ProxyFactory { Set interfaces, Method getIdentifierMethod, Method setIdentifierMethod, - AbstractComponentType componentIdType) throws HibernateException { + CompositeType componentIdType) throws HibernateException { this.entityName = entityName; } diff --git a/core/src/main/java/org/hibernate/proxy/map/MapProxyFactory.java b/core/src/main/java/org/hibernate/proxy/map/MapProxyFactory.java index 38b4d90f1f..9eea8645d0 100644 --- a/core/src/main/java/org/hibernate/proxy/map/MapProxyFactory.java +++ b/core/src/main/java/org/hibernate/proxy/map/MapProxyFactory.java @@ -1,10 +1,10 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as + * 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 Middleware LLC. + * 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 @@ -20,7 +20,6 @@ * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA - * */ package org.hibernate.proxy.map; @@ -32,7 +31,7 @@ import org.hibernate.HibernateException; import org.hibernate.proxy.ProxyFactory; import org.hibernate.proxy.HibernateProxy; import org.hibernate.engine.SessionImplementor; -import org.hibernate.type.AbstractComponentType; +import org.hibernate.type.CompositeType; /** * @author Gavin King @@ -42,23 +41,19 @@ public class MapProxyFactory implements ProxyFactory { private String entityName; public void postInstantiate( - final String entityName, - final Class persistentClass, - final Set interfaces, - final Method getIdentifierMethod, - final Method setIdentifierMethod, - AbstractComponentType componentIdType) - throws HibernateException { - + final String entityName, + final Class persistentClass, + final Set interfaces, + final Method getIdentifierMethod, + final Method setIdentifierMethod, + CompositeType componentIdType) throws HibernateException { this.entityName = entityName; } - public HibernateProxy getProxy( - final Serializable id, - final SessionImplementor session) - throws HibernateException { - return new MapProxy( new MapLazyInitializer(entityName, id, session) ); + public HibernateProxy getProxy(final Serializable id, final SessionImplementor session) + throws HibernateException { + return new MapProxy( new MapLazyInitializer( entityName, id, session ) ); } } diff --git a/core/src/main/java/org/hibernate/proxy/pojo/BasicLazyInitializer.java b/core/src/main/java/org/hibernate/proxy/pojo/BasicLazyInitializer.java index 04a942c61f..232f0502c2 100644 --- a/core/src/main/java/org/hibernate/proxy/pojo/BasicLazyInitializer.java +++ b/core/src/main/java/org/hibernate/proxy/pojo/BasicLazyInitializer.java @@ -1,10 +1,10 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as + * 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 Middleware LLC. + * 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 @@ -20,7 +20,6 @@ * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA - * */ package org.hibernate.proxy.pojo; @@ -29,7 +28,7 @@ import java.lang.reflect.Method; import org.hibernate.engine.EntityKey; import org.hibernate.engine.SessionImplementor; -import org.hibernate.type.AbstractComponentType; +import org.hibernate.type.CompositeType; import org.hibernate.util.MarkerObject; import org.hibernate.util.ReflectHelper; import org.hibernate.proxy.AbstractLazyInitializer; @@ -48,7 +47,7 @@ public abstract class BasicLazyInitializer extends AbstractLazyInitializer { protected Method setIdentifierMethod; protected boolean overridesEquals; private Object replacement; - protected AbstractComponentType componentIdType; + protected CompositeType componentIdType; protected BasicLazyInitializer( String entityName, @@ -56,7 +55,7 @@ public abstract class BasicLazyInitializer extends AbstractLazyInitializer { Serializable id, Method getIdentifierMethod, Method setIdentifierMethod, - AbstractComponentType componentIdType, + CompositeType componentIdType, SessionImplementor session) { super(entityName, id, session); this.persistentClass = persistentClass; @@ -68,30 +67,26 @@ public abstract class BasicLazyInitializer extends AbstractLazyInitializer { protected abstract Object serializableProxy(); + @SuppressWarnings({ "UnnecessaryBoxing" }) protected final Object invoke(Method method, Object[] args, Object proxy) throws Throwable { - String methodName = method.getName(); int params = args.length; if ( params==0 ) { - if ( "writeReplace".equals(methodName) ) { return getReplacement(); } else if ( !overridesEquals && "hashCode".equals(methodName) ) { - return new Integer( System.identityHashCode(proxy) ); + return Integer.valueOf( System.identityHashCode(proxy) ); } else if ( isUninitialized() && method.equals(getIdentifierMethod) ) { return getIdentifier(); } - else if ( "getHibernateLazyInitializer".equals(methodName) ) { return this; } - } else if ( params==1 ) { - if ( !overridesEquals && "equals".equals(methodName) ) { return args[0]==proxy ? Boolean.TRUE : Boolean.FALSE; } @@ -100,7 +95,6 @@ public abstract class BasicLazyInitializer extends AbstractLazyInitializer { setIdentifier( (Serializable) args[0] ); return INVOKE_IMPLEMENTATION; } - } //if it is a property of an embedded component, invoke on the "identifier" diff --git a/core/src/main/java/org/hibernate/proxy/pojo/cglib/CGLIBLazyInitializer.java b/core/src/main/java/org/hibernate/proxy/pojo/cglib/CGLIBLazyInitializer.java index e6d61fcdbd..8311f08b8c 100644 --- a/core/src/main/java/org/hibernate/proxy/pojo/cglib/CGLIBLazyInitializer.java +++ b/core/src/main/java/org/hibernate/proxy/pojo/cglib/CGLIBLazyInitializer.java @@ -39,7 +39,7 @@ import org.hibernate.LazyInitializationException; import org.hibernate.proxy.pojo.BasicLazyInitializer; import org.hibernate.proxy.HibernateProxy; import org.hibernate.engine.SessionImplementor; -import org.hibernate.type.AbstractComponentType; +import org.hibernate.type.CompositeType; import org.hibernate.util.ReflectHelper; import org.slf4j.LoggerFactory; @@ -63,10 +63,15 @@ public final class CGLIBLazyInitializer extends BasicLazyInitializer implements private Class[] interfaces; private boolean constructed = false; - static HibernateProxy getProxy(final String entityName, final Class persistentClass, - final Class[] interfaces, final Method getIdentifierMethod, - final Method setIdentifierMethod, AbstractComponentType componentIdType, - final Serializable id, final SessionImplementor session) throws HibernateException { + static HibernateProxy getProxy( + final String entityName, + final Class persistentClass, + final Class[] interfaces, + final Method getIdentifierMethod, + final Method setIdentifierMethod, + CompositeType componentIdType, + final Serializable id, + final SessionImplementor session) throws HibernateException { // note: interfaces is assumed to already contain HibernateProxy.class try { @@ -94,12 +99,16 @@ public final class CGLIBLazyInitializer extends BasicLazyInitializer implements } } - public static HibernateProxy getProxy(final Class factory, final String entityName, - final Class persistentClass, final Class[] interfaces, - final Method getIdentifierMethod, final Method setIdentifierMethod, - final AbstractComponentType componentIdType, final Serializable id, + public static HibernateProxy getProxy( + final Class factory, + final String entityName, + final Class persistentClass, + final Class[] interfaces, + final Method getIdentifierMethod, + final Method setIdentifierMethod, + final CompositeType componentIdType, + final Serializable id, final SessionImplementor session) throws HibernateException { - final CGLIBLazyInitializer instance = new CGLIBLazyInitializer( entityName, persistentClass, @@ -150,9 +159,14 @@ public final class CGLIBLazyInitializer extends BasicLazyInitializer implements return e.createClass(); } - private CGLIBLazyInitializer(final String entityName, final Class persistentClass, - final Class[] interfaces, final Serializable id, final Method getIdentifierMethod, - final Method setIdentifierMethod, final AbstractComponentType componentIdType, + private CGLIBLazyInitializer( + final String entityName, + final Class persistentClass, + final Class[] interfaces, + final Serializable id, + final Method getIdentifierMethod, + final Method setIdentifierMethod, + final CompositeType componentIdType, final SessionImplementor session) { super( entityName, diff --git a/core/src/main/java/org/hibernate/proxy/pojo/cglib/CGLIBProxyFactory.java b/core/src/main/java/org/hibernate/proxy/pojo/cglib/CGLIBProxyFactory.java index 505ca682e5..1e4a9e5a54 100644 --- a/core/src/main/java/org/hibernate/proxy/pojo/cglib/CGLIBProxyFactory.java +++ b/core/src/main/java/org/hibernate/proxy/pojo/cglib/CGLIBProxyFactory.java @@ -1,10 +1,10 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as + * 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 Middleware LLC. + * 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 @@ -20,7 +20,6 @@ * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA - * */ package org.hibernate.proxy.pojo.cglib; @@ -32,7 +31,7 @@ import org.hibernate.HibernateException; import org.hibernate.proxy.ProxyFactory; import org.hibernate.proxy.HibernateProxy; import org.hibernate.engine.SessionImplementor; -import org.hibernate.type.AbstractComponentType; +import org.hibernate.type.CompositeType; /** * @author Gavin King @@ -46,7 +45,7 @@ public class CGLIBProxyFactory implements ProxyFactory { private Class[] interfaces; private Method getIdentifierMethod; private Method setIdentifierMethod; - private AbstractComponentType componentIdType; + private CompositeType componentIdType; private Class factory; public void postInstantiate( @@ -55,7 +54,7 @@ public class CGLIBProxyFactory implements ProxyFactory { final Set interfaces, final Method getIdentifierMethod, final Method setIdentifierMethod, - AbstractComponentType componentIdType) + CompositeType componentIdType) throws HibernateException { this.entityName = entityName; this.persistentClass = persistentClass; diff --git a/core/src/main/java/org/hibernate/proxy/pojo/cglib/SerializableProxy.java b/core/src/main/java/org/hibernate/proxy/pojo/cglib/SerializableProxy.java index 77be7353bc..1e666372fe 100644 --- a/core/src/main/java/org/hibernate/proxy/pojo/cglib/SerializableProxy.java +++ b/core/src/main/java/org/hibernate/proxy/pojo/cglib/SerializableProxy.java @@ -1,10 +1,10 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as + * 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 Middleware LLC. + * 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 @@ -20,7 +20,6 @@ * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA - * */ package org.hibernate.proxy.pojo.cglib; @@ -30,7 +29,7 @@ import java.lang.reflect.Method; import org.hibernate.HibernateException; import org.hibernate.proxy.AbstractSerializableProxy; import org.hibernate.proxy.HibernateProxy; -import org.hibernate.type.AbstractComponentType; +import org.hibernate.type.CompositeType; /** * Serializable placeholder for CGLIB proxies @@ -44,20 +43,20 @@ public final class SerializableProxy extends AbstractSerializableProxy { private String getIdentifierMethodName; private String setIdentifierMethodName; private Class[] setIdentifierMethodParams; - private AbstractComponentType componentIdType; + private CompositeType componentIdType; - public SerializableProxy() {} + public SerializableProxy() { + } public SerializableProxy( - final String entityName, - final Class persistentClass, - final Class[] interfaces, - final Serializable id, - final Boolean readOnly, - final Method getIdentifierMethod, - final Method setIdentifierMethod, - AbstractComponentType componentIdType - ) { + final String entityName, + final Class persistentClass, + final Class[] interfaces, + final Serializable id, + final Boolean readOnly, + final Method getIdentifierMethod, + final Method setIdentifierMethod, + CompositeType componentIdType) { super( entityName, id, readOnly ); this.persistentClass = persistentClass; this.interfaces = interfaces; diff --git a/core/src/main/java/org/hibernate/proxy/pojo/javassist/JavassistLazyInitializer.java b/core/src/main/java/org/hibernate/proxy/pojo/javassist/JavassistLazyInitializer.java index 071ba5a849..78175e6201 100644 --- a/core/src/main/java/org/hibernate/proxy/pojo/javassist/JavassistLazyInitializer.java +++ b/core/src/main/java/org/hibernate/proxy/pojo/javassist/JavassistLazyInitializer.java @@ -1,10 +1,10 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as + * 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 Middleware LLC. + * 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 @@ -20,7 +20,6 @@ * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA - * */ package org.hibernate.proxy.pojo.javassist; @@ -39,7 +38,7 @@ import org.hibernate.HibernateException; import org.hibernate.engine.SessionImplementor; import org.hibernate.proxy.pojo.BasicLazyInitializer; import org.hibernate.proxy.HibernateProxy; -import org.hibernate.type.AbstractComponentType; +import org.hibernate.type.CompositeType; import org.hibernate.util.ReflectHelper; /** @@ -66,7 +65,7 @@ public class JavassistLazyInitializer extends BasicLazyInitializer implements Me final Serializable id, final Method getIdentifierMethod, final Method setIdentifierMethod, - final AbstractComponentType componentIdType, + final CompositeType componentIdType, final SessionImplementor session) { super( entityName, persistentClass, id, getIdentifierMethod, setIdentifierMethod, componentIdType, session ); this.interfaces = interfaces; @@ -78,7 +77,7 @@ public class JavassistLazyInitializer extends BasicLazyInitializer implements Me final Class[] interfaces, final Method getIdentifierMethod, final Method setIdentifierMethod, - AbstractComponentType componentIdType, + CompositeType componentIdType, final Serializable id, final SessionImplementor session) throws HibernateException { // note: interface is assumed to already contain HibernateProxy.class @@ -121,7 +120,7 @@ public class JavassistLazyInitializer extends BasicLazyInitializer implements Me final Class[] interfaces, final Method getIdentifierMethod, final Method setIdentifierMethod, - final AbstractComponentType componentIdType, + final CompositeType componentIdType, final Serializable id, final SessionImplementor session) throws HibernateException { diff --git a/core/src/main/java/org/hibernate/proxy/pojo/javassist/JavassistProxyFactory.java b/core/src/main/java/org/hibernate/proxy/pojo/javassist/JavassistProxyFactory.java index 9d58803d90..f8a5d39579 100644 --- a/core/src/main/java/org/hibernate/proxy/pojo/javassist/JavassistProxyFactory.java +++ b/core/src/main/java/org/hibernate/proxy/pojo/javassist/JavassistProxyFactory.java @@ -1,10 +1,10 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as + * 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 Middleware LLC. + * 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 @@ -20,7 +20,6 @@ * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA - * */ package org.hibernate.proxy.pojo.javassist; @@ -32,7 +31,7 @@ import org.hibernate.HibernateException; import org.hibernate.engine.SessionImplementor; import org.hibernate.proxy.HibernateProxy; import org.hibernate.proxy.ProxyFactory; -import org.hibernate.type.AbstractComponentType; +import org.hibernate.type.CompositeType; /** * A {@link ProxyFactory} implementation for producing Javassist-based proxies. @@ -47,7 +46,7 @@ public class JavassistProxyFactory implements ProxyFactory, Serializable { private Class[] interfaces; private Method getIdentifierMethod; private Method setIdentifierMethod; - private AbstractComponentType componentIdType; + private CompositeType componentIdType; private Class factory; public void postInstantiate( @@ -56,7 +55,7 @@ public class JavassistProxyFactory implements ProxyFactory, Serializable { final Set interfaces, final Method getIdentifierMethod, final Method setIdentifierMethod, - AbstractComponentType componentIdType) throws HibernateException { + CompositeType componentIdType) throws HibernateException { this.entityName = entityName; this.persistentClass = persistentClass; this.interfaces = (Class[]) interfaces.toArray(NO_CLASSES); diff --git a/core/src/main/java/org/hibernate/proxy/pojo/javassist/SerializableProxy.java b/core/src/main/java/org/hibernate/proxy/pojo/javassist/SerializableProxy.java index d9f1eaea09..b8b2258f08 100644 --- a/core/src/main/java/org/hibernate/proxy/pojo/javassist/SerializableProxy.java +++ b/core/src/main/java/org/hibernate/proxy/pojo/javassist/SerializableProxy.java @@ -1,10 +1,10 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as + * 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 Middleware LLC. + * 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 @@ -20,7 +20,6 @@ * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA - * */ package org.hibernate.proxy.pojo.javassist; @@ -30,7 +29,7 @@ import java.lang.reflect.Method; import org.hibernate.HibernateException; import org.hibernate.proxy.AbstractSerializableProxy; import org.hibernate.proxy.HibernateProxy; -import org.hibernate.type.AbstractComponentType; +import org.hibernate.type.CompositeType; /** * Serializable placeholder for Javassist proxies @@ -44,20 +43,20 @@ public final class SerializableProxy extends AbstractSerializableProxy { private String getIdentifierMethodName; private String setIdentifierMethodName; private Class[] setIdentifierMethodParams; - private AbstractComponentType componentIdType; + private CompositeType componentIdType; - public SerializableProxy() {} + public SerializableProxy() { + } public SerializableProxy( - final String entityName, - final Class persistentClass, - final Class[] interfaces, - final Serializable id, - final Boolean readOnly, - final Method getIdentifierMethod, - final Method setIdentifierMethod, - AbstractComponentType componentIdType - ) { + final String entityName, + final Class persistentClass, + final Class[] interfaces, + final Serializable id, + final Boolean readOnly, + final Method getIdentifierMethod, + final Method setIdentifierMethod, + CompositeType componentIdType) { super( entityName, id, readOnly ); this.persistentClass = persistentClass; this.interfaces = interfaces; diff --git a/core/src/main/java/org/hibernate/tuple/entity/AbstractEntityTuplizer.java b/core/src/main/java/org/hibernate/tuple/entity/AbstractEntityTuplizer.java index cc65a6e1f3..2b8d9be929 100644 --- a/core/src/main/java/org/hibernate/tuple/entity/AbstractEntityTuplizer.java +++ b/core/src/main/java/org/hibernate/tuple/entity/AbstractEntityTuplizer.java @@ -34,20 +34,17 @@ import org.slf4j.LoggerFactory; import org.hibernate.EntityMode; import org.hibernate.HibernateException; import org.hibernate.MappingException; -import org.hibernate.engine.Cascade; import org.hibernate.engine.EntityEntry; import org.hibernate.engine.EntityKey; import org.hibernate.engine.SessionFactoryImplementor; import org.hibernate.engine.SessionImplementor; import org.hibernate.event.EventSource; import org.hibernate.event.PersistEvent; -import org.hibernate.event.SaveOrUpdateEvent; import org.hibernate.id.Assigned; import org.hibernate.intercept.LazyPropertyInitializer; import org.hibernate.mapping.Component; import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.Property; -import org.hibernate.persister.entity.EntityPersister; import org.hibernate.property.Getter; import org.hibernate.property.Setter; import org.hibernate.proxy.HibernateProxy; @@ -55,8 +52,8 @@ import org.hibernate.proxy.ProxyFactory; import org.hibernate.tuple.Instantiator; import org.hibernate.tuple.StandardProperty; import org.hibernate.tuple.VersionProperty; -import org.hibernate.type.AbstractComponentType; import org.hibernate.type.ComponentType; +import org.hibernate.type.CompositeType; import org.hibernate.type.EntityType; import org.hibernate.type.Type; @@ -84,7 +81,7 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer { protected final boolean hasCustomAccessors; private final Instantiator instantiator; private final ProxyFactory proxyFactory; - private final AbstractComponentType identifierMapperType; + private final CompositeType identifierMapperType; public Type getIdentifierMapperType() { return identifierMapperType; @@ -182,7 +179,7 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer { mappedIdentifierValueMarshaller = null; } else { - identifierMapperType = (AbstractComponentType) mapper.getType(); + identifierMapperType = (CompositeType) mapper.getType(); mappedIdentifierValueMarshaller = buildMappedIdentifierValueMarshaller( (ComponentType) entityMetamodel.getIdentifierProperty().getType(), (ComponentType) identifierMapperType @@ -262,7 +259,7 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer { public void setIdentifier(Object entity, Serializable id, SessionImplementor session) { if ( entityMetamodel.getIdentifierProperty().isEmbedded() ) { if ( entity != id ) { - AbstractComponentType copier = (AbstractComponentType) entityMetamodel.getIdentifierProperty().getType(); + CompositeType copier = (CompositeType) entityMetamodel.getIdentifierProperty().getType(); copier.setPropertyValues( entity, copier.getPropertyValues( id, getEntityMode() ), getEntityMode() ); } } diff --git a/core/src/main/java/org/hibernate/tuple/entity/Dom4jEntityTuplizer.java b/core/src/main/java/org/hibernate/tuple/entity/Dom4jEntityTuplizer.java index 38d1d70fed..c371ec9335 100644 --- a/core/src/main/java/org/hibernate/tuple/entity/Dom4jEntityTuplizer.java +++ b/core/src/main/java/org/hibernate/tuple/entity/Dom4jEntityTuplizer.java @@ -1,10 +1,10 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as + * 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 Middleware LLC. + * 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 @@ -20,36 +20,36 @@ * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA - * */ package org.hibernate.tuple.entity; -import org.hibernate.engine.SessionImplementor; -import org.hibernate.mapping.PersistentClass; -import org.hibernate.mapping.Property; -import org.hibernate.proxy.ProxyFactory; -import org.hibernate.proxy.HibernateProxy; -import org.hibernate.proxy.dom4j.Dom4jProxyFactory; -import org.hibernate.property.PropertyAccessor; -import org.hibernate.property.PropertyAccessorFactory; -import org.hibernate.property.Getter; -import org.hibernate.property.Setter; -import org.hibernate.EntityMode; -import org.hibernate.HibernateException; -import org.hibernate.EntityNameResolver; -import org.hibernate.engine.SessionFactoryImplementor; -import org.hibernate.tuple.Instantiator; -import org.hibernate.tuple.Dom4jInstantiator; -import org.hibernate.type.AbstractComponentType; +import java.io.Serializable; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; + import org.dom4j.Element; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.Serializable; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.HashMap; +import org.hibernate.EntityMode; +import org.hibernate.EntityNameResolver; +import org.hibernate.HibernateException; +import org.hibernate.engine.SessionFactoryImplementor; +import org.hibernate.engine.SessionImplementor; +import org.hibernate.mapping.PersistentClass; +import org.hibernate.mapping.Property; +import org.hibernate.property.Getter; +import org.hibernate.property.PropertyAccessor; +import org.hibernate.property.PropertyAccessorFactory; +import org.hibernate.property.Setter; +import org.hibernate.proxy.HibernateProxy; +import org.hibernate.proxy.ProxyFactory; +import org.hibernate.proxy.dom4j.Dom4jProxyFactory; +import org.hibernate.tuple.Dom4jInstantiator; +import org.hibernate.tuple.Instantiator; +import org.hibernate.type.CompositeType; /** * An {@link EntityTuplizer} specific to the dom4j entity mode. @@ -151,7 +151,7 @@ public class Dom4jEntityTuplizer extends AbstractEntityTuplizer { null, null, mappingInfo.hasEmbeddedIdentifier() ? - (AbstractComponentType) mappingInfo.getIdentifier().getType() : + (CompositeType) mappingInfo.getIdentifier().getType() : null ); } diff --git a/core/src/main/java/org/hibernate/tuple/entity/EntityMetamodel.java b/core/src/main/java/org/hibernate/tuple/entity/EntityMetamodel.java index 1c6e4b291b..20c32b7f21 100644 --- a/core/src/main/java/org/hibernate/tuple/entity/EntityMetamodel.java +++ b/core/src/main/java/org/hibernate/tuple/entity/EntityMetamodel.java @@ -1,10 +1,10 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as + * 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 Middleware LLC. + * 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 @@ -20,7 +20,6 @@ * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA - * */ package org.hibernate.tuple.entity; @@ -35,27 +34,27 @@ import java.util.Set; import org.slf4j.Logger; import org.slf4j.LoggerFactory; + import org.hibernate.EntityMode; import org.hibernate.HibernateException; import org.hibernate.MappingException; -import org.hibernate.tuple.IdentifierProperty; -import org.hibernate.tuple.StandardProperty; -import org.hibernate.tuple.PropertyFactory; -import org.hibernate.tuple.VersionProperty; -import org.hibernate.intercept.FieldInterceptionHelper; import org.hibernate.engine.CascadeStyle; import org.hibernate.engine.SessionFactoryImplementor; -import org.hibernate.engine.Versioning; import org.hibernate.engine.ValueInclusion; +import org.hibernate.engine.Versioning; +import org.hibernate.intercept.FieldInterceptionHelper; import org.hibernate.mapping.Component; import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.Property; import org.hibernate.mapping.PropertyGeneration; -import org.hibernate.type.AbstractComponentType; +import org.hibernate.tuple.IdentifierProperty; +import org.hibernate.tuple.PropertyFactory; +import org.hibernate.tuple.StandardProperty; +import org.hibernate.tuple.VersionProperty; import org.hibernate.type.AssociationType; +import org.hibernate.type.CompositeType; import org.hibernate.type.EntityType; import org.hibernate.type.Type; -import org.hibernate.type.TypeFactory; import org.hibernate.util.ArrayHelper; import org.hibernate.util.ReflectHelper; @@ -430,7 +429,7 @@ public class EntityMetamodel implements Serializable { return true; } else if ( type.isComponentType() ) { - Type[] subtypes = ( ( AbstractComponentType ) type ).getSubtypes(); + Type[] subtypes = ( (CompositeType) type ).getSubtypes(); for ( int i = 0; i < subtypes.length; i++ ) { if ( indicatesCollection( subtypes[i] ) ) { return true; diff --git a/core/src/main/java/org/hibernate/tuple/entity/PojoEntityTuplizer.java b/core/src/main/java/org/hibernate/tuple/entity/PojoEntityTuplizer.java index 3828a1306a..ae1f1820a6 100644 --- a/core/src/main/java/org/hibernate/tuple/entity/PojoEntityTuplizer.java +++ b/core/src/main/java/org/hibernate/tuple/entity/PojoEntityTuplizer.java @@ -1,10 +1,10 @@ /* * Hibernate, Relational Persistence for Idiomatic Java * - * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as + * 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 Middleware LLC. + * 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 @@ -20,7 +20,6 @@ * Free Software Foundation, Inc. * 51 Franklin Street, Fifth Floor * Boston, MA 02110-1301 USA - * */ package org.hibernate.tuple.entity; @@ -33,20 +32,19 @@ import java.util.Set; import org.slf4j.Logger; import org.slf4j.LoggerFactory; + import org.hibernate.EntityMode; +import org.hibernate.EntityNameResolver; import org.hibernate.HibernateException; import org.hibernate.MappingException; -import org.hibernate.EntityNameResolver; -import org.hibernate.tuple.Instantiator; -import org.hibernate.tuple.PojoInstantiator; import org.hibernate.bytecode.ReflectionOptimizer; import org.hibernate.cfg.Environment; import org.hibernate.classic.Lifecycle; import org.hibernate.classic.Validatable; -import org.hibernate.engine.SessionImplementor; import org.hibernate.engine.SessionFactoryImplementor; -import org.hibernate.intercept.FieldInterceptor; +import org.hibernate.engine.SessionImplementor; import org.hibernate.intercept.FieldInterceptionHelper; +import org.hibernate.intercept.FieldInterceptor; import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.Property; import org.hibernate.mapping.Subclass; @@ -54,7 +52,9 @@ import org.hibernate.property.Getter; import org.hibernate.property.Setter; import org.hibernate.proxy.HibernateProxy; import org.hibernate.proxy.ProxyFactory; -import org.hibernate.type.AbstractComponentType; +import org.hibernate.tuple.Instantiator; +import org.hibernate.tuple.PojoInstantiator; +import org.hibernate.type.CompositeType; import org.hibernate.util.ReflectHelper; /** @@ -191,7 +191,7 @@ public class PojoEntityTuplizer extends AbstractEntityTuplizer { proxyGetIdentifierMethod, proxySetIdentifierMethod, persistentClass.hasEmbeddedIdentifier() ? - (AbstractComponentType) persistentClass.getIdentifier().getType() : + (CompositeType) persistentClass.getIdentifier().getType() : null ); } diff --git a/core/src/main/java/org/hibernate/type/AbstractComponentType.java b/core/src/main/java/org/hibernate/type/AbstractComponentType.java index b99015239b..d78869c6eb 100644 --- a/core/src/main/java/org/hibernate/type/AbstractComponentType.java +++ b/core/src/main/java/org/hibernate/type/AbstractComponentType.java @@ -23,52 +23,14 @@ */ package org.hibernate.type; -import java.lang.reflect.Method; - -import org.hibernate.EntityMode; -import org.hibernate.FetchMode; -import org.hibernate.HibernateException; -import org.hibernate.engine.CascadeStyle; -import org.hibernate.engine.SessionImplementor; - /** * Enables other Component-like types to hold collections and have cascades, etc. * * @see ComponentType * @see AnyType * @author Gavin King + * + * @deprecated in favor of {@link org.hibernate.type.CompositeType} */ -public interface AbstractComponentType extends Type { - /** - * Get the types of the component properties - */ - public Type[] getSubtypes(); - /** - * Get the names of the component properties - */ - public String[] getPropertyNames(); - /** - * Optional operation - * @return nullability of component properties - */ - public boolean[] getPropertyNullability(); - /** - * Get the values of the component properties of - * a component instance - */ - public Object[] getPropertyValues(Object component, SessionImplementor session) throws HibernateException; - /** - * Optional operation - */ - public Object[] getPropertyValues(Object component, EntityMode entityMode) throws HibernateException; - /** - * Optional operation - */ - public void setPropertyValues(Object component, Object[] values, EntityMode entityMode) throws HibernateException; - public Object getPropertyValue(Object component, int i, SessionImplementor session) throws HibernateException; - //public Object instantiate(Object parent, SessionImplementor session) throws HibernateException; - public CascadeStyle getCascadeStyle(int i); - public FetchMode getFetchMode(int i); - public boolean isMethodOf(Method method); - public boolean isEmbedded(); +public interface AbstractComponentType extends CompositeType { } diff --git a/core/src/main/java/org/hibernate/type/AnyType.java b/core/src/main/java/org/hibernate/type/AnyType.java index f985b5f26d..38f67db482 100644 --- a/core/src/main/java/org/hibernate/type/AnyType.java +++ b/core/src/main/java/org/hibernate/type/AnyType.java @@ -52,7 +52,7 @@ import org.hibernate.util.ArrayHelper; * * @author Gavin King */ -public class AnyType extends AbstractType implements AbstractComponentType, AssociationType { +public class AnyType extends AbstractType implements CompositeType, AssociationType { private final Type identifierType; private final Type metaType; diff --git a/core/src/main/java/org/hibernate/type/ComponentType.java b/core/src/main/java/org/hibernate/type/ComponentType.java index 2d8bfe435b..6a0facab97 100644 --- a/core/src/main/java/org/hibernate/type/ComponentType.java +++ b/core/src/main/java/org/hibernate/type/ComponentType.java @@ -54,7 +54,7 @@ import org.hibernate.util.StringHelper; * * @author Gavin King */ -public class ComponentType extends AbstractType implements AbstractComponentType { +public class ComponentType extends AbstractType implements CompositeType { private final TypeFactory.TypeScope typeScope; private final String[] propertyNames; diff --git a/core/src/main/java/org/hibernate/type/CompositeCustomType.java b/core/src/main/java/org/hibernate/type/CompositeCustomType.java index 2bd02427c9..386420bf6b 100644 --- a/core/src/main/java/org/hibernate/type/CompositeCustomType.java +++ b/core/src/main/java/org/hibernate/type/CompositeCustomType.java @@ -47,7 +47,7 @@ import org.hibernate.usertype.CompositeUserType; * Adapts CompositeUserType to Type interface * @author Gavin King */ -public class CompositeCustomType extends AbstractType implements AbstractComponentType { +public class CompositeCustomType extends AbstractType implements CompositeType { private final CompositeUserType userType; private final String name; diff --git a/core/src/main/java/org/hibernate/type/CompositeType.java b/core/src/main/java/org/hibernate/type/CompositeType.java new file mode 100644 index 0000000000..25b1929041 --- /dev/null +++ b/core/src/main/java/org/hibernate/type/CompositeType.java @@ -0,0 +1,151 @@ +/* + * 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.type; + +import java.lang.reflect.Method; + +import org.hibernate.EntityMode; +import org.hibernate.FetchMode; +import org.hibernate.HibernateException; +import org.hibernate.engine.CascadeStyle; +import org.hibernate.engine.SessionImplementor; + +/** + * Contract for value types to hold collections and have cascades, etc. The notion is that of composition. JPA terms + * this an embeddable. + * + * @author Steve Ebersole + */ +public interface CompositeType extends Type { + /** + * Get the types of the component properties + * + * @return The component property types. + */ + public Type[] getSubtypes(); + + /** + * Get the names of the component properties + * + * @return The component property names + */ + public String[] getPropertyNames(); + + /** + * Retrieve the indicators regarding which component properties are nullable. + *

+ * An optional operation + * + * @return nullability of component properties + */ + public boolean[] getPropertyNullability(); + + /** + * Extract the values of the component properties from the given component instance + * + * @param component The component instance + * @param session The session from which the request originates + * + * @return The property values + * + * @throws HibernateException Indicates a problem access the property values. + */ + public Object[] getPropertyValues(Object component, SessionImplementor session) throws HibernateException; + + /** + * Extract the values of the component properties from the given component instance without access to the + * session. + *

+ * An optional operation + * + * @param component The component instance + * @param entityMode The entity mode + * + * @return The property values + * + * @throws HibernateException Indicates a problem access the property values. + */ + public Object[] getPropertyValues(Object component, EntityMode entityMode) throws HibernateException; + + /** + * Extract a particular component property value indicated by index. + * + * @param component The component instance + * @param index The index of the property whose value is to be extracted + * @param session The session from which the request originates. + * + * @return The extracted component property value + * + * @throws HibernateException Indicates a problem access the property value. + */ + public Object getPropertyValue(Object component, int index, SessionImplementor session) throws HibernateException; + + /** + * Inject property values onto the given component instance + *

+ * An optional operation + * + * @param component The component instance + * @param values The values to inject + * @param entityMode The entity mode + * + * @throws HibernateException Indicates an issue performing the injection + */ + public void setPropertyValues(Object component, Object[] values, EntityMode entityMode) throws HibernateException; + + /** + * Retrieve the cascade style of the indicated component property. + * + * @param index The property index, + * + * @return The cascade style. + */ + public CascadeStyle getCascadeStyle(int index); + + /** + * Retrieve the fetch mode of the indicated component property. + * + * @param index The property index, + * + * @return The fetch mode + */ + public FetchMode getFetchMode(int index); + + /** + * Is the given method a member of this component's class? + * + * @param method The method to check + * + * @return True if the method is a member; false otherwise. + */ + public boolean isMethodOf(Method method); + + /** + * Is this component embedded? "embedded" indicates that the component is "virtual", that its properties are + * "flattened" onto its owner + * + * @return True if this component is embedded; false otherwise. + */ + public boolean isEmbedded(); +} diff --git a/core/src/main/java/org/hibernate/type/Type.java b/core/src/main/java/org/hibernate/type/Type.java index 0d1ac79a3c..d8dc555b90 100644 --- a/core/src/main/java/org/hibernate/type/Type.java +++ b/core/src/main/java/org/hibernate/type/Type.java @@ -96,11 +96,11 @@ public interface Type extends Serializable { public boolean isAnyType(); /** - * Return true if the implementation is castable to {@link AbstractComponentType}. Essentially a polymorphic - * version of {@code (type instanceof AbstractComponentType.class)}. A component type may own collections or + * Return true if the implementation is castable to {@link CompositeType}. Essentially a polymorphic + * version of {@code (type instanceof CompositeType.class)}. A component type may own collections or * associations and hence must provide certain extra functionality. * - * @return True if this type is also an {@link CollectionType} implementor; false otherwise. + * @return True if this type is also an {@link CompositeType} implementor; false otherwise. */ public boolean isComponentType(); diff --git a/core/src/main/java/org/hibernate/type/TypeHelper.java b/core/src/main/java/org/hibernate/type/TypeHelper.java index fdc148c85c..c5fb67aa98 100644 --- a/core/src/main/java/org/hibernate/type/TypeHelper.java +++ b/core/src/main/java/org/hibernate/type/TypeHelper.java @@ -248,7 +248,7 @@ public class TypeHelper { } else if ( types[i].isComponentType() ) { // need to extract the component values and check for subtype replacements... - AbstractComponentType componentType = ( AbstractComponentType ) types[i]; + CompositeType componentType = ( CompositeType ) types[i]; Type[] subtypes = componentType.getSubtypes(); Object[] origComponentValues = original[i] == null ? new Object[subtypes.length] : componentType.getPropertyValues( original[i], session ); Object[] targetComponentValues = target[i] == null ? new Object[subtypes.length] : componentType.getPropertyValues( target[i], session );