From 6fe3072976205390f945b7aa96e1ed12b6b16f94 Mon Sep 17 00:00:00 2001 From: Hardy Ferentschik Date: Wed, 1 Jun 2011 13:30:54 +0200 Subject: [PATCH] HHH-6271 Making sure orm.xml version 1 is supported --- .../binding/AttributeBindingStateImpl.java | 2 +- .../source/annotations/xml/Father.java | 51 +++++++++++++++++++ .../annotations/xml/OrmXmlParserTests.java | 16 ++++-- .../source/annotations/xml/orm-father.xml | 16 ++++++ .../metamodel/source/annotations/xml/orm.xml | 30 ----------- 5 files changed, 79 insertions(+), 36 deletions(-) create mode 100644 hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/xml/Father.java create mode 100644 hibernate-core/src/test/resources/org/hibernate/metamodel/source/annotations/xml/orm-father.xml delete mode 100644 hibernate-core/src/test/resources/org/hibernate/metamodel/source/annotations/xml/orm.xml diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/entity/state/binding/AttributeBindingStateImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/entity/state/binding/AttributeBindingStateImpl.java index 30c2f6ac37..802448a3ad 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/entity/state/binding/AttributeBindingStateImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/entity/state/binding/AttributeBindingStateImpl.java @@ -87,7 +87,7 @@ public class AttributeBindingStateImpl implements SimpleAttributeBindingState { @Override public boolean isKeyCascadeDeleteEnabled() { - return false; //To change body of implemented methods use File | Settings | File Templates. + return false; } @Override diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/xml/Father.java b/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/xml/Father.java new file mode 100644 index 0000000000..76f829b9d7 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/xml/Father.java @@ -0,0 +1,51 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2011, 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.metamodel.source.annotations.xml; + +/** + * @author Hardy Ferentschik + */ +public class Father { + private int id; + + private String name; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} + + diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/xml/OrmXmlParserTests.java b/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/xml/OrmXmlParserTests.java index 3c21e62e1a..ef2d70125d 100644 --- a/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/xml/OrmXmlParserTests.java +++ b/hibernate-core/src/test/java/org/hibernate/metamodel/source/annotations/xml/OrmXmlParserTests.java @@ -26,30 +26,36 @@ package org.hibernate.metamodel.source.annotations.xml; import org.junit.Test; import org.hibernate.metamodel.MetadataSources; +import org.hibernate.metamodel.binding.EntityBinding; import org.hibernate.metamodel.source.MappingException; import org.hibernate.metamodel.source.internal.MetadataImpl; import org.hibernate.service.ServiceRegistryBuilder; import org.hibernate.testing.junit4.BaseUnitTestCase; +import static junit.framework.Assert.assertNotNull; + /** * @author Hardy Ferentschik */ public class OrmXmlParserTests extends BaseUnitTestCase { @Test - public void testSingleOrmXml() { + public void testSimpleOrmVersion2() { MetadataSources sources = new MetadataSources( new ServiceRegistryBuilder().buildServiceRegistry() ); - sources.addResource( "org/hibernate/metamodel/source/annotations/xml/orm.xml" ); + sources.addResource( "org/hibernate/metamodel/source/annotations/xml/orm-father.xml" ); MetadataImpl metadata = (MetadataImpl) sources.buildMetadata(); - // Todo assertions + EntityBinding binding = metadata.getEntityBinding( Father.class.getName() ); + assertNotNull( binding ); } @Test - public void testOrmXmlWithOldSchema() { + public void testSimpleOrmVersion1() { MetadataSources sources = new MetadataSources( new ServiceRegistryBuilder().buildServiceRegistry() ); sources.addResource( "org/hibernate/metamodel/source/annotations/xml/orm-star.xml" ); MetadataImpl metadata = (MetadataImpl) sources.buildMetadata(); - // Todo assertions + + EntityBinding binding = metadata.getEntityBinding( Star.class.getName() ); + assertNotNull( binding ); } @Test(expected = MappingException.class) diff --git a/hibernate-core/src/test/resources/org/hibernate/metamodel/source/annotations/xml/orm-father.xml b/hibernate-core/src/test/resources/org/hibernate/metamodel/source/annotations/xml/orm-father.xml new file mode 100644 index 0000000000..04aa71fe58 --- /dev/null +++ b/hibernate-core/src/test/resources/org/hibernate/metamodel/source/annotations/xml/orm-father.xml @@ -0,0 +1,16 @@ + + + + org.hibernate.metamodel.source.annotations.xml + + + + + + + + + + diff --git a/hibernate-core/src/test/resources/org/hibernate/metamodel/source/annotations/xml/orm.xml b/hibernate-core/src/test/resources/org/hibernate/metamodel/source/annotations/xml/orm.xml deleted file mode 100644 index 87d19123b9..0000000000 --- a/hibernate-core/src/test/resources/org/hibernate/metamodel/source/annotations/xml/orm.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - org.hibernate.test.annotations.onetoone - - - - - - - - - - - - - - - - - - - - - - - -