From 86eeb9be34182ed03cf29ea4c912a3e815d05be3 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Fri, 3 Oct 2008 21:10:16 +0000 Subject: [PATCH] HHH-1907 : component + EntityMode.DOM4J git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@15255 1b8cb986-b30d-0410-93ca-fae66ebed9b2 --- .../entitymode/dom4j/component/Component.java | 49 ++++++++++++ .../dom4j/component/ComponentOwner.java | 58 ++++++++++++++ .../dom4j/component/ComponentReference.java | 45 +++++++++++ .../dom4j/component/Dom4jComponentTest.java | 79 +++++++++++++++++++ .../dom4j/component/Mapping.hbm.xml | 49 ++++++++++++ 5 files changed, 280 insertions(+) create mode 100644 testsuite/src/test/java/org/hibernate/test/entitymode/dom4j/component/Component.java create mode 100644 testsuite/src/test/java/org/hibernate/test/entitymode/dom4j/component/ComponentOwner.java create mode 100644 testsuite/src/test/java/org/hibernate/test/entitymode/dom4j/component/ComponentReference.java create mode 100644 testsuite/src/test/java/org/hibernate/test/entitymode/dom4j/component/Dom4jComponentTest.java create mode 100644 testsuite/src/test/java/org/hibernate/test/entitymode/dom4j/component/Mapping.hbm.xml diff --git a/testsuite/src/test/java/org/hibernate/test/entitymode/dom4j/component/Component.java b/testsuite/src/test/java/org/hibernate/test/entitymode/dom4j/component/Component.java new file mode 100644 index 0000000000..a6e4bcc61d --- /dev/null +++ b/testsuite/src/test/java/org/hibernate/test/entitymode/dom4j/component/Component.java @@ -0,0 +1,49 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2008, Red Hat Middleware LLC 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. + * + * 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.test.entitymode.dom4j.component; + +/** + * TODO : javadoc + * + * @author Steve Ebersole + */ +public class Component { + private ComponentReference reference; + + public Component() { + } + + public Component(ComponentReference reference) { + this.reference = reference; + } + + public ComponentReference getReference() { + return reference; + } + + public void setReference(ComponentReference reference) { + this.reference = reference; + } +} diff --git a/testsuite/src/test/java/org/hibernate/test/entitymode/dom4j/component/ComponentOwner.java b/testsuite/src/test/java/org/hibernate/test/entitymode/dom4j/component/ComponentOwner.java new file mode 100644 index 0000000000..c02a7bd51f --- /dev/null +++ b/testsuite/src/test/java/org/hibernate/test/entitymode/dom4j/component/ComponentOwner.java @@ -0,0 +1,58 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2008, Red Hat Middleware LLC 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. + * + * 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.test.entitymode.dom4j.component; + +/** + * TODO : javadoc + * + * @author Steve Ebersole + */ +public class ComponentOwner { + private Long id; + private Component component; + + public ComponentOwner() { + } + + public ComponentOwner(Component component) { + this.component = component; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Component getComponent() { + return component; + } + + public void setComponent(Component component) { + this.component = component; + } +} diff --git a/testsuite/src/test/java/org/hibernate/test/entitymode/dom4j/component/ComponentReference.java b/testsuite/src/test/java/org/hibernate/test/entitymode/dom4j/component/ComponentReference.java new file mode 100644 index 0000000000..2f41c861bb --- /dev/null +++ b/testsuite/src/test/java/org/hibernate/test/entitymode/dom4j/component/ComponentReference.java @@ -0,0 +1,45 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2008, Red Hat Middleware LLC 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. + * + * 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.test.entitymode.dom4j.component; + +/** + * TODO : javadoc + * + * @author Steve Ebersole + */ +public class ComponentReference { + private Long id; + + public ComponentReference() { + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } +} diff --git a/testsuite/src/test/java/org/hibernate/test/entitymode/dom4j/component/Dom4jComponentTest.java b/testsuite/src/test/java/org/hibernate/test/entitymode/dom4j/component/Dom4jComponentTest.java new file mode 100644 index 0000000000..cfada9fb97 --- /dev/null +++ b/testsuite/src/test/java/org/hibernate/test/entitymode/dom4j/component/Dom4jComponentTest.java @@ -0,0 +1,79 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2008, Red Hat Middleware LLC 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. + * + * 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.test.entitymode.dom4j.component; + +import junit.framework.Test; + +import org.hibernate.junit.functional.FunctionalTestCase; +import org.hibernate.junit.functional.FunctionalTestClassTestSuite; +import org.hibernate.Session; +import org.hibernate.EntityMode; +import org.hibernate.cfg.Configuration; +import org.hibernate.cfg.Environment; + +/** + * TODO : javadoc + * + * @author Steve Ebersole + */ +public class Dom4jComponentTest extends FunctionalTestCase { + public Dom4jComponentTest(String string) { + super( string ); + } + + public String[] getMappings() { + return new String[] { "entitymode/dom4j/component/Mapping.hbm.xml" }; + } + + public void configure(Configuration cfg) { + cfg.setProperty( Environment.DEFAULT_ENTITY_MODE, EntityMode.DOM4J.toString() ); + } + + public static Test suite() { + return new FunctionalTestClassTestSuite( Dom4jComponentTest.class ); + } + + public void testSetAccessorsFailureExpected() { + // An example of part of the issue discussed in HHH-1907 + Session session = openSession(); + session.beginTransaction(); + session.getSession( EntityMode.POJO ).save( new ComponentOwner( new Component( new ComponentReference() ) ) ); + session.getTransaction().commit(); + session.close(); + + session = openSession(); + session.beginTransaction(); + session.createQuery( "from ComponentOwner" ).list(); + session.getTransaction().commit(); + session.close(); + + session = openSession(); + session.beginTransaction(); + session.createQuery( "delete ComponentOwner" ).executeUpdate(); + session.createQuery( "delete ComponentReference" ).executeUpdate(); + session.getTransaction().commit(); + session.close(); + } +} diff --git a/testsuite/src/test/java/org/hibernate/test/entitymode/dom4j/component/Mapping.hbm.xml b/testsuite/src/test/java/org/hibernate/test/entitymode/dom4j/component/Mapping.hbm.xml new file mode 100644 index 0000000000..142d5e021d --- /dev/null +++ b/testsuite/src/test/java/org/hibernate/test/entitymode/dom4j/component/Mapping.hbm.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + +