HHH-5800 Add tests for one-to-one orm XML support

This commit is contained in:
davidmc24 2010-12-30 22:10:27 -05:00
parent e0b06e8a57
commit 33d9cbaa76
13 changed files with 787 additions and 1 deletions

View File

@ -352,7 +352,6 @@ public class Ejb3XmlOneToManyTest extends Ejb3XmlTestCase {
assertEquals( 0, joinTableAnno.joinColumns().length );
assertEquals( 0, joinTableAnno.inverseJoinColumns().length );
assertEquals( 0, joinTableAnno.uniqueConstraints().length );
}
public void testJoinTableAllChildren() throws Exception {

View File

@ -0,0 +1,296 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
* third-party contributors as indicated by either @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.test.annotations.xml.ejb3;
import javax.persistence.Access;
import javax.persistence.AccessType;
import javax.persistence.CascadeType;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.JoinTable;
import javax.persistence.MapsId;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.PrimaryKeyJoinColumns;
import javax.persistence.UniqueConstraint;
public class Ejb3XmlOnetoOneTest extends Ejb3XmlTestCase {
public void testNoChildren() throws Exception {
reader = getReader( Entity1.class, "field1", "one-to-one.orm1.xml" );
assertAnnotationPresent( OneToOne.class );
assertAnnotationNotPresent( MapsId.class );
assertAnnotationNotPresent( Id.class );
assertAnnotationNotPresent( PrimaryKeyJoinColumn.class );
assertAnnotationNotPresent( PrimaryKeyJoinColumns.class );
assertAnnotationNotPresent( JoinColumns.class );
assertAnnotationNotPresent( JoinColumn.class );
assertAnnotationNotPresent( JoinTable.class );
assertAnnotationNotPresent( Access.class );
OneToOne relAnno = reader.getAnnotation( OneToOne.class );
assertEquals( 0, relAnno.cascade().length );
assertEquals( FetchType.EAGER, relAnno.fetch() );
assertEquals( "", relAnno.mappedBy() );
assertTrue( relAnno.optional() );
assertFalse( relAnno.orphanRemoval() );
assertEquals( void.class, relAnno.targetEntity() );
}
/**
* When there's a single primary key join column, we still wrap it with
* a PrimaryKeyJoinColumns annotation.
*/
public void testSinglePrimaryKeyJoinColumn() throws Exception {
reader = getReader( Entity1.class, "field1", "one-to-one.orm2.xml" );
assertAnnotationPresent( OneToOne.class );
assertAnnotationNotPresent( PrimaryKeyJoinColumn.class );
assertAnnotationPresent( PrimaryKeyJoinColumns.class );
PrimaryKeyJoinColumns joinColumnsAnno =
reader.getAnnotation( PrimaryKeyJoinColumns.class );
assertAnnotationNotPresent( JoinColumns.class );
assertAnnotationNotPresent( JoinColumn.class );
assertAnnotationNotPresent( JoinTable.class );
PrimaryKeyJoinColumn[] joinColumns = joinColumnsAnno.value();
assertEquals( 1, joinColumns.length );
assertEquals( "col1", joinColumns[0].name() );
assertEquals( "col2", joinColumns[0].referencedColumnName() );
assertEquals( "int", joinColumns[0].columnDefinition() );
}
public void testMultiplePrimaryKeyJoinColumn() throws Exception {
reader = getReader( Entity1.class, "field1", "one-to-one.orm3.xml" );
assertAnnotationPresent( OneToOne.class );
assertAnnotationNotPresent( PrimaryKeyJoinColumn.class );
assertAnnotationPresent( PrimaryKeyJoinColumns.class );
assertAnnotationNotPresent( JoinColumns.class );
assertAnnotationNotPresent( JoinColumn.class );
assertAnnotationNotPresent( JoinTable.class );
PrimaryKeyJoinColumns joinColumnsAnno =
reader.getAnnotation( PrimaryKeyJoinColumns.class );
PrimaryKeyJoinColumn[] joinColumns = joinColumnsAnno.value();
assertEquals( 2, joinColumns.length );
assertEquals( "", joinColumns[0].name() );
assertEquals( "", joinColumns[0].referencedColumnName() );
assertEquals( "", joinColumns[0].columnDefinition() );
assertEquals( "col1", joinColumns[1].name() );
assertEquals( "col2", joinColumns[1].referencedColumnName() );
assertEquals( "int", joinColumns[1].columnDefinition() );
}
/**
* When there's a single join column, we still wrap it with a JoinColumns
* annotation.
*/
public void testSingleJoinColumn() throws Exception {
reader = getReader( Entity1.class, "field1", "one-to-one.orm4.xml" );
assertAnnotationPresent( OneToOne.class );
assertAnnotationNotPresent( PrimaryKeyJoinColumn.class );
assertAnnotationNotPresent( PrimaryKeyJoinColumns.class );
assertAnnotationPresent( JoinColumns.class );
assertAnnotationNotPresent( JoinColumn.class );
assertAnnotationNotPresent( JoinTable.class );
JoinColumns joinColumnsAnno = reader.getAnnotation( JoinColumns.class );
JoinColumn[] joinColumns = joinColumnsAnno.value();
assertEquals( 1, joinColumns.length );
assertEquals( "col1", joinColumns[0].name() );
assertEquals( "col2", joinColumns[0].referencedColumnName() );
assertEquals( "table1", joinColumns[0].table() );
}
public void testMultipleJoinColumns() throws Exception {
reader = getReader( Entity1.class, "field1", "one-to-one.orm5.xml" );
assertAnnotationPresent( OneToOne.class );
assertAnnotationNotPresent( PrimaryKeyJoinColumn.class );
assertAnnotationNotPresent( PrimaryKeyJoinColumns.class );
assertAnnotationNotPresent( JoinColumn.class );
assertAnnotationPresent( JoinColumns.class );
assertAnnotationNotPresent( JoinTable.class );
JoinColumns joinColumnsAnno = reader.getAnnotation( JoinColumns.class );
JoinColumn[] joinColumns = joinColumnsAnno.value();
assertEquals( 2, joinColumns.length );
assertEquals( "", joinColumns[0].name() );
assertEquals( "", joinColumns[0].referencedColumnName() );
assertEquals( "", joinColumns[0].table() );
assertEquals( "", joinColumns[0].columnDefinition() );
assertTrue( joinColumns[0].insertable() );
assertTrue( joinColumns[0].updatable() );
assertTrue( joinColumns[0].nullable() );
assertFalse( joinColumns[0].unique() );
assertEquals( "col1", joinColumns[1].name() );
assertEquals( "col2", joinColumns[1].referencedColumnName() );
assertEquals( "table1", joinColumns[1].table() );
assertEquals( "int", joinColumns[1].columnDefinition() );
assertFalse( joinColumns[1].insertable() );
assertFalse( joinColumns[1].updatable() );
assertFalse( joinColumns[1].nullable() );
assertTrue( joinColumns[1].unique() );
}
public void testJoinTableNoChildren() throws Exception {
reader = getReader( Entity1.class, "field1", "one-to-one.orm6.xml" );
assertAnnotationPresent( OneToOne.class );
assertAnnotationNotPresent( PrimaryKeyJoinColumn.class );
assertAnnotationNotPresent( PrimaryKeyJoinColumns.class );
assertAnnotationPresent( JoinTable.class );
assertAnnotationNotPresent( JoinColumns.class );
assertAnnotationNotPresent( JoinColumn.class );
JoinTable joinTableAnno = reader.getAnnotation( JoinTable.class );
assertEquals( "", joinTableAnno.catalog() );
assertEquals( "", joinTableAnno.name() );
assertEquals( "", joinTableAnno.schema() );
assertEquals( 0, joinTableAnno.joinColumns().length );
assertEquals( 0, joinTableAnno.inverseJoinColumns().length );
assertEquals( 0, joinTableAnno.uniqueConstraints().length );
}
public void testJoinTableAllChildren() throws Exception {
reader = getReader( Entity1.class, "field1", "one-to-one.orm7.xml" );
assertAnnotationPresent( OneToOne.class );
assertAnnotationNotPresent( PrimaryKeyJoinColumn.class );
assertAnnotationNotPresent( PrimaryKeyJoinColumns.class );
assertAnnotationPresent( JoinTable.class );
assertAnnotationNotPresent( JoinColumns.class );
assertAnnotationNotPresent( JoinColumn.class );
JoinTable joinTableAnno = reader.getAnnotation( JoinTable.class );
assertEquals( "cat1", joinTableAnno.catalog() );
assertEquals( "table1", joinTableAnno.name() );
assertEquals( "schema1", joinTableAnno.schema() );
// JoinColumns
JoinColumn[] joinColumns = joinTableAnno.joinColumns();
assertEquals( 2, joinColumns.length );
assertEquals( "", joinColumns[0].name() );
assertEquals( "", joinColumns[0].referencedColumnName() );
assertEquals( "", joinColumns[0].table() );
assertEquals( "", joinColumns[0].columnDefinition() );
assertTrue( joinColumns[0].insertable() );
assertTrue( joinColumns[0].updatable() );
assertTrue( joinColumns[0].nullable() );
assertFalse( joinColumns[0].unique() );
assertEquals( "col1", joinColumns[1].name() );
assertEquals( "col2", joinColumns[1].referencedColumnName() );
assertEquals( "table2", joinColumns[1].table() );
assertEquals( "int", joinColumns[1].columnDefinition() );
assertFalse( joinColumns[1].insertable() );
assertFalse( joinColumns[1].updatable() );
assertFalse( joinColumns[1].nullable() );
assertTrue( joinColumns[1].unique() );
// InverseJoinColumns
JoinColumn[] inverseJoinColumns = joinTableAnno.inverseJoinColumns();
assertEquals( 2, inverseJoinColumns.length );
assertEquals( "", inverseJoinColumns[0].name() );
assertEquals( "", inverseJoinColumns[0].referencedColumnName() );
assertEquals( "", inverseJoinColumns[0].table() );
assertEquals( "", inverseJoinColumns[0].columnDefinition() );
assertTrue( inverseJoinColumns[0].insertable() );
assertTrue( inverseJoinColumns[0].updatable() );
assertTrue( inverseJoinColumns[0].nullable() );
assertFalse( inverseJoinColumns[0].unique() );
assertEquals( "col3", inverseJoinColumns[1].name() );
assertEquals( "col4", inverseJoinColumns[1].referencedColumnName() );
assertEquals( "table3", inverseJoinColumns[1].table() );
assertEquals( "int", inverseJoinColumns[1].columnDefinition() );
assertFalse( inverseJoinColumns[1].insertable() );
assertFalse( inverseJoinColumns[1].updatable() );
assertFalse( inverseJoinColumns[1].nullable() );
assertTrue( inverseJoinColumns[1].unique() );
// UniqueConstraints
UniqueConstraint[] uniqueConstraints = joinTableAnno
.uniqueConstraints();
assertEquals( 2, uniqueConstraints.length );
assertEquals( 1, uniqueConstraints[0].columnNames().length );
assertEquals( "col5", uniqueConstraints[0].columnNames()[0] );
assertEquals( 2, uniqueConstraints[1].columnNames().length );
assertEquals( "col6", uniqueConstraints[1].columnNames()[0] );
assertEquals( "col7", uniqueConstraints[1].columnNames()[1] );
}
public void testCascadeAll() throws Exception {
reader = getReader( Entity1.class, "field1", "one-to-one.orm8.xml" );
assertAnnotationPresent( OneToOne.class );
OneToOne relAnno = reader.getAnnotation( OneToOne.class );
assertEquals( 1, relAnno.cascade().length );
assertEquals( CascadeType.ALL, relAnno.cascade()[0] );
}
public void testCascadeSomeWithDefaultPersist() throws Exception {
reader = getReader( Entity1.class, "field1", "one-to-one.orm9.xml" );
assertAnnotationPresent( OneToOne.class );
OneToOne relAnno = reader.getAnnotation( OneToOne.class );
assertEquals( 4, relAnno.cascade().length );
assertEquals( CascadeType.REMOVE, relAnno.cascade()[0] );
assertEquals( CascadeType.REFRESH, relAnno.cascade()[1] );
assertEquals( CascadeType.DETACH, relAnno.cascade()[2] );
assertEquals( CascadeType.PERSIST, relAnno.cascade()[3] );
}
/**
* Make sure that it doesn't break the handler when {@link CascadeType#ALL}
* is specified in addition to a default cascade-persist or individual
* cascade settings.
*/
public void testCascadeAllPlusMore() throws Exception {
reader = getReader( Entity1.class, "field1", "one-to-one.orm10.xml" );
assertAnnotationPresent( OneToOne.class );
OneToOne relAnno = reader.getAnnotation( OneToOne.class );
assertEquals( 6, relAnno.cascade().length );
assertEquals( CascadeType.ALL, relAnno.cascade()[0] );
assertEquals( CascadeType.PERSIST, relAnno.cascade()[1] );
assertEquals( CascadeType.MERGE, relAnno.cascade()[2] );
assertEquals( CascadeType.REMOVE, relAnno.cascade()[3] );
assertEquals( CascadeType.REFRESH, relAnno.cascade()[4] );
assertEquals( CascadeType.DETACH, relAnno.cascade()[5] );
}
public void testAllAttributes() throws Exception {
reader = getReader( Entity1.class, "field1", "one-to-one.orm11.xml" );
assertAnnotationPresent( OneToOne.class );
assertAnnotationPresent( MapsId.class );
assertAnnotationPresent( Id.class );
assertAnnotationNotPresent( PrimaryKeyJoinColumn.class );
assertAnnotationNotPresent( PrimaryKeyJoinColumns.class );
assertAnnotationNotPresent( JoinColumns.class );
assertAnnotationNotPresent( JoinColumn.class );
assertAnnotationNotPresent( JoinTable.class );
assertAnnotationPresent( Access.class );
OneToOne relAnno = reader.getAnnotation( OneToOne.class );
assertEquals( 0, relAnno.cascade().length );
assertEquals( FetchType.LAZY, relAnno.fetch() );
assertEquals( "field2", relAnno.mappedBy() );
assertFalse( relAnno.optional() );
assertTrue( relAnno.orphanRemoval() );
assertEquals( Entity3.class, relAnno.targetEntity() );
assertEquals( AccessType.PROPERTY, reader.getAnnotation( Access.class )
.value() );
assertEquals( "field3", reader.getAnnotation( MapsId.class )
.value() );
}
//TODO: tests for merging/overriding
}

View File

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
~ Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
~ third-party contributors as indicated by either @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
-->
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_2_0.xsd"
version="2.0">
<persistence-unit-metadata>
<xml-mapping-metadata-complete/>
</persistence-unit-metadata>
<package>org.hibernate.test.annotations.xml.ejb3</package>
<entity class="Entity1">
<attributes>
<one-to-one name="field1"/>
</attributes>
</entity>
</entity-mappings>

View File

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
~ Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
~ third-party contributors as indicated by either @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
-->
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_2_0.xsd"
version="2.0">
<persistence-unit-metadata>
<xml-mapping-metadata-complete/>
<persistence-unit-defaults>
<cascade-persist/>
</persistence-unit-defaults>
</persistence-unit-metadata>
<package>org.hibernate.test.annotations.xml.ejb3</package>
<entity class="Entity1">
<attributes>
<one-to-one name="field1">
<cascade>
<cascade-all/>
<cascade-persist/>
<cascade-merge/>
<cascade-remove/>
<cascade-refresh/>
<cascade-detach/>
</cascade>
</one-to-one>
</attributes>
</entity>
</entity-mappings>

View File

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
~ Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
~ third-party contributors as indicated by either @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
-->
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_2_0.xsd"
version="2.0">
<persistence-unit-metadata>
<xml-mapping-metadata-complete/>
</persistence-unit-metadata>
<package>org.hibernate.test.annotations.xml.ejb3</package>
<entity class="Entity1">
<attributes>
<one-to-one name="field1" access="PROPERTY" fetch="LAZY"
id="true" mapped-by="field2" maps-id="field3" optional="false"
orphan-removal="true" target-entity="Entity3"/>
</attributes>
</entity>
</entity-mappings>

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
~ Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
~ third-party contributors as indicated by either @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
-->
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_2_0.xsd"
version="2.0">
<persistence-unit-metadata>
<xml-mapping-metadata-complete/>
</persistence-unit-metadata>
<package>org.hibernate.test.annotations.xml.ejb3</package>
<entity class="Entity1">
<attributes>
<one-to-one name="field1">
<primary-key-join-column name="col1"
referenced-column-name="col2" column-definition="int"/>
</one-to-one>
</attributes>
</entity>
</entity-mappings>

View File

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
~ Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
~ third-party contributors as indicated by either @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
-->
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_2_0.xsd"
version="2.0">
<persistence-unit-metadata>
<xml-mapping-metadata-complete/>
</persistence-unit-metadata>
<package>org.hibernate.test.annotations.xml.ejb3</package>
<entity class="Entity1">
<attributes>
<one-to-one name="field1">
<primary-key-join-column/>
<primary-key-join-column name="col1"
referenced-column-name="col2" column-definition="int"/>
</one-to-one>
</attributes>
</entity>
</entity-mappings>

View File

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
~ Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
~ third-party contributors as indicated by either @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
-->
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_2_0.xsd"
version="2.0">
<persistence-unit-metadata>
<xml-mapping-metadata-complete/>
</persistence-unit-metadata>
<package>org.hibernate.test.annotations.xml.ejb3</package>
<entity class="Entity1">
<attributes>
<one-to-one name="field1">
<join-column name="col1" referenced-column-name="col2"
table="table1"/>
</one-to-one>
</attributes>
</entity>
</entity-mappings>

View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
~ Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
~ third-party contributors as indicated by either @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
-->
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_2_0.xsd"
version="2.0">
<persistence-unit-metadata>
<xml-mapping-metadata-complete/>
</persistence-unit-metadata>
<package>org.hibernate.test.annotations.xml.ejb3</package>
<entity class="Entity1">
<attributes>
<one-to-one name="field1">
<join-column/>
<join-column name="col1" referenced-column-name="col2"
table="table1" insertable="false" updatable="false"
column-definition="int" nullable="false" unique="true"/>
</one-to-one>
</attributes>
</entity>
</entity-mappings>

View File

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
~ Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
~ third-party contributors as indicated by either @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
-->
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_2_0.xsd"
version="2.0">
<persistence-unit-metadata>
<xml-mapping-metadata-complete/>
</persistence-unit-metadata>
<package>org.hibernate.test.annotations.xml.ejb3</package>
<entity class="Entity1">
<attributes>
<one-to-one name="field1">
<join-table/>
</one-to-one>
</attributes>
</entity>
</entity-mappings>

View File

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
~ Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
~ third-party contributors as indicated by either @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
-->
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_2_0.xsd"
version="2.0">
<persistence-unit-metadata>
<xml-mapping-metadata-complete/>
</persistence-unit-metadata>
<package>org.hibernate.test.annotations.xml.ejb3</package>
<entity class="Entity1">
<attributes>
<one-to-one name="field1">
<join-table name="table1" catalog="cat1" schema="schema1">
<join-column/>
<join-column name="col1" referenced-column-name="col2"
table="table2" column-definition="int" insertable="false"
updatable="false" nullable="false" unique="true"/>
<inverse-join-column/>
<inverse-join-column name="col3"
referenced-column-name="col4" table="table3" column-definition="int"
insertable="false" updatable="false" nullable="false" unique="true"/>
<unique-constraint>
<column-name>col5</column-name>
</unique-constraint>
<unique-constraint>
<column-name>col6</column-name>
<column-name>col7</column-name>
</unique-constraint>
</join-table>
</one-to-one>
</attributes>
</entity>
</entity-mappings>

View File

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
~ Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
~ third-party contributors as indicated by either @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
-->
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_2_0.xsd"
version="2.0">
<persistence-unit-metadata>
<xml-mapping-metadata-complete/>
</persistence-unit-metadata>
<package>org.hibernate.test.annotations.xml.ejb3</package>
<entity class="Entity1">
<attributes>
<one-to-one name="field1">
<cascade>
<cascade-all/>
</cascade>
</one-to-one>
</attributes>
</entity>
</entity-mappings>

View File

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Hibernate, Relational Persistence for Idiomatic Java
~
~ Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
~ third-party contributors as indicated by either @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
-->
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_2_0.xsd"
version="2.0">
<persistence-unit-metadata>
<xml-mapping-metadata-complete/>
<persistence-unit-defaults>
<cascade-persist/>
</persistence-unit-defaults>
</persistence-unit-metadata>
<package>org.hibernate.test.annotations.xml.ejb3</package>
<entity class="Entity1">
<attributes>
<one-to-one name="field1">
<cascade>
<cascade-remove/>
<cascade-refresh/>
<cascade-detach/>
</cascade>
</one-to-one>
</attributes>
</entity>
</entity-mappings>