HHH-5800 Add tests for element-collection orm XML support

This commit is contained in:
davidmc24 2010-12-31 17:39:30 -05:00
parent af1e078f83
commit 99c4ecef99
39 changed files with 2010 additions and 60 deletions

View File

@ -31,9 +31,11 @@ import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -396,8 +398,6 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
getElementCollection( annotationList, defaults ); getElementCollection( annotationList, defaults );
addIfNotNull( annotationList, getSequenceGenerator( elementsForProperty, defaults ) ); addIfNotNull( annotationList, getSequenceGenerator( elementsForProperty, defaults ) );
addIfNotNull( annotationList, getTableGenerator( elementsForProperty, defaults ) ); addIfNotNull( annotationList, getTableGenerator( elementsForProperty, defaults ) );
addIfNotNull( annotationList, getAttributeOverrides( elementsForProperty, defaults ) );
} }
processEventAnnotations( annotationList, defaults ); processEventAnnotations( annotationList, defaults );
//FIXME use annotationsMap rather than annotationList this will be faster since the annotation type is usually known at put() time //FIXME use annotationsMap rather than annotationList this will be faster since the annotation type is usually known at put() time
@ -634,31 +634,36 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
} }
} }
private void getJoinTable(List<Annotation> annotationList, Element tree, XMLContext.Default defaults) {
addIfNotNull( annotationList, buildJoinTable( tree, defaults ) );
}
/* /*
* no partial overriding possible * no partial overriding possible
*/ */
private void getJoinTable(List<Annotation> annotationList, Element tree, XMLContext.Default defaults) { private JoinTable buildJoinTable(Element tree, XMLContext.Default defaults) {
Element subelement = tree == null ? null : tree.element( "join-table" ); Element subelement = tree == null ? null : tree.element( "join-table" );
final Class<JoinTable> annotationType = JoinTable.class; final Class<JoinTable> annotationType = JoinTable.class;
if ( subelement != null ) { if ( subelement == null ) {
//ignore java annotation, an element is defined return null;
AnnotationDescriptor annotation = new AnnotationDescriptor( annotationType );
copyStringAttribute( annotation, subelement, "name", false );
copyStringAttribute( annotation, subelement, "catalog", false );
if ( StringHelper.isNotEmpty( defaults.getCatalog() )
&& StringHelper.isEmpty( (String) annotation.valueOf( "catalog" ) ) ) {
annotation.setValue( "catalog", defaults.getCatalog() );
}
copyStringAttribute( annotation, subelement, "schema", false );
if ( StringHelper.isNotEmpty( defaults.getSchema() )
&& StringHelper.isEmpty( (String) annotation.valueOf( "schema" ) ) ) {
annotation.setValue( "schema", defaults.getSchema() );
}
buildUniqueConstraints( annotation, subelement );
annotation.setValue( "joinColumns", getJoinColumns( subelement, false ) );
annotation.setValue( "inverseJoinColumns", getJoinColumns( subelement, true ) );
annotationList.add( AnnotationFactory.create( annotation ) );
} }
//ignore java annotation, an element is defined
AnnotationDescriptor annotation = new AnnotationDescriptor( annotationType );
copyStringAttribute( annotation, subelement, "name", false );
copyStringAttribute( annotation, subelement, "catalog", false );
if ( StringHelper.isNotEmpty( defaults.getCatalog() )
&& StringHelper.isEmpty( (String) annotation.valueOf( "catalog" ) ) ) {
annotation.setValue( "catalog", defaults.getCatalog() );
}
copyStringAttribute( annotation, subelement, "schema", false );
if ( StringHelper.isNotEmpty( defaults.getSchema() )
&& StringHelper.isEmpty( (String) annotation.valueOf( "schema" ) ) ) {
annotation.setValue( "schema", defaults.getSchema() );
}
buildUniqueConstraints( annotation, subelement );
annotation.setValue( "joinColumns", getJoinColumns( subelement, false ) );
annotation.setValue( "inverseJoinColumns", getJoinColumns( subelement, true ) );
return AnnotationFactory.create( annotation );
} }
private void getAssociation( private void getAssociation(
@ -853,7 +858,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
return joinColumns.toArray( new MapKeyJoinColumn[joinColumns.size()] ); return joinColumns.toArray( new MapKeyJoinColumn[joinColumns.size()] );
} }
private Annotation getMapKeyAttributeOverrides(Element tree, Default defaults) { private AttributeOverrides getMapKeyAttributeOverrides(Element tree, Default defaults) {
List<AttributeOverride> attributes = buildMapKeyAttributeOverrides( tree ); List<AttributeOverride> attributes = buildMapKeyAttributeOverrides( tree );
return mergeAttributeOverrides( defaults, attributes ); return mergeAttributeOverrides( defaults, attributes );
} }
@ -891,7 +896,6 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
ad.setValue( "value", value ); ad.setValue( "value", value );
annotationList.add( AnnotationFactory.create( ad ) ); annotationList.add( AnnotationFactory.create( ad ) );
} }
} }
/** /**
@ -972,7 +976,6 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
} }
} }
//TODO: Complete parsing of all element-collection related xml
private void getElementCollection(List<Annotation> annotationList, XMLContext.Default defaults) { private void getElementCollection(List<Annotation> annotationList, XMLContext.Default defaults) {
for ( Element element : elementsForProperty ) { for ( Element element : elementsForProperty ) {
if ( "element-collection".equals( element.getName() ) ) { if ( "element-collection".equals( element.getName() ) ) {
@ -980,20 +983,21 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
addTargetClass( element, ad, "target-class", defaults ); addTargetClass( element, ad, "target-class", defaults );
getFetchType( ad, element ); getFetchType( ad, element );
getOrderBy( annotationList, element ); getOrderBy( annotationList, element );
//TODO: support order-column getOrderColumn( annotationList, element );
getMapKey( annotationList, element ); getMapKey( annotationList, element );
getMapKeyClass( annotationList, element, defaults ); getMapKeyClass( annotationList, element, defaults );
//TODO: support map-key-temporal getMapKeyTemporal( annotationList, element );
//TODO: support map-key-enumerated getMapKeyEnumerated( annotationList, element );
//TODO: support map-key-attribute-override
getMapKeyColumn( annotationList, element ); getMapKeyColumn( annotationList, element );
//TODO: support map-key-join-column buildMapKeyJoinColumns( annotationList, element );
Annotation annotation = getColumn( element.element( "column" ), false, element ); Annotation annotation = getColumn( element.element( "column" ), false, element );
addIfNotNull( annotationList, annotation ); addIfNotNull( annotationList, annotation );
getTemporal( annotationList, element ); getTemporal( annotationList, element );
getEnumerated( annotationList, element ); getEnumerated( annotationList, element );
getLob( annotationList, element ); getLob( annotationList, element );
annotation = getAttributeOverrides( element, defaults ); AttributeOverrides mapKeyAttributeOverridesAnno = getMapKeyAttributeOverrides( element, defaults );
AttributeOverrides attributeOverridesAnno = getAttributeOverrides( element, defaults );
annotation = mergeAttributeOverridesAnnotations( mapKeyAttributeOverridesAnno, attributeOverridesAnno );
addIfNotNull( annotationList, annotation ); addIfNotNull( annotationList, annotation );
annotation = getAssociationOverrides( element, defaults ); annotation = getAssociationOverrides( element, defaults );
addIfNotNull( annotationList, annotation ); addIfNotNull( annotationList, annotation );
@ -1004,6 +1008,23 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
} }
} }
private AttributeOverrides mergeAttributeOverridesAnnotations(AttributeOverrides overrides1, AttributeOverrides overrides2) {
//If either one is null, no need to merge, so just return
if(overrides1 == null) {
return overrides2;
}
if(overrides2 == null) {
return overrides1;
}
//Neither one is null
List<AttributeOverride> attributes = new LinkedList<AttributeOverride>();
attributes.addAll( Arrays.asList( overrides1.value() ) );
attributes.addAll( Arrays.asList( overrides2.value() ) );
AnnotationDescriptor ad = new AnnotationDescriptor( AttributeOverrides.class );
ad.setValue( "value", attributes.toArray( new AttributeOverride[attributes.size()] ) );
return AnnotationFactory.create( ad );
}
private void getOrderBy(List<Annotation> annotationList, Element element) { private void getOrderBy(List<Annotation> annotationList, Element element) {
Element subelement = element != null ? element.element( "order-by" ) : null; Element subelement = element != null ? element.element( "order-by" ) : null;
if ( subelement != null ) { if ( subelement != null ) {
@ -1482,7 +1503,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
} }
private AssociationOverrides getAssociationOverrides(Element tree, XMLContext.Default defaults) { private AssociationOverrides getAssociationOverrides(Element tree, XMLContext.Default defaults) {
List<AssociationOverride> attributes = buildAssociationOverrides( tree ); List<AssociationOverride> attributes = buildAssociationOverrides( tree, defaults );
if ( defaults.canUseJavaAnnotations() ) { if ( defaults.canUseJavaAnnotations() ) {
AssociationOverride annotation = getJavaAnnotation( AssociationOverride.class ); AssociationOverride annotation = getJavaAnnotation( AssociationOverride.class );
addAssociationOverrideIfNeeded( annotation, attributes ); addAssociationOverrideIfNeeded( annotation, attributes );
@ -1503,7 +1524,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
} }
} }
private List<AssociationOverride> buildAssociationOverrides(Element element) { private List<AssociationOverride> buildAssociationOverrides(Element element, XMLContext.Default defaults ) {
List<Element> subelements = element == null ? null : element.elements( "association-override" ); List<Element> subelements = element == null ? null : element.elements( "association-override" );
List<AssociationOverride> overrides = new ArrayList<AssociationOverride>(); List<AssociationOverride> overrides = new ArrayList<AssociationOverride>();
if ( subelements != null && subelements.size() > 0 ) { if ( subelements != null && subelements.size() > 0 ) {
@ -1511,6 +1532,10 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
AnnotationDescriptor override = new AnnotationDescriptor( AssociationOverride.class ); AnnotationDescriptor override = new AnnotationDescriptor( AssociationOverride.class );
copyStringAttribute( override, current, "name", true ); copyStringAttribute( override, current, "name", true );
override.setValue( "joinColumns", getJoinColumns( current, false ) ); override.setValue( "joinColumns", getJoinColumns( current, false ) );
JoinTable joinTable = buildJoinTable( current, defaults );
if ( joinTable != null ) {
override.setValue( "joinTable", joinTable );
}
overrides.add( (AssociationOverride) AnnotationFactory.create( override ) ); overrides.add( (AssociationOverride) AnnotationFactory.create( override ) );
} }
} }
@ -2347,6 +2372,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
columnNames[columnNameIndex++] = columnNameElt.getTextTrim(); columnNames[columnNameIndex++] = columnNameElt.getTextTrim();
} }
AnnotationDescriptor ucAnn = new AnnotationDescriptor( UniqueConstraint.class ); AnnotationDescriptor ucAnn = new AnnotationDescriptor( UniqueConstraint.class );
ucAnn.setValue( "name", subelement.attributeValue( "name", "" ) );
ucAnn.setValue( "columnNames", columnNames ); ucAnn.setValue( "columnNames", columnNames );
uniqueConstraints[ucIndex++] = AnnotationFactory.create( ucAnn ); uniqueConstraints[ucIndex++] = AnnotationFactory.create( ucAnn );
} }

View File

@ -0,0 +1,674 @@
/*
* 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.AssociationOverride;
import javax.persistence.AssociationOverrides;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Lob;
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.OrderBy;
import javax.persistence.OrderColumn;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;
public class Ejb3XmlElementCollectionTest extends Ejb3XmlTestCase {
public void testNoChildren() throws Exception {
reader = getReader( Entity2.class, "field1", "element-collection.orm1.xml" );
assertAnnotationPresent( ElementCollection.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( Column.class );
assertAnnotationNotPresent( Temporal.class );
assertAnnotationNotPresent( Enumerated.class );
assertAnnotationNotPresent( Lob.class );
assertAnnotationNotPresent( AttributeOverride.class );
assertAnnotationNotPresent( AttributeOverrides.class );
assertAnnotationNotPresent( AssociationOverride.class );
assertAnnotationNotPresent( AssociationOverrides.class );
assertAnnotationNotPresent( CollectionTable.class );
assertAnnotationNotPresent( Access.class );
ElementCollection relAnno = reader.getAnnotation( ElementCollection.class );
assertEquals( FetchType.LAZY, relAnno.fetch() );
assertEquals( void.class, relAnno.targetClass() );
}
public void testOrderBy() throws Exception {
reader = getReader( Entity2.class, "field1", "element-collection.orm2.xml" );
assertAnnotationPresent( ElementCollection.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", "element-collection.orm3.xml" );
assertAnnotationPresent( ElementCollection.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", "element-collection.orm4.xml" );
assertAnnotationPresent( ElementCollection.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", "element-collection.orm5.xml" );
assertAnnotationPresent( ElementCollection.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", "element-collection.orm6.xml" );
assertAnnotationPresent( ElementCollection.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", "element-collection.orm7.xml" );
assertAnnotationPresent( ElementCollection.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", "element-collection.orm8.xml" );
assertAnnotationPresent( ElementCollection.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", "element-collection.orm9.xml" );
assertAnnotationPresent( ElementCollection.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", "element-collection.orm10.xml" );
assertAnnotationPresent( ElementCollection.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", "element-collection.orm11.xml" );
assertAnnotationPresent( ElementCollection.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", "element-collection.orm12.xml" );
assertAnnotationPresent( ElementCollection.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", "element-collection.orm13.xml" );
assertAnnotationPresent( ElementCollection.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", "element-collection.orm14.xml" );
assertAnnotationPresent( ElementCollection.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", "element-collection.orm15.xml" );
assertAnnotationPresent( ElementCollection.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 testColumnNoAttributes() throws Exception {
reader = getReader( Entity3.class, "field1", "element-collection.orm16.xml" );
assertAnnotationPresent( ElementCollection.class );
assertAnnotationPresent( Column.class );
Column column = reader.getAnnotation( Column.class );
assertEquals( "", column.name() );
assertFalse( column.unique() );
assertTrue( column.nullable() );
assertTrue( column.insertable() );
assertTrue( column.updatable() );
assertEquals( "", column.columnDefinition() );
assertEquals( "", column.table() );
assertEquals( 255, column.length() );
assertEquals( 0, column.precision() );
assertEquals( 0, column.scale() );
}
public void testColumnAllAttributes() throws Exception {
reader = getReader( Entity3.class, "field1", "element-collection.orm17.xml" );
assertAnnotationPresent( ElementCollection.class );
assertAnnotationPresent( Column.class );
Column column = reader.getAnnotation( Column.class );
assertEquals( "col1", column.name() );
assertTrue( column.unique() );
assertFalse( column.nullable() );
assertFalse( column.insertable() );
assertFalse( column.updatable() );
assertEquals( "int", column.columnDefinition() );
assertEquals( "table1", column.table() );
assertEquals( 50, column.length() );
assertEquals( 2, column.precision() );
assertEquals( 1, column.scale() );
}
public void testTemporal() throws Exception {
reader = getReader( Entity3.class, "field1", "element-collection.orm18.xml" );
assertAnnotationPresent( ElementCollection.class );
assertAnnotationPresent( Temporal.class );
assertAnnotationNotPresent( Enumerated.class );
assertAnnotationNotPresent( Lob.class );
assertEquals( TemporalType.DATE, reader.getAnnotation(
Temporal.class ).value() );
}
public void testEnumerated() throws Exception {
reader = getReader( Entity3.class, "field1", "element-collection.orm19.xml" );
assertAnnotationPresent( ElementCollection.class );
assertAnnotationNotPresent( Temporal.class );
assertAnnotationPresent( Enumerated.class );
assertAnnotationNotPresent( Lob.class );
assertEquals( EnumType.STRING, reader.getAnnotation(
Enumerated.class ).value() );
}
public void testLob() throws Exception {
reader = getReader( Entity3.class, "field1", "element-collection.orm20.xml" );
assertAnnotationPresent( ElementCollection.class );
assertAnnotationNotPresent( Temporal.class );
assertAnnotationNotPresent( Enumerated.class );
assertAnnotationPresent( Lob.class );
}
/**
* When there's a single attribute override, we still wrap it with an
* AttributeOverrides annotation.
*/
public void testSingleAttributeOverride() throws Exception {
reader = getReader( Entity3.class, "field1", "element-collection.orm21.xml" );
assertAnnotationPresent( ElementCollection.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 testMultipleAttributeOverrides() throws Exception {
reader = getReader( Entity3.class, "field1", "element-collection.orm22.xml" );
assertAnnotationPresent( ElementCollection.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() );
}
/**
* Tests that map-key-attribute-override and attribute-override elements
* both end up in the AttributeOverrides annotation.
*/
public void testMixedAttributeOverrides() throws Exception {
reader = getReader( Entity3.class, "field1", "element-collection.orm23.xml" );
assertAnnotationPresent( ElementCollection.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( "col1", overrides[0].column().name() );
assertEquals( "field2", overrides[1].name() );
assertEquals( "col2", overrides[1].column().name() );
}
/**
* When there's a single association override, we still wrap it with an
* AssociationOverrides annotation.
*/
public void testSingleAssociationOverride() throws Exception {
reader = getReader( Entity3.class, "field1", "element-collection.orm24.xml" );
assertAnnotationPresent( ElementCollection.class );
assertAnnotationNotPresent( AssociationOverride.class );
assertAnnotationPresent( AssociationOverrides.class );
AssociationOverrides overridesAnno = reader.getAnnotation( AssociationOverrides.class );
AssociationOverride[] overrides = overridesAnno.value();
assertEquals( 1, overrides.length );
assertEquals( "association1", overrides[0].name() );
assertEquals( 0, overrides[0].joinColumns().length );
assertEquals( "", overrides[0].joinTable().name() );
}
public void testMultipleAssociationOverridesJoinColumns() throws Exception {
reader = getReader( Entity3.class, "field1", "element-collection.orm25.xml" );
assertAnnotationPresent( ElementCollection.class );
assertAnnotationNotPresent( AssociationOverride.class );
assertAnnotationPresent( AssociationOverrides.class );
AssociationOverrides overridesAnno = reader.getAnnotation( AssociationOverrides.class );
AssociationOverride[] overrides = overridesAnno.value();
assertEquals( 2, overrides.length );
//First, an association using join table
assertEquals( "association1", overrides[0].name() );
assertEquals( 0, overrides[0].joinColumns().length );
JoinTable joinTableAnno = overrides[0].joinTable();
assertEquals( "catalog1", 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( "", uniqueConstraints[0].name() );
assertEquals( 1, uniqueConstraints[0].columnNames().length );
assertEquals( "col5", uniqueConstraints[0].columnNames()[0] );
assertEquals( "uq1", uniqueConstraints[1].name() );
assertEquals( 2, uniqueConstraints[1].columnNames().length );
assertEquals( "col6", uniqueConstraints[1].columnNames()[0] );
assertEquals( "col7", uniqueConstraints[1].columnNames()[1] );
//Second, an association using join columns
assertEquals( "association2", overrides[1].name() );
//JoinColumns
joinColumns = overrides[1].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( "col8", joinColumns[1].name() );
assertEquals( "col9", joinColumns[1].referencedColumnName() );
assertEquals( "table4", 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 testCollectionTableNoChildren() throws Exception {
reader = getReader( Entity3.class, "field1", "element-collection.orm26.xml" );
assertAnnotationPresent( ElementCollection.class );
assertAnnotationPresent( CollectionTable.class );
CollectionTable tableAnno = reader.getAnnotation( CollectionTable.class );
assertEquals( "", tableAnno.name() );
assertEquals( "", tableAnno.catalog() );
assertEquals( "", tableAnno.schema() );
assertEquals( 0, tableAnno.joinColumns().length );
assertEquals( 0, tableAnno.uniqueConstraints().length );
}
public void testCollectionTableAllChildren() throws Exception {
reader = getReader( Entity3.class, "field1", "element-collection.orm27.xml" );
assertAnnotationPresent( ElementCollection.class );
assertAnnotationPresent( CollectionTable.class );
CollectionTable tableAnno = reader.getAnnotation( CollectionTable.class );
assertEquals( "table1", tableAnno.name() );
assertEquals( "catalog1", tableAnno.catalog() );
assertEquals( "schema1", tableAnno.schema() );
//JoinColumns
JoinColumn[] joinColumns = tableAnno.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() );
//UniqueConstraints
UniqueConstraint[] uniqueConstraints = tableAnno.uniqueConstraints();
assertEquals( 2, uniqueConstraints.length );
assertEquals( "", uniqueConstraints[0].name() );
assertEquals( 1, uniqueConstraints[0].columnNames().length );
assertEquals( "col3", uniqueConstraints[0].columnNames()[0] );
assertEquals( "uq1", uniqueConstraints[1].name() );
assertEquals( 2, uniqueConstraints[1].columnNames().length );
assertEquals( "col4", uniqueConstraints[1].columnNames()[0] );
assertEquals( "col5", uniqueConstraints[1].columnNames()[1] );
}
public void testAllAttributes() throws Exception {
reader = getReader( Entity2.class, "field1", "element-collection.orm28.xml" );
assertAnnotationPresent( ElementCollection.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( Column.class );
assertAnnotationNotPresent( Temporal.class );
assertAnnotationNotPresent( Enumerated.class );
assertAnnotationNotPresent( Lob.class );
assertAnnotationNotPresent( AttributeOverride.class );
assertAnnotationNotPresent( AttributeOverrides.class );
assertAnnotationNotPresent( AssociationOverride.class );
assertAnnotationNotPresent( AssociationOverrides.class );
assertAnnotationNotPresent( CollectionTable.class );
assertAnnotationPresent( Access.class );
ElementCollection relAnno = reader.getAnnotation( ElementCollection.class );
assertEquals( FetchType.EAGER, relAnno.fetch() );
assertEquals( Entity3.class, relAnno.targetClass() );
assertEquals( AccessType.PROPERTY, reader.getAnnotation( Access.class )
.value() );
}
//TODO: tests for merging/overriding
}

View File

@ -42,7 +42,6 @@ import javax.persistence.MapKeyEnumerated;
import javax.persistence.MapKeyJoinColumn; import javax.persistence.MapKeyJoinColumn;
import javax.persistence.MapKeyJoinColumns; import javax.persistence.MapKeyJoinColumns;
import javax.persistence.MapKeyTemporal; import javax.persistence.MapKeyTemporal;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy; import javax.persistence.OrderBy;
import javax.persistence.OrderColumn; import javax.persistence.OrderColumn;
import javax.persistence.TemporalType; import javax.persistence.TemporalType;
@ -407,8 +406,10 @@ public class Ejb3XmlManyToManyTest extends Ejb3XmlTestCase {
UniqueConstraint[] uniqueConstraints = joinTableAnno UniqueConstraint[] uniqueConstraints = joinTableAnno
.uniqueConstraints(); .uniqueConstraints();
assertEquals( 2, uniqueConstraints.length ); assertEquals( 2, uniqueConstraints.length );
assertEquals( "", uniqueConstraints[0].name() );
assertEquals( 1, uniqueConstraints[0].columnNames().length ); assertEquals( 1, uniqueConstraints[0].columnNames().length );
assertEquals( "col5", uniqueConstraints[0].columnNames()[0] ); assertEquals( "col5", uniqueConstraints[0].columnNames()[0] );
assertEquals( "uq1", uniqueConstraints[1].name() );
assertEquals( 2, uniqueConstraints[1].columnNames().length ); assertEquals( 2, uniqueConstraints[1].columnNames().length );
assertEquals( "col6", uniqueConstraints[1].columnNames()[0] ); assertEquals( "col6", uniqueConstraints[1].columnNames()[0] );
assertEquals( "col7", uniqueConstraints[1].columnNames()[1] ); assertEquals( "col7", uniqueConstraints[1].columnNames()[1] );

View File

@ -169,8 +169,10 @@ public class Ejb3XmlManyToOneTest extends Ejb3XmlTestCase {
UniqueConstraint[] uniqueConstraints = joinTableAnno UniqueConstraint[] uniqueConstraints = joinTableAnno
.uniqueConstraints(); .uniqueConstraints();
assertEquals( 2, uniqueConstraints.length ); assertEquals( 2, uniqueConstraints.length );
assertEquals( "", uniqueConstraints[0].name() );
assertEquals( 1, uniqueConstraints[0].columnNames().length ); assertEquals( 1, uniqueConstraints[0].columnNames().length );
assertEquals( "col5", uniqueConstraints[0].columnNames()[0] ); assertEquals( "col5", uniqueConstraints[0].columnNames()[0] );
assertEquals( "uq1", uniqueConstraints[1].name() );
assertEquals( 2, uniqueConstraints[1].columnNames().length ); assertEquals( 2, uniqueConstraints[1].columnNames().length );
assertEquals( "col6", uniqueConstraints[1].columnNames()[0] ); assertEquals( "col6", uniqueConstraints[1].columnNames()[0] );
assertEquals( "col7", uniqueConstraints[1].columnNames()[1] ); assertEquals( "col7", uniqueConstraints[1].columnNames()[1] );

View File

@ -409,8 +409,10 @@ public class Ejb3XmlOneToManyTest extends Ejb3XmlTestCase {
UniqueConstraint[] uniqueConstraints = joinTableAnno UniqueConstraint[] uniqueConstraints = joinTableAnno
.uniqueConstraints(); .uniqueConstraints();
assertEquals( 2, uniqueConstraints.length ); assertEquals( 2, uniqueConstraints.length );
assertEquals( "", uniqueConstraints[0].name() );
assertEquals( 1, uniqueConstraints[0].columnNames().length ); assertEquals( 1, uniqueConstraints[0].columnNames().length );
assertEquals( "col5", uniqueConstraints[0].columnNames()[0] ); assertEquals( "col5", uniqueConstraints[0].columnNames()[0] );
assertEquals( "uq1", uniqueConstraints[1].name() );
assertEquals( 2, uniqueConstraints[1].columnNames().length ); assertEquals( 2, uniqueConstraints[1].columnNames().length );
assertEquals( "col6", uniqueConstraints[1].columnNames()[0] ); assertEquals( "col6", uniqueConstraints[1].columnNames()[0] );
assertEquals( "col7", uniqueConstraints[1].columnNames()[1] ); assertEquals( "col7", uniqueConstraints[1].columnNames()[1] );

View File

@ -38,7 +38,8 @@ import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.PrimaryKeyJoinColumns; import javax.persistence.PrimaryKeyJoinColumns;
import javax.persistence.UniqueConstraint; import javax.persistence.UniqueConstraint;
public class Ejb3XmlOnetoOneTest extends Ejb3XmlTestCase { public class Ejb3XmlOneToOneTest extends Ejb3XmlTestCase {
public void testNoChildren() throws Exception { public void testNoChildren() throws Exception {
reader = getReader( Entity1.class, "field1", "one-to-one.orm1.xml" ); reader = getReader( Entity1.class, "field1", "one-to-one.orm1.xml" );
assertAnnotationPresent( OneToOne.class ); assertAnnotationPresent( OneToOne.class );
@ -98,7 +99,6 @@ public class Ejb3XmlOnetoOneTest extends Ejb3XmlTestCase {
assertEquals( "col1", joinColumns[1].name() ); assertEquals( "col1", joinColumns[1].name() );
assertEquals( "col2", joinColumns[1].referencedColumnName() ); assertEquals( "col2", joinColumns[1].referencedColumnName() );
assertEquals( "int", joinColumns[1].columnDefinition() ); assertEquals( "int", joinColumns[1].columnDefinition() );
} }
/** /**
@ -224,8 +224,10 @@ public class Ejb3XmlOnetoOneTest extends Ejb3XmlTestCase {
UniqueConstraint[] uniqueConstraints = joinTableAnno UniqueConstraint[] uniqueConstraints = joinTableAnno
.uniqueConstraints(); .uniqueConstraints();
assertEquals( 2, uniqueConstraints.length ); assertEquals( 2, uniqueConstraints.length );
assertEquals( "", uniqueConstraints[0].name() );
assertEquals( 1, uniqueConstraints[0].columnNames().length ); assertEquals( 1, uniqueConstraints[0].columnNames().length );
assertEquals( "col5", uniqueConstraints[0].columnNames()[0] ); assertEquals( "col5", uniqueConstraints[0].columnNames()[0] );
assertEquals( "uq1", uniqueConstraints[1].name() );
assertEquals( 2, uniqueConstraints[1].columnNames().length ); assertEquals( 2, uniqueConstraints[1].columnNames().length );
assertEquals( "col6", uniqueConstraints[1].columnNames()[0] ); assertEquals( "col6", uniqueConstraints[1].columnNames()[0] );
assertEquals( "col7", uniqueConstraints[1].columnNames()[1] ); assertEquals( "col7", uniqueConstraints[1].columnNames()[1] );

View File

@ -30,19 +30,48 @@ import java.lang.reflect.AnnotatedElement;
import org.dom4j.Document; import org.dom4j.Document;
import org.dom4j.io.SAXReader; import org.dom4j.io.SAXReader;
import org.hibernate.Hibernate;
import org.hibernate.cfg.annotations.reflection.JPAOverridenAnnotationReader; import org.hibernate.cfg.annotations.reflection.JPAOverridenAnnotationReader;
import org.hibernate.cfg.annotations.reflection.XMLContext; import org.hibernate.cfg.annotations.reflection.XMLContext;
import org.hibernate.test.annotations.TestCase; import org.hibernate.test.annotations.TestCase;
import org.hibernate.testing.junit.functional.annotations.HibernateTestCase;
abstract class Ejb3XmlTestCase extends TestCase { /**
* Test superclass to provide utility methods for testing the mapping of JPA
* XML to JPA annotations. The configuration is built within each test, and no
* database is used. Thus, no schema generation or cleanup will be performed.
*/
abstract class Ejb3XmlTestCase extends HibernateTestCase {
protected JPAOverridenAnnotationReader reader; protected JPAOverridenAnnotationReader reader;
@Override
protected void buildConfiguration() throws Exception {
//Do nothing
}
@Override
protected void runSchemaGeneration() {
//Do nothing
}
@Override
protected void runSchemaDrop() {
//Do nothing
}
@Override
protected void handleUnclosedResources() {
//Do nothing
}
protected void assertAnnotationPresent(Class<? extends Annotation> annotationType) { protected void assertAnnotationPresent(Class<? extends Annotation> annotationType) {
assertTrue( reader.isAnnotationPresent( annotationType ) ); assertTrue( "Expected annotation " + annotationType.getSimpleName() + " was not present",
reader.isAnnotationPresent( annotationType ) );
} }
protected void assertAnnotationNotPresent(Class<? extends Annotation> annotationType) { protected void assertAnnotationNotPresent(Class<? extends Annotation> annotationType) {
assertFalse( reader.isAnnotationPresent( annotationType ) ); assertFalse( "Unexpected annotation " + annotationType.getSimpleName() + " was present",
reader.isAnnotationPresent( annotationType ) );
} }
protected JPAOverridenAnnotationReader getReader(Class<?> entityClass, String fieldName, String ormResourceName) protected JPAOverridenAnnotationReader getReader(Class<?> entityClass, String fieldName, String ormResourceName)

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>
<element-collection 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>
<element-collection name="field1">
<map-key-attribute-override name="field1">
<column name="col1"/>
</map-key-attribute-override>
</element-collection>
</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>
<element-collection 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>
</element-collection>
</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>
<element-collection name="field1">
<map-key-column/>
</element-collection>
</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>
<element-collection 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"/>
</element-collection>
</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>
<element-collection name="field1">
<map-key-join-column name="col1"/>
</element-collection>
</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>
<element-collection 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"/>
</element-collection>
</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>
<element-collection name="field1">
<column/>
</element-collection>
</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>
<element-collection name="field1">
<column name="col1" column-definition="int" insertable="false"
updatable="false" unique="true" nullable="false" length="50"
precision="2" scale="1" table="table1"/>
</element-collection>
</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>
<element-collection name="field1">
<temporal>DATE</temporal>
</element-collection>
</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>
<element-collection name="field1">
<enumerated>STRING</enumerated>
</element-collection>
</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>
<element-collection name="field1">
<order-by>col1 ASC, col2 DESC</order-by>
</element-collection>
</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>
<element-collection name="field1">
<lob/>
</element-collection>
</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>
<element-collection name="field1">
<attribute-override name="field1">
<column name="col1"/>
</attribute-override>
</element-collection>
</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>
<element-collection name="field1">
<attribute-override name="field1">
<column/>
</attribute-override>
<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"/>
</attribute-override>
</element-collection>
</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-metadata>
<package>org.hibernate.test.annotations.xml.ejb3</package>
<entity class="Entity3">
<attributes>
<element-collection name="field1">
<map-key-attribute-override name="field1">
<column name="col1"/>
</map-key-attribute-override>
<attribute-override name="field2">
<column name="col2"/>
</attribute-override>
</element-collection>
</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>
<element-collection name="field1">
<association-override name="association1"/>
</element-collection>
</attributes>
</entity>
</entity-mappings>

View File

@ -0,0 +1,65 @@
<?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>
<element-collection name="field1">
<association-override name="association1">
<join-table catalog="catalog1" name="table1" 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 name="uq1">
<column-name>col6</column-name>
<column-name>col7</column-name>
</unique-constraint>
</join-table>
</association-override>
<association-override name="association2">
<join-column/>
<join-column name="col8" referenced-column-name="col9"
table="table4" column-definition="int" insertable="false"
updatable="false" nullable="false" unique="true"/>
</association-override>
</element-collection>
</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>
<element-collection name="field1">
<collection-table/>
</element-collection>
</attributes>
</entity>
</entity-mappings>

View File

@ -0,0 +1,54 @@
<?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>
<element-collection name="field1">
<collection-table name="table1" catalog="catalog1"
schema="schema1">
<join-column/>
<join-column name="col1" referenced-column-name="col2"
table="table2" column-definition="int" insertable="false"
nullable="false" updatable="false" unique="true"/>
<unique-constraint>
<column-name>col3</column-name>
</unique-constraint>
<unique-constraint name="uq1">
<column-name>col4</column-name>
<column-name>col5</column-name>
</unique-constraint>
</collection-table>
</element-collection>
</attributes>
</entity>
</entity-mappings>

View File

@ -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="Entity2">
<attributes>
<element-collection name="field1" access="PROPERTY"
fetch="EAGER" target-class="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>
<element-collection name="field1">
<order-column/>
</element-collection>
</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>
<element-collection name="field1">
<order-column column-definition="int" name="col1"
insertable="false" nullable="false" updatable="false"/>
</element-collection>
</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>
<element-collection name="field1">
<map-key/>
</element-collection>
</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>
<element-collection name="field1">
<map-key name="field2"/>
</element-collection>
</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>
<element-collection name="field1">
<map-key-class class="Entity2"/>
</element-collection>
</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>
<element-collection name="field1">
<map-key-temporal>DATE</map-key-temporal>
</element-collection>
</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>
<element-collection name="field1">
<map-key-enumerated>STRING</map-key-enumerated>
</element-collection>
</attributes>
</entity>
</entity-mappings>

View File

@ -46,7 +46,7 @@
<unique-constraint> <unique-constraint>
<column-name>col5</column-name> <column-name>col5</column-name>
</unique-constraint> </unique-constraint>
<unique-constraint> <unique-constraint name="uq1">
<column-name>col6</column-name> <column-name>col6</column-name>
<column-name>col7</column-name> <column-name>col7</column-name>
</unique-constraint> </unique-constraint>

View File

@ -46,7 +46,7 @@
<unique-constraint> <unique-constraint>
<column-name>col5</column-name> <column-name>col5</column-name>
</unique-constraint> </unique-constraint>
<unique-constraint> <unique-constraint name="uq1">
<column-name>col6</column-name> <column-name>col6</column-name>
<column-name>col7</column-name> <column-name>col7</column-name>
</unique-constraint> </unique-constraint>

View File

@ -46,7 +46,7 @@
<unique-constraint> <unique-constraint>
<column-name>col5</column-name> <column-name>col5</column-name>
</unique-constraint> </unique-constraint>
<unique-constraint> <unique-constraint name="uq1">
<column-name>col6</column-name> <column-name>col6</column-name>
<column-name>col7</column-name> <column-name>col7</column-name>
</unique-constraint> </unique-constraint>

View File

@ -46,7 +46,7 @@
<unique-constraint> <unique-constraint>
<column-name>col5</column-name> <column-name>col5</column-name>
</unique-constraint> </unique-constraint>
<unique-constraint> <unique-constraint name="uq1">
<column-name>col6</column-name> <column-name>col6</column-name>
<column-name>col7</column-name> <column-name>col7</column-name>
</unique-constraint> </unique-constraint>