HHH-5800 Add tests and fixes for many-to-one orm XML support
This commit is contained in:
parent
c06cac6b36
commit
9bdd76b0e7
|
@ -83,6 +83,7 @@ import javax.persistence.MapKeyJoinColumn;
|
|||
import javax.persistence.MapKeyJoinColumns;
|
||||
import javax.persistence.MapKeyTemporal;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
import javax.persistence.MapsId;
|
||||
import javax.persistence.NamedNativeQueries;
|
||||
import javax.persistence.NamedNativeQuery;
|
||||
import javax.persistence.NamedQueries;
|
||||
|
@ -126,6 +127,7 @@ import org.hibernate.annotations.common.annotationfactory.AnnotationFactory;
|
|||
import org.hibernate.annotations.common.reflection.AnnotationReader;
|
||||
import org.hibernate.annotations.common.reflection.Filter;
|
||||
import org.hibernate.annotations.common.reflection.ReflectionUtil;
|
||||
import org.hibernate.cfg.annotations.reflection.XMLContext.Default;
|
||||
import org.hibernate.util.ReflectHelper;
|
||||
import org.hibernate.util.StringHelper;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -183,6 +185,8 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
|
|||
annotationToXml.put( AttributeOverrides.class, "attribute-override" );
|
||||
annotationToXml.put( AttributeOverride.class, "association-override" );
|
||||
annotationToXml.put( AttributeOverrides.class, "association-override" );
|
||||
annotationToXml.put( AttributeOverride.class, "map-key-attribute-override" );
|
||||
annotationToXml.put( AttributeOverrides.class, "map-key-attribute-override" );
|
||||
annotationToXml.put( Id.class, "id" );
|
||||
annotationToXml.put( EmbeddedId.class, "embedded-id" );
|
||||
annotationToXml.put( GeneratedValue.class, "generated-value" );
|
||||
|
@ -679,11 +683,14 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
|
|||
getMapKey( annotationList, element );
|
||||
getMapKeyClass( annotationList, element, defaults );
|
||||
getMapKeyColumn(annotationList, element);
|
||||
//TODO: support order-column
|
||||
//TODO: support map-key-temporal
|
||||
//TODO: support map-key-enumerated
|
||||
//TODO: support map-key-attribute-override
|
||||
//TODO: support map-key-join-column
|
||||
getOrderColumn(annotationList, element);
|
||||
getMapKeyTemporal(annotationList, element);
|
||||
getMapKeyEnumerated(annotationList, element);
|
||||
annotation = getMapKeyAttributeOverrides( element, defaults );
|
||||
addIfNotNull( annotationList, annotation );
|
||||
buildMapKeyJoinColumns( annotationList, element);
|
||||
getAssociationId(annotationList, element);
|
||||
getMapsId(annotationList, element);
|
||||
annotationList.add( AnnotationFactory.create( ad ) );
|
||||
getAccessType( annotationList, element );
|
||||
}
|
||||
|
@ -818,6 +825,147 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
|
|||
}
|
||||
}
|
||||
|
||||
private void buildMapKeyJoinColumns(List<Annotation> annotationList,
|
||||
Element element) {
|
||||
MapKeyJoinColumn[] joinColumns = getMapKeyJoinColumns( element );
|
||||
if ( joinColumns.length > 0 ) {
|
||||
AnnotationDescriptor ad = new AnnotationDescriptor( MapKeyJoinColumns.class );
|
||||
ad.setValue( "value", joinColumns );
|
||||
annotationList.add( AnnotationFactory.create( ad ) );
|
||||
}
|
||||
}
|
||||
|
||||
private MapKeyJoinColumn[] getMapKeyJoinColumns(Element element) {
|
||||
List<Element> subelements = element != null ?
|
||||
element.elements( "map-key-join-column" ) :
|
||||
null;
|
||||
List<MapKeyJoinColumn> joinColumns = new ArrayList<MapKeyJoinColumn>();
|
||||
if ( subelements != null ) {
|
||||
for (Element subelement : subelements) {
|
||||
AnnotationDescriptor column = new AnnotationDescriptor( MapKeyJoinColumn.class );
|
||||
copyStringAttribute( column, subelement, "name", false );
|
||||
copyStringAttribute( column, subelement, "referenced-column-name", false );
|
||||
copyBooleanAttribute( column, subelement, "unique" );
|
||||
copyBooleanAttribute( column, subelement, "nullable" );
|
||||
copyBooleanAttribute( column, subelement, "insertable" );
|
||||
copyBooleanAttribute( column, subelement, "updatable" );
|
||||
copyStringAttribute( column, subelement, "column-definition", false );
|
||||
copyStringAttribute( column, subelement, "table", false );
|
||||
joinColumns.add( (MapKeyJoinColumn) AnnotationFactory.create( column ) );
|
||||
}
|
||||
}
|
||||
return joinColumns.toArray( new MapKeyJoinColumn[joinColumns.size()] );
|
||||
}
|
||||
|
||||
private Annotation getMapKeyAttributeOverrides(Element tree,
|
||||
Default defaults) {
|
||||
List<AttributeOverride> attributes = buildMapKeyAttributeOverrides( tree );
|
||||
return mergeAttributeOverrides( defaults, attributes );
|
||||
}
|
||||
|
||||
private List<AttributeOverride> buildMapKeyAttributeOverrides(Element element) {
|
||||
List<Element> subelements = element == null ? null : element.elements( "map-key-attribute-override" );
|
||||
return buildMapKeyAttributeOverrides( subelements );
|
||||
}
|
||||
|
||||
private List<AttributeOverride> buildMapKeyAttributeOverrides(List<Element> subelements) {
|
||||
List<AttributeOverride> overrides = new ArrayList<AttributeOverride>();
|
||||
if ( subelements != null && subelements.size() > 0 ) {
|
||||
for (Element current : subelements) {
|
||||
if ( !current.getName().equals( "map-key-attribute-override" ) ) continue;
|
||||
AnnotationDescriptor override = new AnnotationDescriptor( AttributeOverride.class );
|
||||
copyStringAttribute( override, current, "name", true );
|
||||
Element column = current.element( "column" );
|
||||
override.setValue( "column", getColumn( column, true, current ) );
|
||||
overrides.add( (AttributeOverride) AnnotationFactory.create( override ) );
|
||||
}
|
||||
}
|
||||
return overrides;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a @MapKeyEnumerated annotation to the specified annotationList if
|
||||
* the specified element contains a map-key-enumerated sub-element. This
|
||||
* should only be the case for element-collection, many-to-many, or
|
||||
* one-to-many associations.
|
||||
*/
|
||||
private void getMapKeyEnumerated(List<Annotation> annotationList,
|
||||
Element element) {
|
||||
Element subelement = element != null ? element.element( "map-key-enumerated" ) : null;
|
||||
if ( subelement != null ) {
|
||||
AnnotationDescriptor ad = new AnnotationDescriptor( MapKeyEnumerated.class );
|
||||
EnumType value = EnumType.valueOf(subelement.getTextTrim());
|
||||
ad.setValue("value", value);
|
||||
annotationList.add( AnnotationFactory.create( ad ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a @MapKeyTemporal annotation to the specified annotationList if the
|
||||
* specified element contains a map-key-temporal sub-element. This should
|
||||
* only be the case for element-collection, many-to-many, or one-to-many
|
||||
* associations.
|
||||
*/
|
||||
private void getMapKeyTemporal(List<Annotation> annotationList,
|
||||
Element element) {
|
||||
Element subelement = element != null ? element.element( "map-key-temporal" ) : null;
|
||||
if ( subelement != null ) {
|
||||
AnnotationDescriptor ad = new AnnotationDescriptor( MapKeyTemporal.class );
|
||||
TemporalType value = TemporalType.valueOf(subelement.getTextTrim());
|
||||
ad.setValue("value", value);
|
||||
annotationList.add( AnnotationFactory.create( ad ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an @OrderColumn annotation to the specified annotationList if the
|
||||
* specified element contains an order-column sub-element. This should only
|
||||
* be the case for element-collection, many-to-many, or one-to-many
|
||||
* associations.
|
||||
*/
|
||||
private void getOrderColumn(List<Annotation> annotationList,
|
||||
Element element) {
|
||||
Element subelement = element != null ? element.element( "order-column" ) : null;
|
||||
if ( subelement != null ) {
|
||||
AnnotationDescriptor ad = new AnnotationDescriptor( OrderColumn.class );
|
||||
copyStringAttribute( ad, subelement, "name", false );
|
||||
copyBooleanAttribute( ad, subelement, "nullable" );
|
||||
copyBooleanAttribute( ad, subelement, "insertable" );
|
||||
copyBooleanAttribute( ad, subelement, "updatable" );
|
||||
copyStringAttribute( ad, subelement, "column-definition", false );
|
||||
annotationList.add( AnnotationFactory.create( ad ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a @MapsId annotation to the specified annotationList if the
|
||||
* specified element has the maps-id attribute set. This should only be the
|
||||
* case for many-to-one or one-to-one associations.
|
||||
*/
|
||||
private void getMapsId(List<Annotation> annotationList, Element element) {
|
||||
String attrVal = element.attributeValue("maps-id");
|
||||
if(attrVal != null) {
|
||||
AnnotationDescriptor ad = new AnnotationDescriptor( MapsId.class );
|
||||
ad.setValue("value", attrVal);
|
||||
annotationList.add( AnnotationFactory.create( ad ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an @Id annotation to the specified annotationList if the specified
|
||||
* element has the id attribute set to true. This should only be the case
|
||||
* for many-to-one or one-to-one associations.
|
||||
*/
|
||||
private void getAssociationId(List<Annotation> annotationList,
|
||||
Element element) {
|
||||
String attrVal = element.attributeValue("id");
|
||||
if("true".equals(attrVal)) {
|
||||
AnnotationDescriptor ad = new AnnotationDescriptor( Id.class );
|
||||
annotationList.add( AnnotationFactory.create( ad ) );
|
||||
}
|
||||
}
|
||||
|
||||
private void addTargetClass(Element element, AnnotationDescriptor ad, String nodeName, XMLContext.Default defaults) {
|
||||
String className = element.attributeValue( nodeName );
|
||||
if ( className != null ) {
|
||||
|
|
|
@ -0,0 +1,234 @@
|
|||
/*
|
||||
* 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.ManyToOne;
|
||||
import javax.persistence.MapsId;
|
||||
import javax.persistence.UniqueConstraint;
|
||||
|
||||
public class Ejb3XmlManyToOneTest extends Ejb3XmlTestCase {
|
||||
public void testNoJoins() throws Exception {
|
||||
reader = getReader(Entity1.class, "field1", "many-to-one.orm1.xml");
|
||||
assertAnnotationPresent(ManyToOne.class);
|
||||
assertAnnotationNotPresent(JoinColumn.class);
|
||||
assertAnnotationNotPresent(JoinColumns.class);
|
||||
assertAnnotationNotPresent(JoinTable.class);
|
||||
assertAnnotationNotPresent(Id.class);
|
||||
assertAnnotationNotPresent(MapsId.class);
|
||||
assertAnnotationNotPresent(Access.class);
|
||||
ManyToOne relAnno = reader.getAnnotation(ManyToOne.class);
|
||||
assertEquals(0, relAnno.cascade().length);
|
||||
assertEquals(FetchType.EAGER, relAnno.fetch());
|
||||
assertTrue(relAnno.optional());
|
||||
assertEquals(void.class, relAnno.targetEntity());
|
||||
}
|
||||
|
||||
/**
|
||||
* 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", "many-to-one.orm2.xml");
|
||||
assertAnnotationPresent(ManyToOne.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(Entity1.class, "field1", "many-to-one.orm3.xml");
|
||||
assertAnnotationPresent(ManyToOne.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", "many-to-one.orm4.xml");
|
||||
assertAnnotationPresent(ManyToOne.class);
|
||||
assertAnnotationNotPresent(JoinColumn.class);
|
||||
assertAnnotationNotPresent(JoinColumns.class);
|
||||
assertAnnotationPresent(JoinTable.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", "many-to-one.orm5.xml");
|
||||
assertAnnotationPresent(ManyToOne.class);
|
||||
assertAnnotationNotPresent(JoinColumn.class);
|
||||
assertAnnotationNotPresent(JoinColumns.class);
|
||||
assertAnnotationPresent(JoinTable.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 testAllAttributes() throws Exception {
|
||||
reader = getReader(Entity1.class, "field1", "many-to-one.orm6.xml");
|
||||
assertAnnotationPresent(ManyToOne.class);
|
||||
assertAnnotationNotPresent(JoinColumn.class);
|
||||
assertAnnotationNotPresent(JoinColumns.class);
|
||||
assertAnnotationNotPresent(JoinTable.class);
|
||||
assertAnnotationPresent(Id.class);
|
||||
assertAnnotationPresent(MapsId.class);
|
||||
assertAnnotationPresent(Access.class);
|
||||
ManyToOne relAnno = reader.getAnnotation(ManyToOne.class);
|
||||
assertEquals(0, relAnno.cascade().length);
|
||||
assertEquals(FetchType.LAZY, relAnno.fetch());
|
||||
assertFalse(relAnno.optional());
|
||||
assertEquals(Entity3.class, relAnno.targetEntity());
|
||||
assertEquals("col1", reader.getAnnotation(MapsId.class).value());
|
||||
assertEquals(AccessType.PROPERTY,
|
||||
reader.getAnnotation(Access.class).value());
|
||||
}
|
||||
|
||||
public void testCascadeAll() throws Exception {
|
||||
reader = getReader(Entity1.class, "field1", "many-to-one.orm7.xml");
|
||||
assertAnnotationPresent(ManyToOne.class);
|
||||
ManyToOne relAnno = reader.getAnnotation(ManyToOne.class);
|
||||
assertEquals(1, relAnno.cascade().length);
|
||||
assertEquals(CascadeType.ALL, relAnno.cascade()[0]);
|
||||
}
|
||||
|
||||
public void testCascadeSomeWithDefaultPersist() throws Exception {
|
||||
reader = getReader(Entity1.class, "field1", "many-to-one.orm8.xml");
|
||||
assertAnnotationPresent(ManyToOne.class);
|
||||
ManyToOne relAnno = reader.getAnnotation(ManyToOne.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", "many-to-one.orm9.xml");
|
||||
assertAnnotationPresent(ManyToOne.class);
|
||||
ManyToOne relAnno = reader.getAnnotation(ManyToOne.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]);
|
||||
}
|
||||
|
||||
//TODO: tests for merging/overriding
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* 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 java.io.InputStream;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.AnnotatedElement;
|
||||
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.io.SAXReader;
|
||||
import org.hibernate.cfg.annotations.reflection.JPAOverridenAnnotationReader;
|
||||
import org.hibernate.cfg.annotations.reflection.XMLContext;
|
||||
import org.hibernate.test.annotations.TestCase;
|
||||
|
||||
abstract class Ejb3XmlTestCase extends TestCase {
|
||||
protected JPAOverridenAnnotationReader reader;
|
||||
|
||||
protected void assertAnnotationPresent(Class<? extends Annotation> annotationType) {
|
||||
assertTrue(reader.isAnnotationPresent(annotationType));
|
||||
}
|
||||
|
||||
protected void assertAnnotationNotPresent(Class<? extends Annotation> annotationType) {
|
||||
assertFalse(reader.isAnnotationPresent(annotationType));
|
||||
}
|
||||
|
||||
protected JPAOverridenAnnotationReader getReader(Class<?> entityClass, String fieldName, String ormResourceName) throws Exception {
|
||||
AnnotatedElement el = getAnnotatedElement(entityClass, fieldName);
|
||||
XMLContext xmlContext = getContext(ormResourceName);
|
||||
JPAOverridenAnnotationReader reader = new JPAOverridenAnnotationReader(el, xmlContext);
|
||||
return reader;
|
||||
}
|
||||
|
||||
protected AnnotatedElement getAnnotatedElement(Class<?> entityClass, String fieldName) throws Exception {
|
||||
return entityClass.getDeclaredField(fieldName);
|
||||
}
|
||||
|
||||
protected XMLContext getContext(String resourceName) throws Exception {
|
||||
InputStream is = getClass().getResourceAsStream(resourceName);
|
||||
assertNotNull("Could not load resource " + resourceName, is);
|
||||
return getContext(is);
|
||||
}
|
||||
|
||||
protected XMLContext getContext(InputStream is) throws Exception {
|
||||
XMLContext xmlContext = new XMLContext();
|
||||
Document doc = new SAXReader().read(is);
|
||||
xmlContext.addDocument(doc);
|
||||
return xmlContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<?>[] getAnnotatedClasses() {
|
||||
return new Class<?>[0];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* 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;
|
||||
|
||||
public class Entity1 {
|
||||
Entity2 field1;
|
||||
|
||||
public Entity2 getField1() {
|
||||
return field1;
|
||||
}
|
||||
|
||||
public void setField1(Entity2 field1) {
|
||||
this.field1 = field1;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* 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 java.util.List;
|
||||
|
||||
public class Entity2 {
|
||||
List field1;
|
||||
|
||||
public List getField1() {
|
||||
return field1;
|
||||
}
|
||||
|
||||
public void setField1(List field1) {
|
||||
this.field1 = field1;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* 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 java.util.Map;
|
||||
|
||||
public class Entity3 {
|
||||
Map field1;
|
||||
|
||||
public Map getField1() {
|
||||
return field1;
|
||||
}
|
||||
|
||||
public void setField1(Map field1) {
|
||||
this.field1 = field1;
|
||||
}
|
||||
}
|
|
@ -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>
|
||||
<many-to-one name="field1" />
|
||||
</attributes>
|
||||
</entity>
|
||||
</entity-mappings>
|
|
@ -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>
|
||||
<many-to-one name="field1">
|
||||
<join-column name="col1" referenced-column-name="col2"
|
||||
table="table1" />
|
||||
</many-to-one>
|
||||
</attributes>
|
||||
</entity>
|
||||
</entity-mappings>
|
|
@ -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>
|
||||
<many-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" />
|
||||
</many-to-one>
|
||||
</attributes>
|
||||
</entity>
|
||||
</entity-mappings>
|
|
@ -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>
|
||||
<many-to-one name="field1">
|
||||
<join-table />
|
||||
</many-to-one>
|
||||
</attributes>
|
||||
</entity>
|
||||
</entity-mappings>
|
|
@ -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>
|
||||
<many-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>
|
||||
</many-to-one>
|
||||
</attributes>
|
||||
</entity>
|
||||
</entity-mappings>
|
|
@ -0,0 +1,40 @@
|
|||
<?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>
|
||||
<many-to-one name="field1" target-entity="Entity3" fetch="LAZY"
|
||||
optional="false" access="PROPERTY" maps-id="col1" id="true" />
|
||||
</attributes>
|
||||
</entity>
|
||||
</entity-mappings>
|
|
@ -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>
|
||||
<many-to-one name="field1">
|
||||
<cascade>
|
||||
<cascade-all />
|
||||
</cascade>
|
||||
</many-to-one>
|
||||
</attributes>
|
||||
</entity>
|
||||
</entity-mappings>
|
|
@ -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>
|
||||
<many-to-one name="field1">
|
||||
<cascade>
|
||||
<cascade-remove />
|
||||
<cascade-refresh />
|
||||
<cascade-detach />
|
||||
</cascade>
|
||||
</many-to-one>
|
||||
</attributes>
|
||||
</entity>
|
||||
</entity-mappings>
|
|
@ -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>
|
||||
<many-to-one name="field1">
|
||||
<cascade>
|
||||
<cascade-all />
|
||||
<cascade-persist />
|
||||
<cascade-merge />
|
||||
<cascade-remove />
|
||||
<cascade-refresh />
|
||||
<cascade-detach />
|
||||
</cascade>
|
||||
</many-to-one>
|
||||
</attributes>
|
||||
</entity>
|
||||
</entity-mappings>
|
Loading…
Reference in New Issue