HHH-6368 remove deprecated hibernate annotations

This commit is contained in:
Strong Liu 2011-06-27 22:58:18 +08:00 committed by Hardy Ferentschik
parent 919cdf7c69
commit ffb14b28b7
28 changed files with 49 additions and 352 deletions

View File

@ -1,50 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
* indicated by the @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.annotations;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.persistence.FetchType;
/**
* Annotation used to mark a collection as a collection of elements or
* a collection of embedded objects
*
* @deprecated use @ElementCollection
* @author Emmanuel Bernard
*/
@Target({METHOD, FIELD})
@Retention(RUNTIME)
@Deprecated
public @interface CollectionOfElements {
/**
* Represent the element class in the collection
* Only useful if the collection does not use generics
*/
Class targetElement() default void.class;
FetchType fetch() default FetchType.LAZY;
}

View File

@ -1,40 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
* indicated by the @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.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* ForceDiscriminator flag
* To be placed at the root entity near @DiscriminatorColumn or @DiscriminatorFormula
*
* @author Serg Prasolov
* @deprecated use {@link org.hibernate.annotations.DiscriminatorOptions} instead
*/
@Target({ ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
public @interface ForceDiscriminator {
}

View File

@ -1,57 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
* indicated by the @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.annotations;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import javax.persistence.Column;
/**
* Define the map key columns as an explicit column holding the map key
* This is completely different from {@link javax.persistence.MapKey} which use an existing column
* This annotation and {@link javax.persistence.MapKey} are mutually exclusive
*
* @deprecated Use {@link javax.persistence.MapKeyColumn}
* This is the default behavior for Map properties marked as @OneToMany, @ManyToMany
* or @ElementCollection
* @author Emmanuel Bernard
*/
@Target({METHOD, FIELD})
@Retention(RUNTIME)
@Deprecated
public @interface MapKey {
Column[] columns() default {};
/**
* Represent the key class in a Map
* Only useful if the collection does not use generics
*/
Class targetElement() default void.class;
/**
* The optional map key type. Guessed if default
*/
Type type() default @Type(type = "");
}

View File

@ -1,51 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
* indicated by the @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.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.persistence.JoinColumn;
/**
* Define the map key columns as an explicit column holding the map key
* This is completely different from {@link javax.persistence.MapKey} which use an existing column
* This annotation and {@link javax.persistence.MapKey} are mutually exclusive
*
* @deprecated Use {@link javax.persistence.MapKeyJoinColumn} {@link javax.persistence.MapKeyJoinColumns}
* This is the default behavior for Map properties marked as @OneToMany, @ManyToMany
* or @ElementCollection
* @author Emmanuel Bernard
*/
@Target({ElementType.METHOD, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@Deprecated
public @interface MapKeyManyToMany {
JoinColumn[] joinColumns() default {};
/**
* Represent the key class in a Map
* Only useful if the collection does not use generics
*/
Class targetEntity() default void.class;
}

View File

@ -93,7 +93,6 @@ import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.Check;
import org.hibernate.annotations.CollectionId;
import org.hibernate.annotations.CollectionOfElements;
import org.hibernate.annotations.Columns;
import org.hibernate.annotations.DiscriminatorOptions;
import org.hibernate.annotations.Fetch;
@ -103,7 +102,6 @@ import org.hibernate.annotations.Filter;
import org.hibernate.annotations.FilterDef;
import org.hibernate.annotations.FilterDefs;
import org.hibernate.annotations.Filters;
import org.hibernate.annotations.ForceDiscriminator;
import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.Formula;
import org.hibernate.annotations.GenericGenerator;
@ -737,11 +735,6 @@ public final class AnnotationBinder {
null;
entityBinder.setDiscriminatorValue( discrimValue );
if ( clazzToProcess.isAnnotationPresent( ForceDiscriminator.class ) ) {
LOG.deprecatedForceDescriminatorAnnotation();
entityBinder.setForceDiscriminator( true );
}
DiscriminatorOptions discriminatorOptions = clazzToProcess.getAnnotation( DiscriminatorOptions.class );
if ( discriminatorOptions != null) {
entityBinder.setForceDiscriminator( discriminatorOptions.force() );
@ -1651,13 +1644,11 @@ public final class AnnotationBinder {
}
else if ( property.isAnnotationPresent( OneToMany.class )
|| property.isAnnotationPresent( ManyToMany.class )
|| property.isAnnotationPresent( CollectionOfElements.class ) //legacy Hibernate
|| property.isAnnotationPresent( ElementCollection.class )
|| property.isAnnotationPresent( ManyToAny.class ) ) {
OneToMany oneToManyAnn = property.getAnnotation( OneToMany.class );
ManyToMany manyToManyAnn = property.getAnnotation( ManyToMany.class );
ElementCollection elementCollectionAnn = property.getAnnotation( ElementCollection.class );
CollectionOfElements collectionOfElementsAnn = property.getAnnotation( CollectionOfElements.class ); //legacy hibernate
final IndexColumn indexColumn;
@ -1684,9 +1675,7 @@ public final class AnnotationBinder {
propertyHolder.getEntityName(),
property,
!indexColumn.isImplicit(),
property.isAnnotationPresent( CollectionOfElements.class )
|| property.isAnnotationPresent( org.hibernate.annotations.MapKey.class )
|| property.isAnnotationPresent( MapKeyType.class )
property.isAnnotationPresent( MapKeyType.class )
// || property.isAnnotationPresent( ManyToAny.class )
);
@ -1759,12 +1748,6 @@ public final class AnnotationBinder {
isJPA2 = Boolean.TRUE;
keyColumns = new Column[] { new MapKeyColumnDelegator( property.getAnnotation( MapKeyColumn.class ) ) };
}
else if ( property.isAnnotationPresent( org.hibernate.annotations.MapKey.class ) ) {
if ( isJPA2 == null ) {
isJPA2 = Boolean.FALSE;
}
keyColumns = property.getAnnotation( org.hibernate.annotations.MapKey.class ).columns();
}
//not explicitly legacy
if ( isJPA2 == null ) {
@ -1819,14 +1802,6 @@ public final class AnnotationBinder {
)
};
}
else if ( property.isAnnotationPresent( org.hibernate.annotations.MapKeyManyToMany.class ) ) {
if ( isJPA2 == null ) {
isJPA2 = Boolean.FALSE;
}
joinKeyColumns = property.getAnnotation( org.hibernate.annotations.MapKeyManyToMany.class )
.joinColumns();
}
//not explicitly legacy
if ( isJPA2 == null ) {
isJPA2 = Boolean.TRUE;
@ -1876,9 +1851,7 @@ public final class AnnotationBinder {
);
collectionBinder.setOneToMany( true );
}
else if ( elementCollectionAnn != null
|| collectionOfElementsAnn != null //Hibernate legacy
) {
else if ( elementCollectionAnn != null ) {
for ( Ejb3JoinColumn column : joinColumns ) {
if ( column.isSecondary() ) {
throw new NotYetImplementedException( "Collections having FK in secondary table" );
@ -1886,9 +1859,7 @@ public final class AnnotationBinder {
}
collectionBinder.setFkJoinColumns( joinColumns );
mappedBy = "";
final Class<?> targetElement = elementCollectionAnn != null ?
elementCollectionAnn.targetClass() :
collectionOfElementsAnn.targetElement();
final Class<?> targetElement = elementCollectionAnn.targetClass();
collectionBinder.setTargetEntity(
mappings.getReflectionManager().toXClass( targetElement )
);

View File

@ -32,7 +32,6 @@ import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import org.hibernate.AnnotationException;
import org.hibernate.annotations.CollectionOfElements;
import org.hibernate.annotations.Columns;
import org.hibernate.annotations.Formula;
import org.hibernate.annotations.JoinColumnsOrFormulas;
@ -112,7 +111,6 @@ class ColumnsBuilder {
}
else if ( joinColumns == null &&
( property.isAnnotationPresent( OneToMany.class )
|| property.isAnnotationPresent( CollectionOfElements.class ) //legacy Hibernate
|| property.isAnnotationPresent( ElementCollection.class )
) ) {
OneToMany oneToMany = property.getAnnotation( OneToMany.class );

View File

@ -49,7 +49,6 @@ import org.hibernate.MappingException;
import org.hibernate.annotations.BatchSize;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CollectionId;
import org.hibernate.annotations.CollectionOfElements;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.Filter;
import org.hibernate.annotations.FilterJoinTable;
@ -376,8 +375,7 @@ public abstract class CollectionBinder {
collection.setRole(role);
collection.setNodeName( propertyName );
if ( (property.isAnnotationPresent( org.hibernate.annotations.MapKey.class )
|| property.isAnnotationPresent( MapKeyColumn.class ) )
if ( property.isAnnotationPresent( MapKeyColumn.class )
&& mapKeyPropertyName != null ) {
throw new AnnotationException(
"Cannot mix @javax.persistence.MapKey and @MapKeyColumn or @org.hibernate.annotations.MapKey "
@ -505,7 +503,6 @@ public abstract class CollectionBinder {
tableBinder, mappings
);
if ( collectionType.isAnnotationPresent( Embeddable.class )
|| property.isAnnotationPresent( CollectionOfElements.class ) //legacy hibernate
|| property.isAnnotationPresent( ElementCollection.class ) //JPA 2
) {
// do it right away, otherwise @ManyToOne on composite element call addSecondPass
@ -542,7 +539,6 @@ public abstract class CollectionBinder {
Fetch fetch = property.getAnnotation( Fetch.class );
OneToMany oneToMany = property.getAnnotation( OneToMany.class );
ManyToMany manyToMany = property.getAnnotation( ManyToMany.class );
CollectionOfElements collectionOfElements = property.getAnnotation( CollectionOfElements.class ); //legacy hibernate
ElementCollection elementCollection = property.getAnnotation( ElementCollection.class ); //jpa 2
ManyToAny manyToAny = property.getAnnotation( ManyToAny.class );
FetchType fetchType;
@ -555,9 +551,6 @@ public abstract class CollectionBinder {
else if ( elementCollection != null ) {
fetchType = elementCollection.fetch();
}
else if ( collectionOfElements != null ) {
fetchType = collectionOfElements.fetch();
}
else if ( manyToAny != null ) {
fetchType = FetchType.LAZY;
}

View File

@ -33,8 +33,6 @@ import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure;
import org.hibernate.FetchMode;
import org.hibernate.MappingException;
import org.hibernate.annotations.MapKey;
import org.hibernate.annotations.MapKeyManyToMany;
import org.hibernate.annotations.MapKeyType;
import org.hibernate.annotations.common.reflection.XClass;
import org.hibernate.annotations.common.reflection.XProperty;
@ -159,12 +157,6 @@ public class MapBinder extends CollectionBinder {
if ( property.isAnnotationPresent( MapKeyClass.class ) ) {
target = property.getAnnotation( MapKeyClass.class ).value();
}
else if ( property.isAnnotationPresent( org.hibernate.annotations.MapKey.class ) ) {
target = property.getAnnotation( org.hibernate.annotations.MapKey.class ).targetElement();
}
else if ( property.isAnnotationPresent( MapKeyManyToMany.class ) ) {
target = property.getAnnotation( MapKeyManyToMany.class ).targetEntity();
}
if ( !void.class.equals( target ) ) {
mapKeyType = target.getName();
}
@ -281,19 +273,16 @@ public class MapBinder extends CollectionBinder {
elementBinder.setColumns( elementColumns );
//do not call setType as it extract the type from @Type
//the algorithm generally does not apply for map key anyway
MapKey mapKeyAnn = property.getAnnotation( org.hibernate.annotations.MapKey.class );
elementBinder.setKey(true);
if (mapKeyAnn != null && ! BinderHelper.isEmptyAnnotationValue( mapKeyAnn.type().type() ) ) {
elementBinder.setExplicitType( mapKeyAnn.type() );
MapKeyType mapKeyTypeAnnotation = property.getAnnotation( MapKeyType.class );
if ( mapKeyTypeAnnotation != null && !BinderHelper.isEmptyAnnotationValue(
mapKeyTypeAnnotation.value()
.type()
) ) {
elementBinder.setExplicitType( mapKeyTypeAnnotation.value() );
}
else {
MapKeyType mapKeyTypeAnnotation = property.getAnnotation( MapKeyType.class );
if ( mapKeyTypeAnnotation != null && ! BinderHelper.isEmptyAnnotationValue( mapKeyTypeAnnotation.value().type() ) ) {
elementBinder.setExplicitType( mapKeyTypeAnnotation.value() );
}
else {
elementBinder.setType( property, elementClass );
}
elementBinder.setType( property, elementClass );
}
mapValue.setIndex( elementBinder.make() );
}

View File

@ -120,7 +120,6 @@ import org.dom4j.Element;
import org.hibernate.AnnotationException;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CollectionOfElements;
import org.hibernate.annotations.Columns;
import org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor;
import org.hibernate.annotations.common.annotationfactory.AnnotationFactory;
@ -590,7 +589,6 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
defaultToJoinTable = defaultToJoinTable &&
( ( annotationClass == ManyToMany.class && StringHelper.isEmpty( ( (ManyToMany) annotation ).mappedBy() ) )
|| ( annotationClass == OneToMany.class && StringHelper.isEmpty( ( (OneToMany) annotation ).mappedBy() ) )
|| ( annotationClass == CollectionOfElements.class ) //legacy Hibernate
|| ( annotationClass == ElementCollection.class )
);
final Class<JoinTable> annotationType = JoinTable.class;
@ -794,40 +792,6 @@ public class JPAOverridenAnnotationReader implements AnnotationReader {
annotation = getJavaAnnotation( CollectionTable.class );
addIfNotNull( annotationList, annotation );
}
else if ( isJavaAnnotationPresent( CollectionOfElements.class ) ) { //legacy Hibernate
annotation = overridesDefaultsInJoinTable( getJavaAnnotation( CollectionOfElements.class ), defaults );
addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( JoinColumn.class );
addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( JoinColumns.class );
addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( PrimaryKeyJoinColumn.class );
addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( PrimaryKeyJoinColumns.class );
addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( MapKey.class );
addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( OrderBy.class );
addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( AttributeOverride.class );
addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( AttributeOverrides.class );
addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( AssociationOverride.class );
addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( AssociationOverrides.class );
addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( Lob.class );
addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( Enumerated.class );
addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( Temporal.class );
addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( Column.class );
addIfNotNull( annotationList, annotation );
annotation = getJavaAnnotation( Columns.class );
addIfNotNull( annotationList, annotation );
}
}
}

View File

@ -7,11 +7,11 @@ import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.MapKeyColumn;
import javax.persistence.Table;
import org.hibernate.annotations.AnyMetaDef;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.ManyToAny;
import org.hibernate.annotations.MapKey;
import org.hibernate.annotations.MetaValue;
@Entity
@ -59,7 +59,7 @@ public class PropertyMap {
name = "map_properties",
joinColumns = @JoinColumn( name = "map_id" ),
inverseJoinColumns = @JoinColumn( name = "property_id" ) )
@MapKey( columns = { @Column( name = "map_key", nullable = false ) } ) //keep for legacy test
@MapKeyColumn( name = "map_key", nullable = false ) //keep for legacy test
public Map<String, Property> getProperties() {
return properties;
}

View File

@ -19,7 +19,6 @@ import javax.persistence.JoinColumn;
import javax.persistence.MapKeyColumn;
import javax.persistence.OrderColumn;
import javax.persistence.Table;
import org.hibernate.annotations.CollectionOfElements;
/**
* @author Emmanuel Bernard
@ -72,7 +71,7 @@ public class Boy {
this.lastName = lastName;
}
@CollectionOfElements //keep hibernate legacy for test purposes
@ElementCollection
public Set<String> getNickNames() {
return nickNames;
}
@ -136,8 +135,7 @@ public class Boy {
public void setFavoriteNumbers(int[] favoriteNumbers) {
this.favoriteNumbers = favoriteNumbers;
}
@CollectionOfElements //TODO migration to ElementCollection "element.serial"??
@ElementCollection
@AttributeOverride(name = "element.serial", column = @Column(name = "serial_nbr"))
public Set<Toy> getFavoriteToys() {
return favoriteToys;

View File

@ -252,7 +252,7 @@ public class CollectionElementTest extends BaseCoreFunctionalTestCase {
public void testDefaultValueColumnForBasic() throws Exception {
isDefaultValueCollectionColumnPresent( Boy.class.getName(), "hatedNames" );
isDefaultValueCollectionColumnPresent( Boy.class.getName(), "preferredNames" );
isCollectionColumnPresent( Boy.class.getName(), "nickNames", "element" );
isCollectionColumnPresent( Boy.class.getName(), "nickNames", "nickNames" );
isDefaultValueCollectionColumnPresent( Boy.class.getName(), "scorePerPreferredName");
}

View File

@ -3,13 +3,13 @@ package org.hibernate.test.annotations.collectionelement.indexedCollection;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import org.hibernate.annotations.CollectionId;
import org.hibernate.annotations.CollectionOfElements;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;
@ -20,8 +20,7 @@ import org.hibernate.annotations.Type;
@GenericGenerator(name="increment", strategy = "increment")
public class Sale {
@Id @GeneratedValue private Integer id;
@CollectionOfElements //TODO migrate to @ElementCollection, what about @CollectionId
@ElementCollection
@JoinTable(
name = "contact",
joinColumns = @JoinColumn(name = "n_key_person"))

View File

@ -409,7 +409,7 @@ public class EmbeddedTest extends BaseCoreFunctionalTestCase {
public void testDefaultCollectionTable() throws Exception {
//are the tables correct?
assertTrue( SchemaUtil.isTablePresent("WealthyPerson_vacationHomes", configuration() ) );
assertTrue( SchemaUtil.isTablePresent("PersonEmbed_legacyVacationHomes", configuration() ) );
assertTrue( SchemaUtil.isTablePresent("WealthyPerson_legacyVacationHomes", configuration() ) );
assertTrue( SchemaUtil.isTablePresent("WelPers_VacHomes", configuration() ) );
//just to make sure, use the mapping

View File

@ -4,27 +4,17 @@ import java.util.Set;
import javax.persistence.CollectionTable;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import org.hibernate.annotations.CollectionOfElements;
@Entity
public class WealthyPerson extends Person {
@ElementCollection
// @CollectionTable(name="XXXHOMES")
// @AttributeOverrides({
// @AttributeOverride(name="address1",
// column=@Column(name="HOME_STREET")),
// @AttributeOverride(name="city",
// column=@Column(name="HOME_CITY")),
// @AttributeOverride(name="country",
// column=@Column(name="HOME_COUNTRY"))
// })
protected Set<Address> vacationHomes = new HashSet<Address>();
@CollectionOfElements
@ElementCollection
protected Set<Address> legacyVacationHomes = new HashSet<Address>();
@CollectionOfElements
@ElementCollection
@CollectionTable(name = "WelPers_VacHomes")
protected Set<Address> explicitVacationHomes = new HashSet<Address>();
}

View File

@ -19,8 +19,6 @@ import javax.persistence.MapKeyJoinColumn;
import javax.persistence.MapKeyJoinColumns;
import javax.persistence.MapKeyTemporal;
import javax.persistence.TemporalType;
import org.hibernate.annotations.CollectionOfElements;
import org.hibernate.annotations.MapKey;
/**
* @author Emmanuel Bernard
@ -56,7 +54,7 @@ public class Atmosphere {
@JoinTable(name = "Gas_per_key")
public Map<GasKey, Gas> gasesPerKey = new HashMap<GasKey, Gas>();
@CollectionOfElements //TODO migrate to @ElementCollection ; @MapKeyManyToMany ??
@ElementCollection
@Column(name="composition_rate")
@MapKeyJoinColumns( { @MapKeyJoinColumn(name="gas_id" ) } ) //use @MapKeyJoinColumns explicitly for tests
@JoinTable(name = "Composition", joinColumns = @JoinColumn(name = "atmosphere_id"))
@ -70,7 +68,7 @@ public class Atmosphere {
//use default HAN legacy column name for map key
@ManyToMany(cascade = CascadeType.ALL)
@MapKey
@MapKeyColumn
@JoinTable(name="Atm_Gas_DefLeg")
public Map<String, Gas> gasesDefLeg = new HashMap<String, Gas>();

View File

@ -33,6 +33,7 @@ import java.util.Map;
import org.hibernate.Hibernate;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.dialect.H2Dialect;
import org.hibernate.dialect.HSQLDialect;
import org.hibernate.mapping.Collection;
import org.hibernate.mapping.Column;
@ -58,7 +59,7 @@ public class IndexedCollectionTest extends BaseCoreFunctionalTestCase {
public void testJPA2DefaultMapColumns() throws Exception {
isDefaultKeyColumnPresent( Atmosphere.class.getName(), "gasesDef", "_KEY" );
isDefaultKeyColumnPresent( Atmosphere.class.getName(), "gasesPerKeyDef", "_KEY" );
isNotDefaultKeyColumnPresent( Atmosphere.class.getName(), "gasesDefLeg", "_KEY" );
isDefaultKeyColumnPresent( Atmosphere.class.getName(), "gasesDefLeg", "_KEY" );
}
@Test
@ -330,7 +331,7 @@ public class IndexedCollectionTest extends BaseCoreFunctionalTestCase {
}
@Test
@RequiresDialect(HSQLDialect.class)
@RequiresDialect({HSQLDialect.class, H2Dialect.class})
public void testComponentSubPropertyMapKey() throws Exception {
Session s;
Transaction tx;

View File

@ -6,14 +6,12 @@ import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import org.hibernate.annotations.ForceDiscriminator;
/**
* @author Emmanuel Bernard
*/
@Entity
@DiscriminatorColumn(name = "discriminator_disc")
@ForceDiscriminator
@DiscriminatorValue("B")
public class Building {
@Id

View File

@ -9,7 +9,6 @@ import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import org.hibernate.annotations.CollectionOfElements;
/**
* @author Emmanuel Bernard
@ -29,12 +28,11 @@ public class PropertyRecord {
public Map<Address, PropertyInfo> parcels;
@AttributeOverrides({
@AttributeOverride(name = "index.street", column = @Column(name = "STREET_NAME")),
@AttributeOverride(name = "element.size", column = @Column(name = "SQUARE_FEET")),
@AttributeOverride(name = "element.tax", column = @Column(name = "ASSESSMENT"))
@AttributeOverride(name = "key.street", column = @Column(name = "STREET_NAME")),
@AttributeOverride(name = "value.size", column = @Column(name = "SQUARE_FEET")),
@AttributeOverride(name = "value.tax", column = @Column(name = "ASSESSMENT"))
})
@CollectionOfElements
//@MapKey
@ElementCollection
@CollectionTable(name="LegacyParcels")
public Map<Address, PropertyInfo> legacyParcels;
@ -46,9 +44,9 @@ public class PropertyRecord {
public Set<PropertyInfo> unsortedParcels;
@AttributeOverrides({
@AttributeOverride(name = "element.size", column = @Column(name = "SQUARE_FEET")),
@AttributeOverride(name = "element.tax", column = @Column(name = "ASSESSMENT"))
@AttributeOverride(name = "size", column = @Column(name = "SQUARE_FEET")),
@AttributeOverride(name = "tax", column = @Column(name = "ASSESSMENT"))
})
@CollectionOfElements
@ElementCollection
public Set<PropertyInfo> legacyUnsortedParcels;
}

View File

@ -30,7 +30,7 @@ import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.MapKeyClass;
import org.hibernate.annotations.MapKeyManyToMany;
import javax.persistence.MapKeyJoinColumn;
/**
* @author Emmanuel Bernard
@ -47,7 +47,7 @@ public class Brand {
@ElementCollection(targetClass = SizeImpl.class)
@MapKeyClass(LuggageImpl.class)
@MapKeyManyToMany //legacy column name: was never officially supported BTW
@MapKeyJoinColumn
private Map<Luggage, Size> sizePerLuggage = new HashMap<Luggage, Size>();

View File

@ -24,12 +24,12 @@
package org.hibernate.envers.test.entities.collection;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import org.hibernate.annotations.CollectionOfElements;
import org.hibernate.envers.Audited;
/**
@ -45,12 +45,12 @@ public class EnumSetEntity {
private Integer id;
@Audited
@CollectionOfElements
@ElementCollection
@Enumerated(EnumType.STRING)
private Set<E1> enums1;
@Audited
@CollectionOfElements
@ElementCollection
@Enumerated(EnumType.ORDINAL)
private Set<E2> enums2;

View File

@ -24,10 +24,10 @@
package org.hibernate.envers.test.entities.collection;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import org.hibernate.annotations.CollectionOfElements;
import org.hibernate.annotations.IndexColumn;
import org.hibernate.envers.Audited;
@ -41,7 +41,7 @@ public class StringListEntity {
private Integer id;
@Audited
@CollectionOfElements
@ElementCollection
@IndexColumn(name = "list_index")
private List<String> strings;

View File

@ -24,10 +24,10 @@
package org.hibernate.envers.test.entities.collection;
import java.util.HashMap;
import java.util.Map;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import org.hibernate.annotations.CollectionOfElements;
import org.hibernate.envers.Audited;
/**
@ -40,7 +40,7 @@ public class StringMapEntity {
private Integer id;
@Audited
@CollectionOfElements
@ElementCollection
private Map<String, String> strings;
public StringMapEntity() {

View File

@ -24,10 +24,10 @@
package org.hibernate.envers.test.entities.collection;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import org.hibernate.annotations.CollectionOfElements;
import org.hibernate.envers.Audited;
/**
@ -40,7 +40,7 @@ public class StringSetEntity {
private Integer id;
@Audited
@CollectionOfElements
@ElementCollection
private Set<String> strings;
public StringSetEntity() {

View File

@ -2,11 +2,11 @@ package org.hibernate.envers.test.integration.hashcode;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Basic;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import org.hibernate.annotations.CollectionOfElements;
import org.hibernate.envers.Audited;
/**
@ -25,7 +25,7 @@ public class WikiPage {
@Basic
private String content;
@CollectionOfElements
@ElementCollection
private Set<String> links = new HashSet<String>();
@OneToMany

View File

@ -28,7 +28,6 @@ import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import org.hibernate.annotations.MapKeyManyToMany;
import org.hibernate.envers.Audited;
import org.hibernate.envers.test.entities.IntTestEntity;
import org.hibernate.envers.test.entities.StrTestEntity;
@ -44,7 +43,7 @@ public class TernaryMapEntity {
@Audited
@ManyToMany
@MapKeyManyToMany
@javax.persistence.MapKeyJoinColumn
private Map<IntTestEntity, StrTestEntity> map;
public TernaryMapEntity() {

View File

@ -9,7 +9,6 @@ import javax.persistence.MappedSuperclass;
* @author Erik-Berndt Scheper
*/
@MappedSuperclass
@org.hibernate.annotations.ForceDiscriminator
@org.hibernate.envers.Audited
public abstract class VersionsJoinTableRangeTestEntitySuperClass {

View File

@ -24,9 +24,9 @@
package org.hibernate.envers.test.performance.complex;
import java.util.Set;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.Id;
import org.hibernate.annotations.CollectionOfElements;
import org.hibernate.envers.Audited;
/**
@ -42,7 +42,7 @@ public class ChildEntity2 {
private Integer number;
@CollectionOfElements
@ElementCollection
private Set<String> strings;
public Long getId() {