[hibernate-commits] Hibernate SVN: r20272 - in core/trunk/core/src: test/java/org/hibernate and 1 other directories.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Thu Aug 26 21:50:32 EDT 2010


Author: steve.ebersole at jboss.com
Date: 2010-08-26 21:50:32 -0400 (Thu, 26 Aug 2010)
New Revision: 20272

Added:
   core/trunk/core/src/test/java/org/hibernate/subclassProxyInterface/
   core/trunk/core/src/test/java/org/hibernate/subclassProxyInterface/Doctor.java
   core/trunk/core/src/test/java/org/hibernate/subclassProxyInterface/IDoctor.java
   core/trunk/core/src/test/java/org/hibernate/subclassProxyInterface/Person.hbm.xml
   core/trunk/core/src/test/java/org/hibernate/subclassProxyInterface/Person.java
   core/trunk/core/src/test/java/org/hibernate/subclassProxyInterface/SubclassProxyInterfaceTest.java
Modified:
   core/trunk/core/src/main/java/org/hibernate/tuple/entity/PojoEntityTuplizer.java
Log:
HHH-1189 - interfaces for Proxies are not regonized as interfaces


Modified: core/trunk/core/src/main/java/org/hibernate/tuple/entity/PojoEntityTuplizer.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/tuple/entity/PojoEntityTuplizer.java	2010-08-26 21:00:47 UTC (rev 20271)
+++ core/trunk/core/src/main/java/org/hibernate/tuple/entity/PojoEntityTuplizer.java	2010-08-27 01:50:32 UTC (rev 20272)
@@ -116,7 +116,7 @@
 	protected ProxyFactory buildProxyFactory(PersistentClass persistentClass, Getter idGetter, Setter idSetter) {
 		// determine the id getter and setter methods from the proxy interface (if any)
         // determine all interfaces needed by the resulting proxy
-		HashSet proxyInterfaces = new HashSet();
+		HashSet<Class> proxyInterfaces = new HashSet<Class>();
 		proxyInterfaces.add( HibernateProxy.class );
 		
 		Class mappedClass = persistentClass.getMappedClass();
@@ -125,9 +125,8 @@
 		if ( proxyInterface!=null && !mappedClass.equals( proxyInterface ) ) {
 			if ( !proxyInterface.isInterface() ) {
 				throw new MappingException(
-				        "proxy must be either an interface, or the class itself: " + 
-				        getEntityName()
-					);
+						"proxy must be either an interface, or the class itself: " + getEntityName()
+				);
 			}
 			proxyInterfaces.add( proxyInterface );
 		}
@@ -136,16 +135,15 @@
 			proxyInterfaces.add( mappedClass );
 		}
 
-		Iterator iter = persistentClass.getSubclassIterator();
-		while ( iter.hasNext() ) {
-			Subclass subclass = ( Subclass ) iter.next();
-			Class subclassProxy = subclass.getProxyInterface();
-			Class subclassClass = subclass.getMappedClass();
+		Iterator subclasses = persistentClass.getSubclassIterator();
+		while ( subclasses.hasNext() ) {
+			final Subclass subclass = ( Subclass ) subclasses.next();
+			final Class subclassProxy = subclass.getProxyInterface();
+			final Class subclassClass = subclass.getMappedClass();
 			if ( subclassProxy!=null && !subclassClass.equals( subclassProxy ) ) {
-				if ( !proxyInterface.isInterface() ) {
+				if ( !subclassProxy.isInterface() ) {
 					throw new MappingException(
-					        "proxy must be either an interface, or the class itself: " + 
-					        subclass.getEntityName()
+							"proxy must be either an interface, or the class itself: " + subclass.getEntityName()
 					);
 				}
 				proxyInterfaces.add( subclassProxy );

Added: core/trunk/core/src/test/java/org/hibernate/subclassProxyInterface/Doctor.java
===================================================================
--- core/trunk/core/src/test/java/org/hibernate/subclassProxyInterface/Doctor.java	                        (rev 0)
+++ core/trunk/core/src/test/java/org/hibernate/subclassProxyInterface/Doctor.java	2010-08-27 01:50:32 UTC (rev 20272)
@@ -0,0 +1,40 @@
+/*
+ * 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.subclassProxyInterface;
+
+/**
+ * @author Steve Ebersole
+ */
+public class Doctor extends Person implements IDoctor {
+	public Doctor() {
+	}
+
+	public Doctor(String name) {
+		super( name );
+	}
+
+    public String operate() {
+        return "Dr. " + getName() + " is in";
+    }
+}

Added: core/trunk/core/src/test/java/org/hibernate/subclassProxyInterface/IDoctor.java
===================================================================
--- core/trunk/core/src/test/java/org/hibernate/subclassProxyInterface/IDoctor.java	                        (rev 0)
+++ core/trunk/core/src/test/java/org/hibernate/subclassProxyInterface/IDoctor.java	2010-08-27 01:50:32 UTC (rev 20272)
@@ -0,0 +1,31 @@
+/*
+ * 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.subclassProxyInterface;
+
+/**
+ * @author Steve Ebersole
+ */
+public interface IDoctor {
+    String operate();
+}

Added: core/trunk/core/src/test/java/org/hibernate/subclassProxyInterface/Person.hbm.xml
===================================================================
--- core/trunk/core/src/test/java/org/hibernate/subclassProxyInterface/Person.hbm.xml	                        (rev 0)
+++ core/trunk/core/src/test/java/org/hibernate/subclassProxyInterface/Person.hbm.xml	2010-08-27 01:50:32 UTC (rev 20272)
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC
+        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="org.hibernate.subclassProxyInterface">
+	<class name="Person">
+		<id name="id" type="long">
+            <generator class="increment"/>
+		</id>
+		<discriminator column="personType" type="string" />
+		<property name="name" type="string"  />
+		<subclass name="Doctor" discriminator-value="doctor" proxy="IDoctor" />
+	</class>
+</hibernate-mapping>

Added: core/trunk/core/src/test/java/org/hibernate/subclassProxyInterface/Person.java
===================================================================
--- core/trunk/core/src/test/java/org/hibernate/subclassProxyInterface/Person.java	                        (rev 0)
+++ core/trunk/core/src/test/java/org/hibernate/subclassProxyInterface/Person.java	2010-08-27 01:50:32 UTC (rev 20272)
@@ -0,0 +1,55 @@
+/*
+ * 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.subclassProxyInterface;
+
+/**
+ * @author Steve Ebersole
+ */
+public class Person {
+    private Long id;
+    private String name;
+
+	public Person() {
+	}
+
+	public Person(String name) {
+		this.name = name;
+	}
+
+	public Long getId() {
+		return id;
+	}
+
+	public void setId(Long id) {
+		this.id = id;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+}

Added: core/trunk/core/src/test/java/org/hibernate/subclassProxyInterface/SubclassProxyInterfaceTest.java
===================================================================
--- core/trunk/core/src/test/java/org/hibernate/subclassProxyInterface/SubclassProxyInterfaceTest.java	                        (rev 0)
+++ core/trunk/core/src/test/java/org/hibernate/subclassProxyInterface/SubclassProxyInterfaceTest.java	2010-08-27 01:50:32 UTC (rev 20272)
@@ -0,0 +1,44 @@
+/*
+ * 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.subclassProxyInterface;
+
+import junit.framework.TestCase;
+
+import org.hibernate.cfg.Configuration;
+import org.hibernate.cfg.Environment;
+import org.hibernate.dialect.H2Dialect;
+
+/**
+ * TODO : javadoc
+ *
+ * @author Steve Ebersole
+ */
+public class SubclassProxyInterfaceTest extends TestCase {
+	public void testSubclassProxyInterfaces() {
+        final Configuration cfg = new Configuration()
+				.setProperty( Environment.DIALECT, H2Dialect.class.getName() );
+		cfg.addClass( Person.class );
+		cfg.buildSessionFactory().close();
+	}
+}



More information about the hibernate-commits mailing list