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

This commit is contained in:
davidmc24 2010-12-21 21:04:37 -05:00 committed by Hardy Ferentschik
parent 57f5dce48c
commit 926c35a1b5
24 changed files with 1496 additions and 0 deletions

View File

@ -0,0 +1,521 @@
/*
* 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.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.CascadeType;
import javax.persistence.EnumType;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.JoinTable;
import javax.persistence.MapKey;
import javax.persistence.MapKeyClass;
import javax.persistence.MapKeyColumn;
import javax.persistence.MapKeyEnumerated;
import javax.persistence.MapKeyJoinColumn;
import javax.persistence.MapKeyJoinColumns;
import javax.persistence.MapKeyTemporal;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.OrderColumn;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;
public class Ejb3XmlOneToManyTest extends Ejb3XmlTestCase {
public void testNoChildren() throws Exception {
reader = getReader(Entity2.class, "field1", "one-to-many.orm1.xml");
assertAnnotationPresent(OneToMany.class);
assertAnnotationNotPresent(OrderBy.class);
assertAnnotationNotPresent(OrderColumn.class);
assertAnnotationNotPresent(MapKey.class);
assertAnnotationNotPresent(MapKeyClass.class);
assertAnnotationNotPresent(MapKeyTemporal.class);
assertAnnotationNotPresent(MapKeyEnumerated.class);
assertAnnotationNotPresent(MapKeyColumn.class);
assertAnnotationNotPresent(MapKeyJoinColumns.class);
assertAnnotationNotPresent(MapKeyJoinColumn.class);
assertAnnotationNotPresent(JoinTable.class);
assertAnnotationNotPresent(JoinColumns.class);
assertAnnotationNotPresent(JoinColumn.class);
assertAnnotationNotPresent(Access.class);
OneToMany relAnno = reader.getAnnotation(OneToMany.class);;
assertEquals(0, relAnno.cascade().length);
assertEquals(FetchType.LAZY, relAnno.fetch());
assertEquals("", relAnno.mappedBy());
assertFalse(relAnno.orphanRemoval());
assertEquals(void.class, relAnno.targetEntity());
}
public void testOrderBy() throws Exception {
reader = getReader(Entity2.class, "field1", "one-to-many.orm2.xml");
assertAnnotationPresent(OneToMany.class);
assertAnnotationPresent(OrderBy.class);
assertAnnotationNotPresent(OrderColumn.class);
assertEquals("col1 ASC, col2 DESC", reader.getAnnotation(OrderBy.class).value());
}
public void testOrderColumnNoAttributes() throws Exception {
reader = getReader(Entity2.class, "field1", "one-to-many.orm3.xml");
assertAnnotationPresent(OneToMany.class);
assertAnnotationNotPresent(OrderBy.class);
assertAnnotationPresent(OrderColumn.class);
OrderColumn orderColumnAnno = reader.getAnnotation(OrderColumn.class);
assertEquals("", orderColumnAnno.columnDefinition());
assertEquals("", orderColumnAnno.name());
assertTrue(orderColumnAnno.insertable());
assertTrue(orderColumnAnno.nullable());
assertTrue(orderColumnAnno.updatable());
}
public void testOrderColumnAllAttributes() throws Exception {
reader = getReader(Entity2.class, "field1", "one-to-many.orm4.xml");
assertAnnotationPresent(OneToMany.class);
assertAnnotationNotPresent(OrderBy.class);
assertAnnotationPresent(OrderColumn.class);
OrderColumn orderColumnAnno = reader.getAnnotation(OrderColumn.class);
assertEquals("int", orderColumnAnno.columnDefinition());
assertEquals("col1", orderColumnAnno.name());
assertFalse(orderColumnAnno.insertable());
assertFalse(orderColumnAnno.nullable());
assertFalse(orderColumnAnno.updatable());
}
public void testMapKeyNoAttributes() throws Exception {
reader = getReader(Entity3.class, "field1", "one-to-many.orm5.xml");
assertAnnotationPresent(OneToMany.class);
assertAnnotationPresent(MapKey.class);
assertAnnotationNotPresent(MapKeyClass.class);
assertAnnotationNotPresent(MapKeyTemporal.class);
assertAnnotationNotPresent(MapKeyEnumerated.class);
assertAnnotationNotPresent(MapKeyColumn.class);
assertAnnotationNotPresent(MapKeyJoinColumns.class);
assertAnnotationNotPresent(MapKeyJoinColumn.class);
assertEquals("", reader.getAnnotation(MapKey.class).name());
}
public void testMapKeyAllAttributes() throws Exception {
reader = getReader(Entity3.class, "field1", "one-to-many.orm6.xml");
assertAnnotationPresent(OneToMany.class);
assertAnnotationPresent(MapKey.class);
assertAnnotationNotPresent(MapKeyClass.class);
assertAnnotationNotPresent(MapKeyTemporal.class);
assertAnnotationNotPresent(MapKeyEnumerated.class);
assertAnnotationNotPresent(MapKeyColumn.class);
assertAnnotationNotPresent(MapKeyJoinColumns.class);
assertAnnotationNotPresent(MapKeyJoinColumn.class);
assertEquals("field2", reader.getAnnotation(MapKey.class).name());
}
public void testMapKeyClass() throws Exception {
reader = getReader(Entity3.class, "field1", "one-to-many.orm7.xml");
assertAnnotationPresent(OneToMany.class);
assertAnnotationNotPresent(MapKey.class);
assertAnnotationPresent(MapKeyClass.class);
assertAnnotationNotPresent(MapKeyTemporal.class);
assertAnnotationNotPresent(MapKeyEnumerated.class);
assertAnnotationNotPresent(MapKeyColumn.class);
assertAnnotationNotPresent(MapKeyJoinColumns.class);
assertAnnotationNotPresent(MapKeyJoinColumn.class);
assertEquals(Entity2.class, reader.getAnnotation(MapKeyClass.class).value());
}
public void testMapKeyTemporal() throws Exception {
reader = getReader(Entity3.class, "field1", "one-to-many.orm8.xml");
assertAnnotationPresent(OneToMany.class);
assertAnnotationNotPresent(MapKey.class);
assertAnnotationNotPresent(MapKeyClass.class);
assertAnnotationPresent(MapKeyTemporal.class);
assertAnnotationNotPresent(MapKeyEnumerated.class);
assertAnnotationNotPresent(MapKeyColumn.class);
assertAnnotationNotPresent(MapKeyJoinColumns.class);
assertAnnotationNotPresent(MapKeyJoinColumn.class);
assertEquals(TemporalType.DATE, reader.getAnnotation(MapKeyTemporal.class).value());
}
public void testMapKeyEnumerated() throws Exception {
reader = getReader(Entity3.class, "field1", "one-to-many.orm9.xml");
assertAnnotationPresent(OneToMany.class);
assertAnnotationNotPresent(MapKey.class);
assertAnnotationNotPresent(MapKeyClass.class);
assertAnnotationNotPresent(MapKeyTemporal.class);
assertAnnotationPresent(MapKeyEnumerated.class);
assertAnnotationNotPresent(MapKeyColumn.class);
assertAnnotationNotPresent(MapKeyJoinColumns.class);
assertAnnotationNotPresent(MapKeyJoinColumn.class);
assertEquals(EnumType.STRING, reader.getAnnotation(MapKeyEnumerated.class).value());
}
/**
* When there's a single map key attribute override, we still wrap it with
* an AttributeOverrides annotation.
*/
public void testSingleMapKeyAttributeOverride() throws Exception {
reader = getReader(Entity3.class, "field1", "one-to-many.orm10.xml");
assertAnnotationPresent(OneToMany.class);
assertAnnotationNotPresent(MapKey.class);
assertAnnotationNotPresent(MapKeyClass.class);
assertAnnotationNotPresent(MapKeyTemporal.class);
assertAnnotationNotPresent(MapKeyEnumerated.class);
assertAnnotationNotPresent(MapKeyColumn.class);
assertAnnotationNotPresent(MapKeyJoinColumns.class);
assertAnnotationNotPresent(MapKeyJoinColumn.class);
assertAnnotationNotPresent(AttributeOverride.class);
assertAnnotationPresent(AttributeOverrides.class);
AttributeOverrides overridesAnno = reader.getAnnotation(AttributeOverrides.class);
AttributeOverride[] overrides = overridesAnno.value();
assertEquals(1, overrides.length);
assertEquals("field1", overrides[0].name());
assertEquals("col1", overrides[0].column().name());
}
public void testMultipleMapKeyAttributeOverrides() throws Exception {
reader = getReader(Entity3.class, "field1", "one-to-many.orm11.xml");
assertAnnotationPresent(OneToMany.class);
assertAnnotationNotPresent(MapKey.class);
assertAnnotationNotPresent(MapKeyClass.class);
assertAnnotationNotPresent(MapKeyTemporal.class);
assertAnnotationNotPresent(MapKeyEnumerated.class);
assertAnnotationNotPresent(MapKeyColumn.class);
assertAnnotationNotPresent(MapKeyJoinColumns.class);
assertAnnotationNotPresent(MapKeyJoinColumn.class);
assertAnnotationNotPresent(AttributeOverride.class);
assertAnnotationPresent(AttributeOverrides.class);
AttributeOverrides overridesAnno = reader.getAnnotation(AttributeOverrides.class);
AttributeOverride[] overrides = overridesAnno.value();
assertEquals(2, overrides.length);
assertEquals("field1", overrides[0].name());
assertEquals("", overrides[0].column().name());
assertFalse(overrides[0].column().unique());
assertTrue(overrides[0].column().nullable());
assertTrue(overrides[0].column().insertable());
assertTrue(overrides[0].column().updatable());
assertEquals("", overrides[0].column().columnDefinition());
assertEquals("", overrides[0].column().table());
assertEquals(255, overrides[0].column().length());
assertEquals(0, overrides[0].column().precision());
assertEquals(0, overrides[0].column().scale());
assertEquals("field2", overrides[1].name());
assertEquals("col1", overrides[1].column().name());
assertTrue(overrides[1].column().unique());
assertFalse(overrides[1].column().nullable());
assertFalse(overrides[1].column().insertable());
assertFalse(overrides[1].column().updatable());
assertEquals("int", overrides[1].column().columnDefinition());
assertEquals("table1", overrides[1].column().table());
assertEquals(50, overrides[1].column().length());
assertEquals(2, overrides[1].column().precision());
assertEquals(1, overrides[1].column().scale());
}
public void testMapKeyColumnNoAttributes() throws Exception {
reader = getReader(Entity3.class, "field1", "one-to-many.orm12.xml");
assertAnnotationPresent(OneToMany.class);
assertAnnotationNotPresent(MapKey.class);
assertAnnotationNotPresent(MapKeyClass.class);
assertAnnotationNotPresent(MapKeyTemporal.class);
assertAnnotationNotPresent(MapKeyEnumerated.class);
assertAnnotationPresent(MapKeyColumn.class);
assertAnnotationNotPresent(MapKeyJoinColumns.class);
assertAnnotationNotPresent(MapKeyJoinColumn.class);
MapKeyColumn keyColAnno = reader.getAnnotation(MapKeyColumn.class);
assertEquals("", keyColAnno.columnDefinition());
assertEquals("", keyColAnno.name());
assertEquals("", keyColAnno.table());
assertFalse(keyColAnno.nullable());
assertTrue(keyColAnno.insertable());
assertFalse(keyColAnno.unique());
assertTrue(keyColAnno.updatable());
assertEquals(255, keyColAnno.length());
assertEquals(0, keyColAnno.precision());
assertEquals(0, keyColAnno.scale());
}
public void testMapKeyColumnAllAttributes() throws Exception {
reader = getReader(Entity3.class, "field1", "one-to-many.orm13.xml");
assertAnnotationPresent(OneToMany.class);
assertAnnotationNotPresent(MapKey.class);
assertAnnotationNotPresent(MapKeyClass.class);
assertAnnotationNotPresent(MapKeyTemporal.class);
assertAnnotationNotPresent(MapKeyEnumerated.class);
assertAnnotationPresent(MapKeyColumn.class);
assertAnnotationNotPresent(MapKeyJoinColumns.class);
assertAnnotationNotPresent(MapKeyJoinColumn.class);
MapKeyColumn keyColAnno = reader.getAnnotation(MapKeyColumn.class);
assertEquals("int", keyColAnno.columnDefinition());
assertEquals("col1", keyColAnno.name());
assertEquals("table1", keyColAnno.table());
assertTrue(keyColAnno.nullable());
assertFalse(keyColAnno.insertable());
assertTrue(keyColAnno.unique());
assertFalse(keyColAnno.updatable());
assertEquals(50, keyColAnno.length());
assertEquals(2, keyColAnno.precision());
assertEquals(1, keyColAnno.scale());
}
/**
* When there's a single map key join column, we still wrap it with a
* MapKeyJoinColumns annotation.
*/
public void testSingleMapKeyJoinColumn() throws Exception {
reader = getReader(Entity3.class, "field1", "one-to-many.orm14.xml");
assertAnnotationPresent(OneToMany.class);
assertAnnotationNotPresent(MapKey.class);
assertAnnotationNotPresent(MapKeyClass.class);
assertAnnotationNotPresent(MapKeyTemporal.class);
assertAnnotationNotPresent(MapKeyEnumerated.class);
assertAnnotationNotPresent(MapKeyColumn.class);
assertAnnotationPresent(MapKeyJoinColumns.class);
assertAnnotationNotPresent(MapKeyJoinColumn.class);
MapKeyJoinColumns joinColumnsAnno = reader.getAnnotation(MapKeyJoinColumns.class);
MapKeyJoinColumn[] joinColumns = joinColumnsAnno.value();
assertEquals(1, joinColumns.length);
assertEquals("col1", joinColumns[0].name());
}
public void testMultipleMapKeyJoinColumns() throws Exception {
reader = getReader(Entity3.class, "field1", "one-to-many.orm15.xml");
assertAnnotationPresent(OneToMany.class);
assertAnnotationNotPresent(MapKey.class);
assertAnnotationNotPresent(MapKeyClass.class);
assertAnnotationNotPresent(MapKeyTemporal.class);
assertAnnotationNotPresent(MapKeyEnumerated.class);
assertAnnotationNotPresent(MapKeyColumn.class);
assertAnnotationPresent(MapKeyJoinColumns.class);
assertAnnotationNotPresent(MapKeyJoinColumn.class);
MapKeyJoinColumns joinColumnsAnno = reader.getAnnotation(MapKeyJoinColumns.class);
MapKeyJoinColumn[] joinColumns = joinColumnsAnno.value();
assertEquals(2, joinColumns.length);
assertEquals("", joinColumns[0].name());
assertEquals("", joinColumns[0].referencedColumnName());
assertFalse(joinColumns[0].unique());
assertFalse(joinColumns[0].nullable());
assertTrue(joinColumns[0].insertable());
assertTrue(joinColumns[0].updatable());
assertEquals("", joinColumns[0].columnDefinition());
assertEquals("", joinColumns[0].table());
assertEquals("col1", joinColumns[1].name());
assertEquals("col2", joinColumns[1].referencedColumnName());
assertTrue(joinColumns[1].unique());
assertTrue(joinColumns[1].nullable());
assertFalse(joinColumns[1].insertable());
assertFalse(joinColumns[1].updatable());
assertEquals("int", joinColumns[1].columnDefinition());
assertEquals("table1", joinColumns[1].table());
}
public void testJoinTableNoChildren() throws Exception {
reader = getReader(Entity2.class, "field1", "one-to-many.orm16.xml");
assertAnnotationPresent(OneToMany.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(Entity2.class, "field1", "one-to-many.orm17.xml");
assertAnnotationPresent(OneToMany.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]);
}
/**
* When there's a single join column, we still wrap it with a JoinColumns
* annotation.
*/
public void testSingleJoinColumn() throws Exception {
reader = getReader(Entity2.class, "field1", "one-to-many.orm18.xml");
assertAnnotationPresent(OneToMany.class);
assertAnnotationNotPresent(JoinColumn.class);
assertAnnotationPresent(JoinColumns.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(Entity2.class, "field1", "one-to-many.orm19.xml");
assertAnnotationPresent(OneToMany.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 testCascadeAll() throws Exception {
reader = getReader(Entity2.class, "field1", "one-to-many.orm20.xml");
assertAnnotationPresent(OneToMany.class);
OneToMany relAnno = reader.getAnnotation(OneToMany.class);
assertEquals(1, relAnno.cascade().length);
assertEquals(CascadeType.ALL, relAnno.cascade()[0]);
}
public void testCascadeSomeWithDefaultPersist() throws Exception {
reader = getReader(Entity2.class, "field1", "one-to-many.orm21.xml");
assertAnnotationPresent(OneToMany.class);
OneToMany relAnno = reader.getAnnotation(OneToMany.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(Entity2.class, "field1", "one-to-many.orm22.xml");
assertAnnotationPresent(OneToMany.class);
OneToMany relAnno = reader.getAnnotation(OneToMany.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(Entity2.class, "field1", "one-to-many.orm23.xml");
assertAnnotationPresent(OneToMany.class);
assertAnnotationNotPresent(OrderBy.class);
assertAnnotationNotPresent(OrderColumn.class);
assertAnnotationNotPresent(MapKey.class);
assertAnnotationNotPresent(MapKeyClass.class);
assertAnnotationNotPresent(MapKeyTemporal.class);
assertAnnotationNotPresent(MapKeyEnumerated.class);
assertAnnotationNotPresent(MapKeyColumn.class);
assertAnnotationNotPresent(MapKeyJoinColumns.class);
assertAnnotationNotPresent(MapKeyJoinColumn.class);
assertAnnotationNotPresent(JoinTable.class);
assertAnnotationNotPresent(JoinColumns.class);
assertAnnotationNotPresent(JoinColumn.class);
assertAnnotationPresent(Access.class);
OneToMany relAnno = reader.getAnnotation(OneToMany.class);;
assertEquals(0, relAnno.cascade().length);
assertEquals(FetchType.EAGER, relAnno.fetch());
assertEquals("field2", relAnno.mappedBy());
assertTrue(relAnno.orphanRemoval());
assertEquals(Entity3.class, relAnno.targetEntity());
assertEquals(AccessType.PROPERTY,
reader.getAnnotation(Access.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="Entity2">
<attributes>
<one-to-many name="field1" />
</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="Entity3">
<attributes>
<one-to-many name="field1">
<map-key-attribute-override name="field1">
<column name="col1" />
</map-key-attribute-override>
</one-to-many>
</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-metadata>
<package>org.hibernate.test.annotations.xml.ejb3</package>
<entity class="Entity3">
<attributes>
<one-to-many name="field1">
<map-key-attribute-override name="field1">
<column />
</map-key-attribute-override>
<map-key-attribute-override name="field2">
<column name="col1" column-definition="int" insertable="false"
nullable="false" length="50" precision="2" scale="1" table="table1"
unique="true" updatable="false" />
</map-key-attribute-override>
</one-to-many>
</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="Entity3">
<attributes>
<one-to-many name="field1">
<map-key-column />
</one-to-many>
</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="Entity3">
<attributes>
<one-to-many name="field1">
<map-key-column column-definition="int" insertable="false"
length="50" name="col1" nullable="true" precision="2" scale="1"
table="table1" unique="true" updatable="false" />
</one-to-many>
</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="Entity3">
<attributes>
<one-to-many name="field1">
<map-key-join-column name="col1"/>
</one-to-many>
</attributes>
</entity>
</entity-mappings>

View File

@ -0,0 +1,45 @@
<?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="Entity3">
<attributes>
<one-to-many name="field1">
<map-key-join-column />
<map-key-join-column name="col1"
column-definition="int" insertable="false" nullable="true"
referenced-column-name="col2" table="table1" unique="true"
updatable="false" />
</one-to-many>
</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="Entity2">
<attributes>
<one-to-many name="field1">
<join-table/>
</one-to-many>
</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="Entity2">
<attributes>
<one-to-many 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-many>
</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="Entity2">
<attributes>
<one-to-many name="field1">
<join-column name="col1" referenced-column-name="col2"
table="table1" />
</one-to-many>
</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="Entity2">
<attributes>
<one-to-many 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-many>
</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="Entity2">
<attributes>
<one-to-many name="field1">
<order-by>col1 ASC, col2 DESC</order-by>
</one-to-many>
</attributes>
</entity>
</entity-mappings>

View File

@ -0,0 +1,38 @@
<?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="Entity2">
<attributes>
<one-to-many name="field1">
<cascade>
<cascade-all />
</cascade>
</one-to-many>
</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-defaults>
<cascade-persist />
</persistence-unit-defaults>
</persistence-unit-metadata>
<package>org.hibernate.test.annotations.xml.ejb3</package>
<entity class="Entity2">
<attributes>
<one-to-many name="field1">
<cascade>
<cascade-remove />
<cascade-refresh />
<cascade-detach />
</cascade>
</one-to-many>
</attributes>
</entity>
</entity-mappings>

View File

@ -0,0 +1,46 @@
<?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="Entity2">
<attributes>
<one-to-many name="field1">
<cascade>
<cascade-all />
<cascade-persist />
<cascade-merge />
<cascade-remove />
<cascade-refresh />
<cascade-detach />
</cascade>
</one-to-many>
</attributes>
</entity>
</entity-mappings>

View File

@ -0,0 +1,35 @@
<?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="Entity2">
<attributes>
<one-to-many name="field1" access="PROPERTY" fetch="EAGER"
mapped-by="field2" orphan-removal="true" target-entity="Entity3" />
</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="Entity2">
<attributes>
<one-to-many name="field1">
<order-column />
</one-to-many>
</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="Entity2">
<attributes>
<one-to-many name="field1">
<order-column column-definition="int" name="col1"
insertable="false" nullable="false" updatable="false" />
</one-to-many>
</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="Entity3">
<attributes>
<one-to-many name="field1">
<map-key />
</one-to-many>
</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="Entity3">
<attributes>
<one-to-many name="field1">
<map-key name="field2" />
</one-to-many>
</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="Entity3">
<attributes>
<one-to-many name="field1">
<map-key-class class="Entity2" />
</one-to-many>
</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="Entity3">
<attributes>
<one-to-many name="field1">
<map-key-temporal>DATE</map-key-temporal>
</one-to-many>
</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="Entity3">
<attributes>
<one-to-many name="field1">
<map-key-enumerated>STRING</map-key-enumerated>
</one-to-many>
</attributes>
</entity>
</entity-mappings>