HHH-6271 Making sure orm.xml version 1 is supported
This commit is contained in:
parent
7a18764893
commit
6fe3072976
|
@ -87,7 +87,7 @@ public class AttributeBindingStateImpl implements SimpleAttributeBindingState {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isKeyCascadeDeleteEnabled() {
|
public boolean isKeyCascadeDeleteEnabled() {
|
||||||
return false; //To change body of implemented methods use File | Settings | File Templates.
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,30 +26,36 @@ package org.hibernate.metamodel.source.annotations.xml;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import org.hibernate.metamodel.MetadataSources;
|
import org.hibernate.metamodel.MetadataSources;
|
||||||
|
import org.hibernate.metamodel.binding.EntityBinding;
|
||||||
import org.hibernate.metamodel.source.MappingException;
|
import org.hibernate.metamodel.source.MappingException;
|
||||||
import org.hibernate.metamodel.source.internal.MetadataImpl;
|
import org.hibernate.metamodel.source.internal.MetadataImpl;
|
||||||
import org.hibernate.service.ServiceRegistryBuilder;
|
import org.hibernate.service.ServiceRegistryBuilder;
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||||
|
|
||||||
|
import static junit.framework.Assert.assertNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Hardy Ferentschik
|
* @author Hardy Ferentschik
|
||||||
*/
|
*/
|
||||||
public class OrmXmlParserTests extends BaseUnitTestCase {
|
public class OrmXmlParserTests extends BaseUnitTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testSingleOrmXml() {
|
public void testSimpleOrmVersion2() {
|
||||||
MetadataSources sources = new MetadataSources( new ServiceRegistryBuilder().buildServiceRegistry() );
|
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();
|
MetadataImpl metadata = (MetadataImpl) sources.buildMetadata();
|
||||||
|
|
||||||
// Todo assertions
|
EntityBinding binding = metadata.getEntityBinding( Father.class.getName() );
|
||||||
|
assertNotNull( binding );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOrmXmlWithOldSchema() {
|
public void testSimpleOrmVersion1() {
|
||||||
MetadataSources sources = new MetadataSources( new ServiceRegistryBuilder().buildServiceRegistry() );
|
MetadataSources sources = new MetadataSources( new ServiceRegistryBuilder().buildServiceRegistry() );
|
||||||
sources.addResource( "org/hibernate/metamodel/source/annotations/xml/orm-star.xml" );
|
sources.addResource( "org/hibernate/metamodel/source/annotations/xml/orm-star.xml" );
|
||||||
MetadataImpl metadata = (MetadataImpl) sources.buildMetadata();
|
MetadataImpl metadata = (MetadataImpl) sources.buildMetadata();
|
||||||
// Todo assertions
|
|
||||||
|
EntityBinding binding = metadata.getEntityBinding( Star.class.getName() );
|
||||||
|
assertNotNull( binding );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = MappingException.class)
|
@Test(expected = MappingException.class)
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
version="2.0">
|
||||||
|
<package>org.hibernate.metamodel.source.annotations.xml</package>
|
||||||
|
|
||||||
|
<entity class="Father">
|
||||||
|
<attributes>
|
||||||
|
<id name="id">
|
||||||
|
<generated-value strategy="AUTO"/>
|
||||||
|
</id>
|
||||||
|
<basic name="name"/>
|
||||||
|
</attributes>
|
||||||
|
</entity>
|
||||||
|
</entity-mappings>
|
|
@ -1,30 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
|
|
||||||
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
version="2.0">
|
|
||||||
<package>org.hibernate.test.annotations.onetoone</package>
|
|
||||||
|
|
||||||
<entity class="Father">
|
|
||||||
<attributes>
|
|
||||||
<id name="id">
|
|
||||||
<generated-value strategy="AUTO"/>
|
|
||||||
</id>
|
|
||||||
<basic name="name"/>
|
|
||||||
</attributes>
|
|
||||||
</entity>
|
|
||||||
<entity class="Son">
|
|
||||||
<attributes>
|
|
||||||
<id name="id">
|
|
||||||
<generated-value strategy="AUTO"/>
|
|
||||||
</id>
|
|
||||||
<basic name="name"/>
|
|
||||||
<one-to-one name="father">
|
|
||||||
<join-table name="father_son">
|
|
||||||
<join-column name="foo"/>
|
|
||||||
<inverse-join-column name="bar"/>
|
|
||||||
</join-table>
|
|
||||||
</one-to-one>
|
|
||||||
</attributes>
|
|
||||||
</entity>
|
|
||||||
</entity-mappings>
|
|
Loading…
Reference in New Issue