HHH-5800 Applying Hibernate code formatting style
This commit is contained in:
parent
bde29a52d2
commit
95c23b6f50
|
@ -1,10 +1,10 @@
|
||||||
/*
|
/*
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
|
* Copyright (c) 2011 by Red Hat Inc and/or its affiliates or by
|
||||||
* indicated by the @author tags or express copyright attribution
|
* third-party contributors as indicated by either @author tags or express
|
||||||
* statements applied by the authors. All third-party contributions are
|
* copyright attribution statements applied by the authors. All
|
||||||
* distributed under license by Red Hat Inc.
|
* third-party contributions are distributed under license by Red Hat Inc.
|
||||||
*
|
*
|
||||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
* 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
|
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||||
|
@ -51,6 +51,7 @@ import javax.persistence.ColumnResult;
|
||||||
import javax.persistence.DiscriminatorColumn;
|
import javax.persistence.DiscriminatorColumn;
|
||||||
import javax.persistence.DiscriminatorType;
|
import javax.persistence.DiscriminatorType;
|
||||||
import javax.persistence.DiscriminatorValue;
|
import javax.persistence.DiscriminatorValue;
|
||||||
|
import javax.persistence.ElementCollection;
|
||||||
import javax.persistence.Embeddable;
|
import javax.persistence.Embeddable;
|
||||||
import javax.persistence.Embedded;
|
import javax.persistence.Embedded;
|
||||||
import javax.persistence.EmbeddedId;
|
import javax.persistence.EmbeddedId;
|
||||||
|
@ -114,10 +115,12 @@ import javax.persistence.TemporalType;
|
||||||
import javax.persistence.Transient;
|
import javax.persistence.Transient;
|
||||||
import javax.persistence.UniqueConstraint;
|
import javax.persistence.UniqueConstraint;
|
||||||
import javax.persistence.Version;
|
import javax.persistence.Version;
|
||||||
import javax.persistence.ElementCollection;
|
|
||||||
|
|
||||||
import org.dom4j.Attribute;
|
import org.dom4j.Attribute;
|
||||||
import org.dom4j.Element;
|
import org.dom4j.Element;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import org.hibernate.AnnotationException;
|
import org.hibernate.AnnotationException;
|
||||||
import org.hibernate.annotations.Cascade;
|
import org.hibernate.annotations.Cascade;
|
||||||
import org.hibernate.annotations.CollectionOfElements;
|
import org.hibernate.annotations.CollectionOfElements;
|
||||||
|
@ -129,8 +132,6 @@ import org.hibernate.annotations.common.reflection.Filter;
|
||||||
import org.hibernate.annotations.common.reflection.ReflectionUtil;
|
import org.hibernate.annotations.common.reflection.ReflectionUtil;
|
||||||
import org.hibernate.util.ReflectHelper;
|
import org.hibernate.util.ReflectHelper;
|
||||||
import org.hibernate.util.StringHelper;
|
import org.hibernate.util.StringHelper;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encapsulates the overriding of Java annotations from an EJB 3.0 descriptor.
|
* Encapsulates the overriding of Java annotations from an EJB 3.0 descriptor.
|
||||||
|
@ -355,7 +356,6 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
|
||||||
addIfNotNull( annotationList, getAttributeOverrides( tree, defaults, true ) );
|
addIfNotNull( annotationList, getAttributeOverrides( tree, defaults, true ) );
|
||||||
addIfNotNull( annotationList, getAssociationOverrides( tree, defaults, true ) );
|
addIfNotNull( annotationList, getAssociationOverrides( tree, defaults, true ) );
|
||||||
addIfNotNull( annotationList, getEntityListeners( tree, defaults ) );
|
addIfNotNull( annotationList, getEntityListeners( tree, defaults ) );
|
||||||
//FIXME use annotationsMap rather than annotationList this will be faster since the annotation type is usually known at put() time
|
|
||||||
this.annotations = annotationList.toArray( new Annotation[annotationList.size()] );
|
this.annotations = annotationList.toArray( new Annotation[annotationList.size()] );
|
||||||
for ( Annotation ann : this.annotations ) {
|
for ( Annotation ann : this.annotations ) {
|
||||||
annotationsMap.put( ann.annotationType(), ann );
|
annotationsMap.put( ann.annotationType(), ann );
|
||||||
|
@ -442,9 +442,11 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
|
||||||
for ( Element subelement : (List<Element>) element.elements() ) {
|
for ( Element subelement : (List<Element>) element.elements() ) {
|
||||||
String propertyName = subelement.attributeValue( "name" );
|
String propertyName = subelement.attributeValue( "name" );
|
||||||
if ( !properties.contains( propertyName ) ) {
|
if ( !properties.contains( propertyName ) ) {
|
||||||
log.warn( "Property {} not found in class"
|
log.warn(
|
||||||
|
"Property {} not found in class"
|
||||||
+ " but described in <mapping-file/> (possible typo error)",
|
+ " but described in <mapping-file/> (possible typo error)",
|
||||||
StringHelper.qualify( className, propertyName ) );
|
StringHelper.qualify( className, propertyName )
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1103,12 +1105,24 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
|
||||||
List<Element> elements = element != null ? element.elements( "cascade" ) : new ArrayList<Element>( 0 );
|
List<Element> elements = element != null ? element.elements( "cascade" ) : new ArrayList<Element>( 0 );
|
||||||
List<CascadeType> cascades = new ArrayList<CascadeType>();
|
List<CascadeType> cascades = new ArrayList<CascadeType>();
|
||||||
for ( Element subelement : elements ) {
|
for ( Element subelement : elements ) {
|
||||||
if ( subelement.element( "cascade-all" ) != null ) cascades.add( CascadeType.ALL );
|
if ( subelement.element( "cascade-all" ) != null ) {
|
||||||
if ( subelement.element( "cascade-persist" ) != null ) cascades.add( CascadeType.PERSIST );
|
cascades.add( CascadeType.ALL );
|
||||||
if ( subelement.element( "cascade-merge" ) != null ) cascades.add( CascadeType.MERGE );
|
}
|
||||||
if ( subelement.element( "cascade-remove" ) != null ) cascades.add( CascadeType.REMOVE );
|
if ( subelement.element( "cascade-persist" ) != null ) {
|
||||||
if ( subelement.element( "cascade-refresh" ) != null ) cascades.add( CascadeType.REFRESH );
|
cascades.add( CascadeType.PERSIST );
|
||||||
if ( subelement.element( "cascade-detach" ) != null ) cascades.add( CascadeType.DETACH );
|
}
|
||||||
|
if ( subelement.element( "cascade-merge" ) != null ) {
|
||||||
|
cascades.add( CascadeType.MERGE );
|
||||||
|
}
|
||||||
|
if ( subelement.element( "cascade-remove" ) != null ) {
|
||||||
|
cascades.add( CascadeType.REMOVE );
|
||||||
|
}
|
||||||
|
if ( subelement.element( "cascade-refresh" ) != null ) {
|
||||||
|
cascades.add( CascadeType.REFRESH );
|
||||||
|
}
|
||||||
|
if ( subelement.element( "cascade-detach" ) != null ) {
|
||||||
|
cascades.add( CascadeType.DETACH );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ( Boolean.TRUE.equals( defaults.getCascadePersist() )
|
if ( Boolean.TRUE.equals( defaults.getCascadePersist() )
|
||||||
&& !cascades.contains( CascadeType.ALL ) && !cascades.contains( CascadeType.PERSIST ) ) {
|
&& !cascades.contains( CascadeType.ALL ) && !cascades.contains( CascadeType.PERSIST ) ) {
|
||||||
|
@ -1381,7 +1395,8 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
|
||||||
boolean isExplicit = defaults.getAccess() != null;
|
boolean isExplicit = defaults.getAccess() != null;
|
||||||
boolean correctAccess =
|
boolean correctAccess =
|
||||||
( PropertyType.PROPERTY.equals( propertyType ) && AccessType.PROPERTY.equals( defaults.getAccess() ) )
|
( PropertyType.PROPERTY.equals( propertyType ) && AccessType.PROPERTY.equals( defaults.getAccess() ) )
|
||||||
|| ( PropertyType.FIELD.equals( propertyType ) && AccessType.FIELD.equals( defaults.getAccess() ) );
|
|| ( PropertyType.FIELD.equals( propertyType ) && AccessType.FIELD
|
||||||
|
.equals( defaults.getAccess() ) );
|
||||||
boolean hasId = defaults.canUseJavaAnnotations()
|
boolean hasId = defaults.canUseJavaAnnotations()
|
||||||
&& ( isJavaAnnotationPresent( Id.class ) || isJavaAnnotationPresent( EmbeddedId.class ) );
|
&& ( isJavaAnnotationPresent( Id.class ) || isJavaAnnotationPresent( EmbeddedId.class ) );
|
||||||
//if ( properAccessOnMetadataComplete || properOverridingOnMetadataNonComplete ) {
|
//if ( properAccessOnMetadataComplete || properOverridingOnMetadataNonComplete ) {
|
||||||
|
@ -1562,7 +1577,9 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( !present ) overrides.add( annotation );
|
if ( !present ) {
|
||||||
|
overrides.add( annotation );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1613,7 +1630,9 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
|
||||||
List<AttributeOverride> overrides = new ArrayList<AttributeOverride>();
|
List<AttributeOverride> overrides = new ArrayList<AttributeOverride>();
|
||||||
if ( subelements != null && subelements.size() > 0 ) {
|
if ( subelements != null && subelements.size() > 0 ) {
|
||||||
for ( Element current : subelements ) {
|
for ( Element current : subelements ) {
|
||||||
if ( !current.getName().equals( nodeName ) ) continue;
|
if ( !current.getName().equals( nodeName ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
AnnotationDescriptor override = new AnnotationDescriptor( AttributeOverride.class );
|
AnnotationDescriptor override = new AnnotationDescriptor( AttributeOverride.class );
|
||||||
copyStringAttribute( override, current, "name", true );
|
copyStringAttribute( override, current, "name", true );
|
||||||
Element column = current.element( "column" );
|
Element column = current.element( "column" );
|
||||||
|
@ -1658,7 +1677,9 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( !present ) overrides.add( annotation );
|
if ( !present ) {
|
||||||
|
overrides.add( annotation );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1736,7 +1757,9 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<SqlResultSetMapping> buildSqlResultsetMappings(Element element, XMLContext.Default defaults) {
|
public static List<SqlResultSetMapping> buildSqlResultsetMappings(Element element, XMLContext.Default defaults) {
|
||||||
if ( element == null ) return new ArrayList<SqlResultSetMapping>();
|
if ( element == null ) {
|
||||||
|
return new ArrayList<SqlResultSetMapping>();
|
||||||
|
}
|
||||||
List resultsetElementList = element.elements( "sql-result-set-mapping" );
|
List resultsetElementList = element.elements( "sql-result-set-mapping" );
|
||||||
List<SqlResultSetMapping> resultsets = new ArrayList<SqlResultSetMapping>();
|
List<SqlResultSetMapping> resultsets = new ArrayList<SqlResultSetMapping>();
|
||||||
Iterator it = resultsetElementList.listIterator();
|
Iterator it = resultsetElementList.listIterator();
|
||||||
|
@ -1817,7 +1840,9 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( !present ) resultsets.add( annotation );
|
if ( !present ) {
|
||||||
|
resultsets.add( annotation );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1854,7 +1879,9 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( !present ) queries.add( annotation );
|
if ( !present ) {
|
||||||
|
queries.add( annotation );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1890,12 +1917,16 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( !present ) queries.add( annotation );
|
if ( !present ) {
|
||||||
|
queries.add( annotation );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List buildNamedQueries(Element element, boolean isNative, XMLContext.Default defaults) {
|
public static List buildNamedQueries(Element element, boolean isNative, XMLContext.Default defaults) {
|
||||||
if ( element == null ) return new ArrayList();
|
if ( element == null ) {
|
||||||
|
return new ArrayList();
|
||||||
|
}
|
||||||
List namedQueryElementList = isNative ?
|
List namedQueryElementList = isNative ?
|
||||||
element.elements( "named-native-query" ) :
|
element.elements( "named-native-query" ) :
|
||||||
element.elements( "named-query" );
|
element.elements( "named-query" );
|
||||||
|
@ -1908,17 +1939,23 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
|
||||||
);
|
);
|
||||||
copyStringAttribute( ann, subelement, "name", false );
|
copyStringAttribute( ann, subelement, "name", false );
|
||||||
Element queryElt = subelement.element( "query" );
|
Element queryElt = subelement.element( "query" );
|
||||||
if ( queryElt == null ) throw new AnnotationException( "No <query> element found." + SCHEMA_VALIDATION );
|
if ( queryElt == null ) {
|
||||||
|
throw new AnnotationException( "No <query> element found." + SCHEMA_VALIDATION );
|
||||||
|
}
|
||||||
copyStringElement( queryElt, ann, "query" );
|
copyStringElement( queryElt, ann, "query" );
|
||||||
List<Element> elements = subelement.elements( "hint" );
|
List<Element> elements = subelement.elements( "hint" );
|
||||||
List<QueryHint> queryHints = new ArrayList<QueryHint>( elements.size() );
|
List<QueryHint> queryHints = new ArrayList<QueryHint>( elements.size() );
|
||||||
for ( Element hint : elements ) {
|
for ( Element hint : elements ) {
|
||||||
AnnotationDescriptor hintDescriptor = new AnnotationDescriptor( QueryHint.class );
|
AnnotationDescriptor hintDescriptor = new AnnotationDescriptor( QueryHint.class );
|
||||||
String value = hint.attributeValue( "name" );
|
String value = hint.attributeValue( "name" );
|
||||||
if ( value == null ) throw new AnnotationException( "<hint> without name. " + SCHEMA_VALIDATION );
|
if ( value == null ) {
|
||||||
|
throw new AnnotationException( "<hint> without name. " + SCHEMA_VALIDATION );
|
||||||
|
}
|
||||||
hintDescriptor.setValue( "name", value );
|
hintDescriptor.setValue( "name", value );
|
||||||
value = hint.attributeValue( "value" );
|
value = hint.attributeValue( "value" );
|
||||||
if ( value == null ) throw new AnnotationException( "<hint> without value. " + SCHEMA_VALIDATION );
|
if ( value == null ) {
|
||||||
|
throw new AnnotationException( "<hint> without value. " + SCHEMA_VALIDATION );
|
||||||
|
}
|
||||||
hintDescriptor.setValue( "value", value );
|
hintDescriptor.setValue( "value", value );
|
||||||
queryHints.add( (QueryHint) AnnotationFactory.create( hintDescriptor ) );
|
queryHints.add( (QueryHint) AnnotationFactory.create( hintDescriptor ) );
|
||||||
}
|
}
|
||||||
|
@ -2189,7 +2226,9 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
|
||||||
if ( defaults.canUseJavaAnnotations()
|
if ( defaults.canUseJavaAnnotations()
|
||||||
&& StringHelper.isEmpty( (String) entity.valueOf( "name" ) ) ) {
|
&& StringHelper.isEmpty( (String) entity.valueOf( "name" ) ) ) {
|
||||||
Entity javaAnn = getJavaAnnotation( Entity.class );
|
Entity javaAnn = getJavaAnnotation( Entity.class );
|
||||||
if ( javaAnn != null ) entity.setValue( "name", javaAnn.name() );
|
if ( javaAnn != null ) {
|
||||||
|
entity.setValue( "name", javaAnn.name() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return AnnotationFactory.create( entity );
|
return AnnotationFactory.create( entity );
|
||||||
}
|
}
|
||||||
|
@ -2380,7 +2419,9 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
private PrimaryKeyJoinColumn[] buildPrimaryKeyJoinColumns(Element element) {
|
private PrimaryKeyJoinColumn[] buildPrimaryKeyJoinColumns(Element element) {
|
||||||
if ( element == null ) return new PrimaryKeyJoinColumn[] { };
|
if ( element == null ) {
|
||||||
|
return new PrimaryKeyJoinColumn[] { };
|
||||||
|
}
|
||||||
List pkJoinColumnElementList = element.elements( "primary-key-join-column" );
|
List pkJoinColumnElementList = element.elements( "primary-key-join-column" );
|
||||||
PrimaryKeyJoinColumn[] pkJoinColumns = new PrimaryKeyJoinColumn[pkJoinColumnElementList.size()];
|
PrimaryKeyJoinColumn[] pkJoinColumns = new PrimaryKeyJoinColumn[pkJoinColumnElementList.size()];
|
||||||
int index = 0;
|
int index = 0;
|
||||||
|
@ -2407,7 +2448,7 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
|
||||||
else {
|
else {
|
||||||
if ( mandatory ) {
|
if ( mandatory ) {
|
||||||
throw new AnnotationException(
|
throw new AnnotationException(
|
||||||
element.getName() + "." + attributeName + " is mandatory in XML overring. " + SCHEMA_VALIDATION
|
element.getName() + "." + attributeName + " is mandatory in XML overriding. " + SCHEMA_VALIDATION
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
|
* Copyright (c) 2011 by Red Hat Inc and/or its affiliates or by
|
||||||
* third-party contributors as indicated by either @author tags or express
|
* third-party contributors as indicated by either @author tags or express
|
||||||
* copyright attribution statements applied by the authors. All
|
* copyright attribution statements applied by the authors. All
|
||||||
* third-party contributions are distributed under license by Red Hat Inc.
|
* third-party contributions are distributed under license by Red Hat Inc.
|
||||||
|
@ -86,8 +86,10 @@ public class Ejb3XmlElementCollectionTest extends Ejb3XmlTestCase {
|
||||||
assertAnnotationPresent( ElementCollection.class );
|
assertAnnotationPresent( ElementCollection.class );
|
||||||
assertAnnotationPresent( OrderBy.class );
|
assertAnnotationPresent( OrderBy.class );
|
||||||
assertAnnotationNotPresent( OrderColumn.class );
|
assertAnnotationNotPresent( OrderColumn.class );
|
||||||
assertEquals( "col1 ASC, col2 DESC", reader.getAnnotation( OrderBy.class )
|
assertEquals(
|
||||||
.value() );
|
"col1 ASC, col2 DESC", reader.getAnnotation( OrderBy.class )
|
||||||
|
.value()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testOrderColumnNoAttributes() throws Exception {
|
public void testOrderColumnNoAttributes() throws Exception {
|
||||||
|
@ -152,8 +154,10 @@ public class Ejb3XmlElementCollectionTest extends Ejb3XmlTestCase {
|
||||||
assertAnnotationNotPresent( MapKeyColumn.class );
|
assertAnnotationNotPresent( MapKeyColumn.class );
|
||||||
assertAnnotationNotPresent( MapKeyJoinColumns.class );
|
assertAnnotationNotPresent( MapKeyJoinColumns.class );
|
||||||
assertAnnotationNotPresent( MapKeyJoinColumn.class );
|
assertAnnotationNotPresent( MapKeyJoinColumn.class );
|
||||||
assertEquals( Entity2.class, reader.getAnnotation( MapKeyClass.class )
|
assertEquals(
|
||||||
.value() );
|
Entity2.class, reader.getAnnotation( MapKeyClass.class )
|
||||||
|
.value()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMapKeyTemporal() throws Exception {
|
public void testMapKeyTemporal() throws Exception {
|
||||||
|
@ -166,8 +170,11 @@ public class Ejb3XmlElementCollectionTest extends Ejb3XmlTestCase {
|
||||||
assertAnnotationNotPresent( MapKeyColumn.class );
|
assertAnnotationNotPresent( MapKeyColumn.class );
|
||||||
assertAnnotationNotPresent( MapKeyJoinColumns.class );
|
assertAnnotationNotPresent( MapKeyJoinColumns.class );
|
||||||
assertAnnotationNotPresent( MapKeyJoinColumn.class );
|
assertAnnotationNotPresent( MapKeyJoinColumn.class );
|
||||||
assertEquals( TemporalType.DATE, reader.getAnnotation(
|
assertEquals(
|
||||||
MapKeyTemporal.class ).value() );
|
TemporalType.DATE, reader.getAnnotation(
|
||||||
|
MapKeyTemporal.class
|
||||||
|
).value()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMapKeyEnumerated() throws Exception {
|
public void testMapKeyEnumerated() throws Exception {
|
||||||
|
@ -180,8 +187,11 @@ public class Ejb3XmlElementCollectionTest extends Ejb3XmlTestCase {
|
||||||
assertAnnotationNotPresent( MapKeyColumn.class );
|
assertAnnotationNotPresent( MapKeyColumn.class );
|
||||||
assertAnnotationNotPresent( MapKeyJoinColumns.class );
|
assertAnnotationNotPresent( MapKeyJoinColumns.class );
|
||||||
assertAnnotationNotPresent( MapKeyJoinColumn.class );
|
assertAnnotationNotPresent( MapKeyJoinColumn.class );
|
||||||
assertEquals( EnumType.STRING, reader.getAnnotation(
|
assertEquals(
|
||||||
MapKeyEnumerated.class ).value() );
|
EnumType.STRING, reader.getAnnotation(
|
||||||
|
MapKeyEnumerated.class
|
||||||
|
).value()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -387,8 +397,11 @@ public class Ejb3XmlElementCollectionTest extends Ejb3XmlTestCase {
|
||||||
assertAnnotationPresent( Temporal.class );
|
assertAnnotationPresent( Temporal.class );
|
||||||
assertAnnotationNotPresent( Enumerated.class );
|
assertAnnotationNotPresent( Enumerated.class );
|
||||||
assertAnnotationNotPresent( Lob.class );
|
assertAnnotationNotPresent( Lob.class );
|
||||||
assertEquals( TemporalType.DATE, reader.getAnnotation(
|
assertEquals(
|
||||||
Temporal.class ).value() );
|
TemporalType.DATE, reader.getAnnotation(
|
||||||
|
Temporal.class
|
||||||
|
).value()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testEnumerated() throws Exception {
|
public void testEnumerated() throws Exception {
|
||||||
|
@ -397,8 +410,11 @@ public class Ejb3XmlElementCollectionTest extends Ejb3XmlTestCase {
|
||||||
assertAnnotationNotPresent( Temporal.class );
|
assertAnnotationNotPresent( Temporal.class );
|
||||||
assertAnnotationPresent( Enumerated.class );
|
assertAnnotationPresent( Enumerated.class );
|
||||||
assertAnnotationNotPresent( Lob.class );
|
assertAnnotationNotPresent( Lob.class );
|
||||||
assertEquals( EnumType.STRING, reader.getAnnotation(
|
assertEquals(
|
||||||
Enumerated.class ).value() );
|
EnumType.STRING, reader.getAnnotation(
|
||||||
|
Enumerated.class
|
||||||
|
).value()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testLob() throws Exception {
|
public void testLob() throws Exception {
|
||||||
|
@ -666,8 +682,10 @@ public class Ejb3XmlElementCollectionTest extends Ejb3XmlTestCase {
|
||||||
ElementCollection relAnno = reader.getAnnotation( ElementCollection.class );
|
ElementCollection relAnno = reader.getAnnotation( ElementCollection.class );
|
||||||
assertEquals( FetchType.EAGER, relAnno.fetch() );
|
assertEquals( FetchType.EAGER, relAnno.fetch() );
|
||||||
assertEquals( Entity3.class, relAnno.targetClass() );
|
assertEquals( Entity3.class, relAnno.targetClass() );
|
||||||
assertEquals( AccessType.PROPERTY, reader.getAnnotation( Access.class )
|
assertEquals(
|
||||||
.value() );
|
AccessType.PROPERTY, reader.getAnnotation( Access.class )
|
||||||
|
.value()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
|
* Copyright (c) 2011 by Red Hat Inc and/or its affiliates or by
|
||||||
* third-party contributors as indicated by either @author tags or express
|
* third-party contributors as indicated by either @author tags or express
|
||||||
* copyright attribution statements applied by the authors. All
|
* copyright attribution statements applied by the authors. All
|
||||||
* third-party contributions are distributed under license by Red Hat Inc.
|
* third-party contributions are distributed under license by Red Hat Inc.
|
||||||
|
@ -75,8 +75,10 @@ public class Ejb3XmlManyToManyTest extends Ejb3XmlTestCase {
|
||||||
assertAnnotationPresent( ManyToMany.class );
|
assertAnnotationPresent( ManyToMany.class );
|
||||||
assertAnnotationPresent( OrderBy.class );
|
assertAnnotationPresent( OrderBy.class );
|
||||||
assertAnnotationNotPresent( OrderColumn.class );
|
assertAnnotationNotPresent( OrderColumn.class );
|
||||||
assertEquals( "col1 ASC, col2 DESC", reader.getAnnotation( OrderBy.class )
|
assertEquals(
|
||||||
.value() );
|
"col1 ASC, col2 DESC", reader.getAnnotation( OrderBy.class )
|
||||||
|
.value()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testOrderColumnNoAttributes() throws Exception {
|
public void testOrderColumnNoAttributes() throws Exception {
|
||||||
|
@ -141,8 +143,10 @@ public class Ejb3XmlManyToManyTest extends Ejb3XmlTestCase {
|
||||||
assertAnnotationNotPresent( MapKeyColumn.class );
|
assertAnnotationNotPresent( MapKeyColumn.class );
|
||||||
assertAnnotationNotPresent( MapKeyJoinColumns.class );
|
assertAnnotationNotPresent( MapKeyJoinColumns.class );
|
||||||
assertAnnotationNotPresent( MapKeyJoinColumn.class );
|
assertAnnotationNotPresent( MapKeyJoinColumn.class );
|
||||||
assertEquals( Entity2.class, reader.getAnnotation( MapKeyClass.class )
|
assertEquals(
|
||||||
.value() );
|
Entity2.class, reader.getAnnotation( MapKeyClass.class )
|
||||||
|
.value()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMapKeyTemporal() throws Exception {
|
public void testMapKeyTemporal() throws Exception {
|
||||||
|
@ -155,8 +159,11 @@ public class Ejb3XmlManyToManyTest extends Ejb3XmlTestCase {
|
||||||
assertAnnotationNotPresent( MapKeyColumn.class );
|
assertAnnotationNotPresent( MapKeyColumn.class );
|
||||||
assertAnnotationNotPresent( MapKeyJoinColumns.class );
|
assertAnnotationNotPresent( MapKeyJoinColumns.class );
|
||||||
assertAnnotationNotPresent( MapKeyJoinColumn.class );
|
assertAnnotationNotPresent( MapKeyJoinColumn.class );
|
||||||
assertEquals( TemporalType.DATE, reader.getAnnotation(
|
assertEquals(
|
||||||
MapKeyTemporal.class ).value() );
|
TemporalType.DATE, reader.getAnnotation(
|
||||||
|
MapKeyTemporal.class
|
||||||
|
).value()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMapKeyEnumerated() throws Exception {
|
public void testMapKeyEnumerated() throws Exception {
|
||||||
|
@ -169,8 +176,11 @@ public class Ejb3XmlManyToManyTest extends Ejb3XmlTestCase {
|
||||||
assertAnnotationNotPresent( MapKeyColumn.class );
|
assertAnnotationNotPresent( MapKeyColumn.class );
|
||||||
assertAnnotationNotPresent( MapKeyJoinColumns.class );
|
assertAnnotationNotPresent( MapKeyJoinColumns.class );
|
||||||
assertAnnotationNotPresent( MapKeyJoinColumn.class );
|
assertAnnotationNotPresent( MapKeyJoinColumn.class );
|
||||||
assertEquals( EnumType.STRING, reader.getAnnotation(
|
assertEquals(
|
||||||
MapKeyEnumerated.class ).value() );
|
EnumType.STRING, reader.getAnnotation(
|
||||||
|
MapKeyEnumerated.class
|
||||||
|
).value()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -471,8 +481,10 @@ public class Ejb3XmlManyToManyTest extends Ejb3XmlTestCase {
|
||||||
assertEquals( FetchType.EAGER, relAnno.fetch() );
|
assertEquals( FetchType.EAGER, relAnno.fetch() );
|
||||||
assertEquals( "field2", relAnno.mappedBy() );
|
assertEquals( "field2", relAnno.mappedBy() );
|
||||||
assertEquals( Entity3.class, relAnno.targetEntity() );
|
assertEquals( Entity3.class, relAnno.targetEntity() );
|
||||||
assertEquals( AccessType.PROPERTY, reader.getAnnotation( Access.class )
|
assertEquals(
|
||||||
.value() );
|
AccessType.PROPERTY, reader.getAnnotation( Access.class )
|
||||||
|
.value()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -193,8 +193,10 @@ public class Ejb3XmlManyToOneTest extends Ejb3XmlTestCase {
|
||||||
assertFalse( relAnno.optional() );
|
assertFalse( relAnno.optional() );
|
||||||
assertEquals( Entity3.class, relAnno.targetEntity() );
|
assertEquals( Entity3.class, relAnno.targetEntity() );
|
||||||
assertEquals( "col1", reader.getAnnotation( MapsId.class ).value() );
|
assertEquals( "col1", reader.getAnnotation( MapsId.class ).value() );
|
||||||
assertEquals( AccessType.PROPERTY, reader.getAnnotation( Access.class )
|
assertEquals(
|
||||||
.value() );
|
AccessType.PROPERTY, reader.getAnnotation( Access.class )
|
||||||
|
.value()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCascadeAll() throws Exception {
|
public void testCascadeAll() throws Exception {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
|
* Copyright (c) 2011 by Red Hat Inc and/or its affiliates or by
|
||||||
* third-party contributors as indicated by either @author tags or express
|
* third-party contributors as indicated by either @author tags or express
|
||||||
* copyright attribution statements applied by the authors. All
|
* copyright attribution statements applied by the authors. All
|
||||||
* third-party contributions are distributed under license by Red Hat Inc.
|
* third-party contributions are distributed under license by Red Hat Inc.
|
||||||
|
@ -78,8 +78,10 @@ public class Ejb3XmlOneToManyTest extends Ejb3XmlTestCase {
|
||||||
assertAnnotationPresent( OneToMany.class );
|
assertAnnotationPresent( OneToMany.class );
|
||||||
assertAnnotationPresent( OrderBy.class );
|
assertAnnotationPresent( OrderBy.class );
|
||||||
assertAnnotationNotPresent( OrderColumn.class );
|
assertAnnotationNotPresent( OrderColumn.class );
|
||||||
assertEquals( "col1 ASC, col2 DESC", reader.getAnnotation( OrderBy.class )
|
assertEquals(
|
||||||
.value() );
|
"col1 ASC, col2 DESC", reader.getAnnotation( OrderBy.class )
|
||||||
|
.value()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testOrderColumnNoAttributes() throws Exception {
|
public void testOrderColumnNoAttributes() throws Exception {
|
||||||
|
@ -144,8 +146,10 @@ public class Ejb3XmlOneToManyTest extends Ejb3XmlTestCase {
|
||||||
assertAnnotationNotPresent( MapKeyColumn.class );
|
assertAnnotationNotPresent( MapKeyColumn.class );
|
||||||
assertAnnotationNotPresent( MapKeyJoinColumns.class );
|
assertAnnotationNotPresent( MapKeyJoinColumns.class );
|
||||||
assertAnnotationNotPresent( MapKeyJoinColumn.class );
|
assertAnnotationNotPresent( MapKeyJoinColumn.class );
|
||||||
assertEquals( Entity2.class, reader.getAnnotation( MapKeyClass.class )
|
assertEquals(
|
||||||
.value() );
|
Entity2.class, reader.getAnnotation( MapKeyClass.class )
|
||||||
|
.value()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMapKeyTemporal() throws Exception {
|
public void testMapKeyTemporal() throws Exception {
|
||||||
|
@ -158,8 +162,11 @@ public class Ejb3XmlOneToManyTest extends Ejb3XmlTestCase {
|
||||||
assertAnnotationNotPresent( MapKeyColumn.class );
|
assertAnnotationNotPresent( MapKeyColumn.class );
|
||||||
assertAnnotationNotPresent( MapKeyJoinColumns.class );
|
assertAnnotationNotPresent( MapKeyJoinColumns.class );
|
||||||
assertAnnotationNotPresent( MapKeyJoinColumn.class );
|
assertAnnotationNotPresent( MapKeyJoinColumn.class );
|
||||||
assertEquals( TemporalType.DATE, reader.getAnnotation(
|
assertEquals(
|
||||||
MapKeyTemporal.class ).value() );
|
TemporalType.DATE, reader.getAnnotation(
|
||||||
|
MapKeyTemporal.class
|
||||||
|
).value()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMapKeyEnumerated() throws Exception {
|
public void testMapKeyEnumerated() throws Exception {
|
||||||
|
@ -172,8 +179,11 @@ public class Ejb3XmlOneToManyTest extends Ejb3XmlTestCase {
|
||||||
assertAnnotationNotPresent( MapKeyColumn.class );
|
assertAnnotationNotPresent( MapKeyColumn.class );
|
||||||
assertAnnotationNotPresent( MapKeyJoinColumns.class );
|
assertAnnotationNotPresent( MapKeyJoinColumns.class );
|
||||||
assertAnnotationNotPresent( MapKeyJoinColumn.class );
|
assertAnnotationNotPresent( MapKeyJoinColumn.class );
|
||||||
assertEquals( EnumType.STRING, reader.getAnnotation(
|
assertEquals(
|
||||||
MapKeyEnumerated.class ).value() );
|
EnumType.STRING, reader.getAnnotation(
|
||||||
|
MapKeyEnumerated.class
|
||||||
|
).value()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -522,8 +532,10 @@ public class Ejb3XmlOneToManyTest extends Ejb3XmlTestCase {
|
||||||
assertEquals( "field2", relAnno.mappedBy() );
|
assertEquals( "field2", relAnno.mappedBy() );
|
||||||
assertTrue( relAnno.orphanRemoval() );
|
assertTrue( relAnno.orphanRemoval() );
|
||||||
assertEquals( Entity3.class, relAnno.targetEntity() );
|
assertEquals( Entity3.class, relAnno.targetEntity() );
|
||||||
assertEquals( AccessType.PROPERTY, reader.getAnnotation( Access.class )
|
assertEquals(
|
||||||
.value() );
|
AccessType.PROPERTY, reader.getAnnotation( Access.class )
|
||||||
|
.value()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
|
* Copyright (c) 2011 by Red Hat Inc and/or its affiliates or by
|
||||||
* third-party contributors as indicated by either @author tags or express
|
* third-party contributors as indicated by either @author tags or express
|
||||||
* copyright attribution statements applied by the authors. All
|
* copyright attribution statements applied by the authors. All
|
||||||
* third-party contributions are distributed under license by Red Hat Inc.
|
* third-party contributions are distributed under license by Red Hat Inc.
|
||||||
|
@ -288,10 +288,14 @@ public class Ejb3XmlOneToOneTest extends Ejb3XmlTestCase {
|
||||||
assertFalse( relAnno.optional() );
|
assertFalse( relAnno.optional() );
|
||||||
assertTrue( relAnno.orphanRemoval() );
|
assertTrue( relAnno.orphanRemoval() );
|
||||||
assertEquals( Entity3.class, relAnno.targetEntity() );
|
assertEquals( Entity3.class, relAnno.targetEntity() );
|
||||||
assertEquals( AccessType.PROPERTY, reader.getAnnotation( Access.class )
|
assertEquals(
|
||||||
.value() );
|
AccessType.PROPERTY, reader.getAnnotation( Access.class )
|
||||||
assertEquals( "field3", reader.getAnnotation( MapsId.class )
|
.value()
|
||||||
.value() );
|
);
|
||||||
|
assertEquals(
|
||||||
|
"field3", reader.getAnnotation( MapsId.class )
|
||||||
|
.value()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,10 +30,9 @@ 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.testing.junit.functional.annotations.HibernateTestCase;
|
import org.hibernate.testing.junit.functional.annotations.HibernateTestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -64,14 +63,23 @@ abstract class Ejb3XmlTestCase extends HibernateTestCase {
|
||||||
//Do nothing
|
//Do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Class<?>[] getAnnotatedClasses() {
|
||||||
|
return new Class<?>[0];
|
||||||
|
}
|
||||||
|
|
||||||
protected void assertAnnotationPresent(Class<? extends Annotation> annotationType) {
|
protected void assertAnnotationPresent(Class<? extends Annotation> annotationType) {
|
||||||
assertTrue( "Expected annotation " + annotationType.getSimpleName() + " was not present",
|
assertTrue(
|
||||||
reader.isAnnotationPresent( annotationType ) );
|
"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( "Unexpected annotation " + annotationType.getSimpleName() + " was present",
|
assertFalse(
|
||||||
reader.isAnnotationPresent( annotationType ) );
|
"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)
|
||||||
|
@ -98,9 +106,4 @@ abstract class Ejb3XmlTestCase extends HibernateTestCase {
|
||||||
xmlContext.addDocument( doc );
|
xmlContext.addDocument( doc );
|
||||||
return xmlContext;
|
return xmlContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Class<?>[] getAnnotatedClasses() {
|
|
||||||
return new Class<?>[0];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
|
* Copyright (c) 2011 by Red Hat Inc and/or its affiliates or by
|
||||||
* third-party contributors as indicated by either @author tags or express
|
* third-party contributors as indicated by either @author tags or express
|
||||||
* copyright attribution statements applied by the authors. All
|
* copyright attribution statements applied by the authors. All
|
||||||
* third-party contributions are distributed under license by Red Hat Inc.
|
* third-party contributions are distributed under license by Red Hat Inc.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* Copyright (c) 2010 by Red Hat Inc and/or its affiliates or by
|
* Copyright (c) 2011 by Red Hat Inc and/or its affiliates or by
|
||||||
* third-party contributors as indicated by either @author tags or express
|
* third-party contributors as indicated by either @author tags or express
|
||||||
* copyright attribution statements applied by the authors. All
|
* copyright attribution statements applied by the authors. All
|
||||||
* third-party contributions are distributed under license by Red Hat Inc.
|
* third-party contributions are distributed under license by Red Hat Inc.
|
||||||
|
|
|
@ -5,8 +5,8 @@ import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.OneToMany;
|
|
||||||
import javax.persistence.NamedQuery;
|
import javax.persistence.NamedQuery;
|
||||||
|
import javax.persistence.OneToMany;
|
||||||
import javax.persistence.TableGenerator;
|
import javax.persistence.TableGenerator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue