From ff12d5cdf13e2d63fb80b88df488f5482c948fa7 Mon Sep 17 00:00:00 2001 From: Brett Meyer Date: Fri, 14 Feb 2014 11:20:55 -0500 Subject: [PATCH] HHH-8969 removed deprecated annotations --- .../org/hibernate/annotations/AccessType.java | 51 -------- .../hibernate/annotations/CascadeType.java | 14 --- .../org/hibernate/annotations/Entity.java | 86 -------------- .../hibernate/annotations/FlushModeType.java | 7 -- .../org/hibernate/annotations/ForeignKey.java | 54 --------- .../java/org/hibernate/annotations/Index.java | 52 -------- .../hibernate/annotations/IndexColumn.java | 64 ---------- .../java/org/hibernate/annotations/Sort.java | 57 --------- .../org/hibernate/annotations/SortType.java | 47 -------- .../java/org/hibernate/annotations/Table.java | 7 +- .../org/hibernate/annotations/Tuplizer.java | 15 +-- .../org/hibernate/cfg/AnnotationBinder.java | 85 ++------------ .../java/org/hibernate/cfg/Ejb3Column.java | 8 -- .../java/org/hibernate/cfg/IndexColumn.java | 36 +----- .../org/hibernate/cfg/OneToOneSecondPass.java | 4 - .../org/hibernate/cfg/PropertyContainer.java | 31 +---- .../hibernate/cfg/PropertyInferredData.java | 23 +--- .../cfg/annotations/CollectionBinder.java | 42 +------ .../cfg/annotations/EntityBinder.java | 111 ++---------------- .../hibernate/cfg/annotations/ListBinder.java | 8 -- .../cfg/annotations/QueryBinder.java | 5 +- .../cfg/annotations/TableBinder.java | 20 +--- .../BasicPluralAttributeIndexSourceImpl.java | 12 +- .../IndexedPluralAttributeSourceImpl.java | 6 +- ...uentialPluralAttributeIndexSourceImpl.java | 12 +- .../annotations/ToOneAttributeSourceImpl.java | 24 ++-- .../source/annotations/attribute/Column.java | 7 +- .../attribute/PluralAssociationAttribute.java | 63 ++-------- .../annotations/entity/ConfiguredClass.java | 13 +- .../annotations/entity/EntityClass.java | 20 +--- .../annotations/global/QueryProcessor.java | 3 - .../util/EnumConversionHelper.java | 4 +- .../annotations/util/HibernateDotNames.java | 13 +- .../annotations/util/JandexHelperTest.java | 43 ++----- .../EntityWithUnidirectionalOneToMany.java | 5 +- .../hibernate/test/annotations/Customer.java | 10 +- .../test/annotations/access/Bed.java | 4 +- .../test/annotations/access/Furniture.java | 6 +- .../test/annotations/access/Gardenshed.java | 6 +- .../test/annotations/access/Woody.java | 4 +- .../test/annotations/access/jpa/Course3.java | 5 +- .../test/annotations/access/xml/Boy.java | 4 +- .../test/annotations/backquotes/Bug.java | 7 +- .../cascade/CodedPairSetHolder.java | 9 +- .../test/annotations/cascade/PersonPair.java | 12 +- .../annotations/collectionelement/Matrix.java | 6 +- .../test/annotations/embedded/Country.java | 5 +- .../embedded/RegionalArticlePk.java | 5 +- .../embedded/many2one/Address.java | 4 +- .../annotations/embedded/one2many/Alias.java | 3 +- .../annotations/embedded/one2many/Name.java | 4 +- .../embedded/one2many/PersonName.java | 5 +- .../test/annotations/entity/Forest.java | 20 ++-- ...NewCustomEntityMappingAnnotationsTest.java | 10 +- .../test/annotations/entity/ZipCode.java | 3 +- .../test/annotations/indexcoll/Training.java | 6 +- .../inheritance/joined/Document.java | 3 - .../hibernate/test/annotations/join/Cat.java | 16 +-- .../test/annotations/manytomany/Woman.java | 23 ++-- .../test/annotations/manytoone/Car.java | 6 +- .../annotations/manytoone/ForestType.java | 11 +- .../test/annotations/onetomany/City.java | 7 +- .../test/annotations/onetomany/Trainer.java | 9 +- .../test/annotations/onetomany/Troop.java | 4 +- .../test/annotations/persister/Card.java | 5 +- .../test/annotations/persister/Deck.java | 2 +- .../annotations/persister/PersisterTest.java | 8 +- .../test/annotations/polymorphism/Car.java | 3 +- .../polymorphism/PolymorphismTest.java | 2 - .../annotations/polymorphism/SportCar.java | 3 +- .../test/annotations/strategy/Storm.java | 9 +- .../annotations/tableperclass/Component.java | 6 +- .../test/annotations/various/Conductor.java | 5 +- .../test/annotations/various/Truck.java | 9 +- .../test/annotations/various/Vehicule.java | 18 ++- .../test/constraint/ConstraintTest.java | 68 +++++------ .../MultipleCollectionRefEntity1.java | 5 +- .../MultipleCollectionRefEntity2.java | 5 +- .../test/propertyref/DoesNotWork.java | 9 +- 79 files changed, 272 insertions(+), 1154 deletions(-) delete mode 100644 hibernate-core/src/main/java/org/hibernate/annotations/AccessType.java delete mode 100644 hibernate-core/src/main/java/org/hibernate/annotations/Entity.java delete mode 100644 hibernate-core/src/main/java/org/hibernate/annotations/ForeignKey.java delete mode 100644 hibernate-core/src/main/java/org/hibernate/annotations/Index.java delete mode 100644 hibernate-core/src/main/java/org/hibernate/annotations/IndexColumn.java delete mode 100644 hibernate-core/src/main/java/org/hibernate/annotations/Sort.java delete mode 100644 hibernate-core/src/main/java/org/hibernate/annotations/SortType.java diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/AccessType.java b/hibernate-core/src/main/java/org/hibernate/annotations/AccessType.java deleted file mode 100644 index 94c5eb032914..000000000000 --- a/hibernate-core/src/main/java/org/hibernate/annotations/AccessType.java +++ /dev/null @@ -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.Retention; -import java.lang.annotation.Target; - -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -/** - * Property Access type. Prefer the standard {@link javax.persistence.Access} annotation; however, - * {@code @Access} is limited to field/property access definitions. - * - * @author Emmanuel Bernard - * - * @deprecated Use {@link AttributeAccessor} instead; renamed to avoid confusion with the JPA - * {@link javax.persistence.AccessType} enum. - */ -@Target({ TYPE, METHOD, FIELD }) -@Retention(RUNTIME) -@Deprecated -public @interface AccessType { - /** - * The access strategy name. - */ - String value(); -} diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/CascadeType.java b/hibernate-core/src/main/java/org/hibernate/annotations/CascadeType.java index 96ad7ec1f7be..15933ff957fd 100644 --- a/hibernate-core/src/main/java/org/hibernate/annotations/CascadeType.java +++ b/hibernate-core/src/main/java/org/hibernate/annotations/CascadeType.java @@ -59,24 +59,10 @@ public enum CascadeType { * Corresponds to the Hibernate native REPLICATE action. */ REPLICATE, - /** - * Hibernate originally handled orphan removal as a specialized cascade. - * - * @deprecated use @OneToOne(orphanRemoval=true) or @OneToMany(orphanRemoval=true) - */ - @Deprecated - DELETE_ORPHAN, /** * Corresponds to the Hibernate native LOCK action. */ LOCK, - /** - * JPA originally planned on calling DETACH EVICT. - * - * @deprecated use javax.persistence.CascadeType.DETACH - */ - @Deprecated - EVICT, /** * Corresponds to {@link javax.persistence.CascadeType#REFRESH}. */ diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/Entity.java b/hibernate-core/src/main/java/org/hibernate/annotations/Entity.java deleted file mode 100644 index 00527d5092b1..000000000000 --- a/hibernate-core/src/main/java/org/hibernate/annotations/Entity.java +++ /dev/null @@ -1,86 +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.Retention; -import java.lang.annotation.Target; - -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -/** - * Extends {@link javax.persistence.Entity} with Hibernate features. - * - * @author Emmanuel Bernard - * - * @deprecated See individual attributes for intended replacements. To be removed in 4.1 - */ -@Target(TYPE) -@Retention(RUNTIME) -@Deprecated -public @interface Entity { - /** - * Is this entity mutable (read only) or not. - * - * @deprecated use {@link org.hibernate.annotations.Immutable} - */ - @Deprecated - boolean mutable() default true; - /** - * Needed column only in SQL on insert. - * @deprecated use {@link DynamicInsert} instead - */ - @Deprecated - boolean dynamicInsert() default false; - /** - * Needed column only in SQL on update. - * @deprecated Use {@link DynamicUpdate} instead - */ - @Deprecated - boolean dynamicUpdate() default false; - /** - * Do a select to retrieve the entity before any potential update. - * @deprecated Use {@link SelectBeforeUpdate} instead - */ - @Deprecated - boolean selectBeforeUpdate() default false; - /** - * polymorphism strategy for this entity. - * @deprecated use {@link Polymorphism} instead - */ - @Deprecated - PolymorphismType polymorphism() default PolymorphismType.IMPLICIT; - /** - * optimistic locking strategy. - * @deprecated use {@link OptimisticLocking} instead. - */ - @Deprecated - OptimisticLockType optimisticLock() default OptimisticLockType.VERSION; - /** - * persister of this entity, default is hibernate internal one. - * @deprecated use {@link Persister} instead - */ - @Deprecated - String persister() default ""; -} diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/FlushModeType.java b/hibernate-core/src/main/java/org/hibernate/annotations/FlushModeType.java index 69bc487d83e3..8b942af119a2 100644 --- a/hibernate-core/src/main/java/org/hibernate/annotations/FlushModeType.java +++ b/hibernate-core/src/main/java/org/hibernate/annotations/FlushModeType.java @@ -41,13 +41,6 @@ public enum FlushModeType { * Corresponds to {@link org.hibernate.FlushMode#COMMIT}. */ COMMIT, - /** - * Corresponds to {@link org.hibernate.FlushMode#NEVER}. - * - * @deprecated use MANUAL, will be removed in a subsequent release - */ - @Deprecated - NEVER, /** * Corresponds to {@link org.hibernate.FlushMode#MANUAL}. */ diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/ForeignKey.java b/hibernate-core/src/main/java/org/hibernate/annotations/ForeignKey.java deleted file mode 100644 index c1963ec1626b..000000000000 --- a/hibernate-core/src/main/java/org/hibernate/annotations/ForeignKey.java +++ /dev/null @@ -1,54 +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.Retention; -import java.lang.annotation.Target; - -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -/** - * Define the foreign key name. - * - * @deprecated Prefer the JPA 2.1 introduced {@link javax.persistence.ForeignKey} instead. - */ -@Target({FIELD, METHOD, TYPE}) -@Retention(RUNTIME) -@Deprecated -public @interface ForeignKey { - /** - * Name of the foreign key. Used in OneToMany, ManyToOne, and OneToOne - * relationships. Used for the owning side in ManyToMany relationships - */ - String name(); - - /** - * Used for the non-owning side of a ManyToMany relationship. Ignored - * in other relationships - */ - String inverseName() default ""; -} diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/Index.java b/hibernate-core/src/main/java/org/hibernate/annotations/Index.java deleted file mode 100644 index 5b6a9ea0db79..000000000000 --- a/hibernate-core/src/main/java/org/hibernate/annotations/Index.java +++ /dev/null @@ -1,52 +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.Retention; -import java.lang.annotation.Target; - -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -/** - * Define a DB index. - * - * @author Emmanuel Bernard - * - * @deprecated Using {@link javax.persistence.Index} instead. - */ -@Target({FIELD, METHOD}) -@Retention(RUNTIME) -@Deprecated -public @interface Index { - /** - * The index name. - */ - String name(); - - /** - * The column(s) that are indexed. - */ - String[] columnNames() default {}; -} diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/IndexColumn.java b/hibernate-core/src/main/java/org/hibernate/annotations/IndexColumn.java deleted file mode 100644 index 88c228ccc202..000000000000 --- a/hibernate-core/src/main/java/org/hibernate/annotations/IndexColumn.java +++ /dev/null @@ -1,64 +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.Retention; -import java.lang.annotation.Target; - -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -/** - * Describe an index column of a List. - * - * @author Matthew Inger - * - * @deprecated Prefer the standard JPA {@link javax.persistence.OrderColumn} annotation and the Hibernate specific - * {@link ListIndexBase} (for replacing {@link #base()}). - */ -@Target({METHOD, FIELD}) -@Retention(RUNTIME) -@Deprecated -public @interface IndexColumn { - /** - * The column name. - */ - String name(); - - /** - * The starting index value. Zero (0) by default, since Lists indexes start at zero (0). - */ - int base() default 0; - - /** - * Is the column nullable? - */ - boolean nullable() default true; - - /** - * An explicit column definition. - */ - String columnDefinition() default ""; -} diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/Sort.java b/hibernate-core/src/main/java/org/hibernate/annotations/Sort.java deleted file mode 100644 index 3dd90115e68f..000000000000 --- a/hibernate-core/src/main/java/org/hibernate/annotations/Sort.java +++ /dev/null @@ -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 java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -/** - * Collection sort (in-memory sorting). Different that ordering, which is applied during the SQL select. - * - * @author Emmanuel Bernard - * - * @see OrderBy - * - * @deprecated Use {@link SortComparator} or {@link SortNatural} instead depending on need. - */ -@Target({METHOD, FIELD}) -@Retention(RUNTIME) -@Deprecated -public @interface Sort { - /** - * The type of sorting to use. The default is to not use sorting. - */ - SortType type() default SortType.UNSORTED; - - /** - * Specifies the comparator to use. Only valid when {@link #type} specifies {@link SortType#COMPARATOR}. - * - * TODO find a way to use Class -> see HHH-8164 - */ - Class comparator() default void.class; -} diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/SortType.java b/hibernate-core/src/main/java/org/hibernate/annotations/SortType.java deleted file mode 100644 index b8f0ea4baa01..000000000000 --- a/hibernate-core/src/main/java/org/hibernate/annotations/SortType.java +++ /dev/null @@ -1,47 +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; - -/** - * Possible collection sorting strategies. - * - * @author Emmanuel Bernard - * - * @deprecated Since {@link Sort} is deprecated. - */ -@Deprecated -public enum SortType { - /** - * The collection is unsorted. - */ - UNSORTED, - /** - * The collection is sorted using its natural sorting. - */ - NATURAL, - /** - * The collection is sorted using a supplied comparator. - */ - COMPARATOR -} diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/Table.java b/hibernate-core/src/main/java/org/hibernate/annotations/Table.java index 43338e0dc181..48d1c2f4e3fc 100644 --- a/hibernate-core/src/main/java/org/hibernate/annotations/Table.java +++ b/hibernate-core/src/main/java/org/hibernate/annotations/Table.java @@ -23,11 +23,14 @@ */ package org.hibernate.annotations; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + import java.lang.annotation.Retention; import java.lang.annotation.Target; -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; +import javax.persistence.ForeignKey; +import javax.persistence.Index; /** * Complementary information to a table either primary or secondary. diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/Tuplizer.java b/hibernate-core/src/main/java/org/hibernate/annotations/Tuplizer.java index c692a36455f3..377259fdb7fc 100644 --- a/hibernate-core/src/main/java/org/hibernate/annotations/Tuplizer.java +++ b/hibernate-core/src/main/java/org/hibernate/annotations/Tuplizer.java @@ -23,15 +23,15 @@ */ package org.hibernate.annotations; -import java.lang.annotation.Retention; - -import org.hibernate.EntityMode; - import static java.lang.annotation.ElementType.FIELD; import static java.lang.annotation.ElementType.METHOD; import static java.lang.annotation.ElementType.TYPE; import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Retention; + +import org.hibernate.EntityMode; + /** * Define a tuplizer for an entity or a component. * @@ -45,13 +45,6 @@ */ Class impl(); - /** - * either pojo, dynamic-map or dom4j. - * @deprecated should use #entityModeType instead - */ - @Deprecated - String entityMode() default "pojo"; - /** * The entity mode. */ diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java b/hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java index 45eaa636356b..e08033cee622 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/AnnotationBinder.java @@ -87,7 +87,6 @@ import org.hibernate.AnnotationException; import org.hibernate.AssertionFailure; -import org.hibernate.EntityMode; import org.hibernate.FetchMode; import org.hibernate.MappingException; import org.hibernate.annotations.BatchSize; @@ -107,11 +106,9 @@ import org.hibernate.annotations.FilterDef; import org.hibernate.annotations.FilterDefs; import org.hibernate.annotations.Filters; -import org.hibernate.annotations.ForeignKey; import org.hibernate.annotations.Formula; import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerators; -import org.hibernate.annotations.Index; import org.hibernate.annotations.LazyToOne; import org.hibernate.annotations.LazyToOneOption; import org.hibernate.annotations.ListIndexBase; @@ -128,7 +125,6 @@ import org.hibernate.annotations.Parameter; import org.hibernate.annotations.Parent; import org.hibernate.annotations.Proxy; -import org.hibernate.annotations.Sort; import org.hibernate.annotations.SortComparator; import org.hibernate.annotations.SortNatural; import org.hibernate.annotations.Source; @@ -607,11 +603,8 @@ public static void bindClass( PersistentClass persistentClass = makePersistentClass( inheritanceState, superEntity ); Entity entityAnn = clazzToProcess.getAnnotation( Entity.class ); - org.hibernate.annotations.Entity hibEntityAnn = clazzToProcess.getAnnotation( - org.hibernate.annotations.Entity.class - ); EntityBinder entityBinder = new EntityBinder( - entityAnn, hibEntityAnn, clazzToProcess, persistentClass, mappings + entityAnn, clazzToProcess, persistentClass, mappings ); entityBinder.setInheritanceState( inheritanceState ); @@ -713,10 +706,6 @@ else if ( clazzToProcess.isAnnotationPresent( Table.class ) ) { final JoinedSubclass jsc = ( JoinedSubclass ) persistentClass; SimpleValue key = new DependantValue( mappings, jsc.getTable(), jsc.getIdentifier() ); jsc.setKey( key ); - ForeignKey fk = clazzToProcess.getAnnotation( ForeignKey.class ); - if ( fk != null && !BinderHelper.isEmptyAnnotationValue( fk.name() ) ) { - key.setForeignKeyName( fk.name() ); - } if ( onDeleteAnn != null ) { key.setCascadeDeleteEnabled( OnDeleteAction.CASCADE.equals( onDeleteAnn.action() ) ); } @@ -1359,10 +1348,6 @@ private static boolean isEntityClassType(XClass clazzToProcess, AnnotatedClassTy || AnnotatedClassType.NONE.equals( classType ) //to be ignored || AnnotatedClassType.EMBEDDABLE.equals( classType ) //allow embeddable element declaration ) { - if ( AnnotatedClassType.NONE.equals( classType ) - && clazzToProcess.isAnnotationPresent( org.hibernate.annotations.Entity.class ) ) { - LOG.missingEntityAnnotation( clazzToProcess.getName() ); - } return false; } @@ -1892,29 +1877,15 @@ else if ( property.isAnnotationPresent( OneToMany.class ) ManyToMany manyToManyAnn = property.getAnnotation( ManyToMany.class ); ElementCollection elementCollectionAnn = property.getAnnotation( ElementCollection.class ); - final IndexColumn indexColumn; - - if ( property.isAnnotationPresent( OrderColumn.class ) ) { - indexColumn = IndexColumn.buildColumnFromAnnotation( - property.getAnnotation( OrderColumn.class ), - propertyHolder, - inferredData, - entityBinder.getSecondaryTables(), - mappings - ); - if ( property.isAnnotationPresent( ListIndexBase.class ) ) { - indexColumn.setBase( ( property.getAnnotation( ListIndexBase.class ) ).value() ); - } - } - else { - //if @IndexColumn is not there, the generated IndexColumn is an implicit column and not used. - //so we can leave the legacy processing as the default - indexColumn = IndexColumn.buildColumnFromAnnotation( - property.getAnnotation( org.hibernate.annotations.IndexColumn.class ), - propertyHolder, - inferredData, - mappings - ); + final IndexColumn indexColumn = IndexColumn.buildColumnFromAnnotation( + property.getAnnotation( OrderColumn.class ), + propertyHolder, + inferredData, + entityBinder.getSecondaryTables(), + mappings + ); + if ( property.isAnnotationPresent( ListIndexBase.class ) ) { + indexColumn.setBase( ( property.getAnnotation( ListIndexBase.class ) ).value() ); } CollectionBinder collectionBinder = CollectionBinder.getCollectionBinder( propertyHolder.getEntityName(), @@ -1932,7 +1903,6 @@ else if ( property.isAnnotationPresent( OneToMany.class ) collectionBinder.setJpaOrderBy( property.getAnnotation( javax.persistence.OrderBy.class ) ); collectionBinder.setSqlOrderBy( property.getAnnotation( OrderBy.class ) ); - collectionBinder.setSort( property.getAnnotation( Sort.class ) ); collectionBinder.setNaturalSort( property.getAnnotation( SortNatural.class ) ); collectionBinder.setComparatorSort( property.getAnnotation( SortComparator.class ) ); @@ -2274,24 +2244,6 @@ else if ( !isId || !entityBinder.isIgnoreIdAnnotations() ) { } } } - //init index - //process indexes after everything: in second pass, many to one has to be done before indexes - Index index = property.getAnnotation( Index.class ); - if ( index != null ) { - if ( joinColumns != null ) { - - for ( Ejb3Column column : joinColumns ) { - column.addIndex( index, inSecondPass ); - } - } - else { - if ( columns != null ) { - for ( Ejb3Column column : columns ) { - column.addIndex( index, inSecondPass ); - } - } - } - } // Natural ID columns must reside in one single UniqueKey within the Table. // For now, simply ensure consistent naming. @@ -2795,16 +2747,12 @@ private static void setupComponentTuplizer(XProperty property, Component compone } if ( property.isAnnotationPresent( Tuplizers.class ) ) { for ( Tuplizer tuplizer : property.getAnnotation( Tuplizers.class ).value() ) { - EntityMode mode = EntityMode.parse( tuplizer.entityMode() ); - //todo tuplizer.entityModeType - component.addTuplizer( mode, tuplizer.impl().getName() ); + component.addTuplizer( tuplizer.entityModeType(), tuplizer.impl().getName() ); } } if ( property.isAnnotationPresent( Tuplizer.class ) ) { Tuplizer tuplizer = property.getAnnotation( Tuplizer.class ); - EntityMode mode = EntityMode.parse( tuplizer.entityMode() ); - //todo tuplizer.entityModeType - component.addTuplizer( mode, tuplizer.impl().getName() ); + component.addTuplizer( tuplizer.entityModeType(), tuplizer.impl().getName() ); } } @@ -2881,10 +2829,6 @@ private static void bindManyToOne( if ( joinColumn != null && joinColumn.foreignKey() != null ) { fkName = joinColumn.foreignKey().name(); } - if ( StringHelper.isEmpty( fkName ) ) { - ForeignKey fk = property.getAnnotation( ForeignKey.class ); - fkName = fk != null ? fk.name() : ""; - } if ( !StringHelper.isEmpty( fkName ) ) { value.setForeignKeyName( fkName ); } @@ -3164,7 +3108,6 @@ private static String getCascadeStrategy( } if ( orphanRemoval ) { - hibernateCascadeSet.add( CascadeType.DELETE_ORPHAN ); hibernateCascadeSet.add( CascadeType.REMOVE ); } if ( forcePersist ) { @@ -3195,16 +3138,12 @@ private static String getCascadeStrategy( case REPLICATE: cascade.append( "," ).append( "replicate" ); break; - case EVICT: case DETACH: cascade.append( "," ).append( "evict" ); break; case DELETE: cascade.append( "," ).append( "delete" ); break; - case DELETE_ORPHAN: - cascade.append( "," ).append( "delete-orphan" ); - break; case REMOVE: cascade.append( "," ).append( "delete" ); break; diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/Ejb3Column.java b/hibernate-core/src/main/java/org/hibernate/cfg/Ejb3Column.java index a70e1ccaa114..6bc72c6bad75 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/Ejb3Column.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/Ejb3Column.java @@ -30,7 +30,6 @@ import org.hibernate.annotations.ColumnDefault; import org.hibernate.annotations.ColumnTransformer; import org.hibernate.annotations.ColumnTransformers; -import org.hibernate.annotations.Index; import org.hibernate.annotations.common.reflection.XProperty; import org.hibernate.cfg.annotations.Nullability; import org.hibernate.internal.CoreMessageLogger; @@ -40,7 +39,6 @@ import org.hibernate.mapping.Join; import org.hibernate.mapping.SimpleValue; import org.hibernate.mapping.Table; - import org.jboss.logging.Logger; /** @@ -647,12 +645,6 @@ public static void checkPropertyConsistency(Ejb3Column[] columns, String propert } - public void addIndex(Index index, boolean inSecondPass) { - if ( index == null ) return; - String indexName = index.name(); - addIndex( indexName, inSecondPass ); - } - void addIndex(String indexName, boolean inSecondPass) { IndexOrUniqueKeySecondPass secondPass = new IndexOrUniqueKeySecondPass( indexName, this, mappings, false ); if ( inSecondPass ) { diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/IndexColumn.java b/hibernate-core/src/main/java/org/hibernate/cfg/IndexColumn.java index aaf82c375e92..a0fc14dc79ee 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/IndexColumn.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/IndexColumn.java @@ -23,6 +23,7 @@ */ package org.hibernate.cfg; import java.util.Map; + import javax.persistence.OrderColumn; import org.hibernate.mapping.Join; @@ -119,39 +120,4 @@ public static IndexColumn buildColumnFromAnnotation( } return column; } - - /** - * Legacy {@link IndexColumn @IndexColumn} processing. - * - * @param ann The IndexColumn annotation instance - * @param propertyHolder Information about the property - * @param inferredData Yeah, right. Uh... - * @param mappings The mappings being built. - * - * @return The index column - */ - public static IndexColumn buildColumnFromAnnotation( - org.hibernate.annotations.IndexColumn ann, - PropertyHolder propertyHolder, - PropertyData inferredData, - Mappings mappings) { - final IndexColumn column; - if ( ann != null ) { - final String sqlType = BinderHelper.isEmptyAnnotationValue( ann.columnDefinition() ) ? null : ann.columnDefinition(); - final String name = BinderHelper.isEmptyAnnotationValue( ann.name() ) ? inferredData.getPropertyName() : ann.name(); - //TODO move it to a getter based system and remove the constructor - column = new IndexColumn( - false, sqlType, 0, 0, 0, name, ann.nullable(), - false, true, true, null, null, propertyHolder, mappings - ); - column.setBase( ann.base() ); - } - else { - column = new IndexColumn( - true, null, 0, 0, 0, null, true, - false, true, true, null, null, propertyHolder, mappings - ); - } - return column; - } } diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/OneToOneSecondPass.java b/hibernate-core/src/main/java/org/hibernate/cfg/OneToOneSecondPass.java index 4df180aa333a..eb54f4d922d2 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/OneToOneSecondPass.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/OneToOneSecondPass.java @@ -28,7 +28,6 @@ import org.hibernate.AnnotationException; import org.hibernate.MappingException; -import org.hibernate.annotations.ForeignKey; import org.hibernate.annotations.common.reflection.XClass; import org.hibernate.cfg.annotations.PropertyBinder; import org.hibernate.internal.util.StringHelper; @@ -255,9 +254,6 @@ else if ( otherSideProperty.getValue() instanceof ManyToOne ) { ); } } - ForeignKey fk = inferredData.getProperty().getAnnotation( ForeignKey.class ); - String fkName = fk != null ? fk.name() : ""; - if ( !BinderHelper.isEmptyAnnotationValue( fkName ) ) value.setForeignKeyName( fkName ); } /** diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/PropertyContainer.java b/hibernate-core/src/main/java/org/hibernate/cfg/PropertyContainer.java index 66f39593187a..8e8a7027646b 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/PropertyContainer.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/PropertyContainer.java @@ -31,6 +31,7 @@ import java.util.List; import java.util.Map; import java.util.TreeMap; + import javax.persistence.Access; import javax.persistence.ManyToMany; import javax.persistence.ManyToOne; @@ -39,7 +40,6 @@ import javax.persistence.Transient; import org.hibernate.AnnotationException; -import org.hibernate.MappingException; import org.hibernate.annotations.ManyToAny; import org.hibernate.annotations.Target; import org.hibernate.annotations.Type; @@ -47,7 +47,6 @@ import org.hibernate.annotations.common.reflection.XProperty; import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.util.StringHelper; - import org.jboss.logging.Logger; /** @@ -207,35 +206,13 @@ private TreeMap initProperties(AccessType access) { } private AccessType determineClassDefinedAccessStrategy() { - AccessType classDefinedAccessType; - - AccessType hibernateDefinedAccessType = AccessType.DEFAULT; - AccessType jpaDefinedAccessType = AccessType.DEFAULT; - - org.hibernate.annotations.AccessType accessType = xClass.getAnnotation( org.hibernate.annotations.AccessType.class ); - if ( accessType != null ) { - hibernateDefinedAccessType = AccessType.getAccessStrategy( accessType.value() ); - } + AccessType classDefinedAccessType = null; Access access = xClass.getAnnotation( Access.class ); if ( access != null ) { - jpaDefinedAccessType = AccessType.getAccessStrategy( access.value() ); - } - - if ( hibernateDefinedAccessType != AccessType.DEFAULT - && jpaDefinedAccessType != AccessType.DEFAULT - && hibernateDefinedAccessType != jpaDefinedAccessType ) { - throw new MappingException( - "@AccessType and @Access specified with contradicting values. Use of @Access only is recommended. " - ); - } - - if ( hibernateDefinedAccessType != AccessType.DEFAULT ) { - classDefinedAccessType = hibernateDefinedAccessType; - } - else { - classDefinedAccessType = jpaDefinedAccessType; + classDefinedAccessType = AccessType.getAccessStrategy( access.value() ); } + return classDefinedAccessType; } diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/PropertyInferredData.java b/hibernate-core/src/main/java/org/hibernate/cfg/PropertyInferredData.java index b74a2dc3d928..63f151936dbb 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/PropertyInferredData.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/PropertyInferredData.java @@ -66,35 +66,14 @@ public PropertyInferredData(XClass declaringClass, XProperty property, String pr public AccessType getDefaultAccess() throws MappingException { AccessType accessType = defaultAccess; - AccessType hibernateAccessType = AccessType.DEFAULT; AccessType jpaAccessType = AccessType.DEFAULT; - org.hibernate.annotations.AccessType accessTypeAnnotation = property.getAnnotation( org.hibernate.annotations.AccessType.class ); - if ( accessTypeAnnotation != null ) { - hibernateAccessType = AccessType.getAccessStrategy( accessTypeAnnotation.value() ); - } - Access access = property.getAnnotation( Access.class ); if ( access != null ) { jpaAccessType = AccessType.getAccessStrategy( access.value() ); } - if ( hibernateAccessType != AccessType.DEFAULT - && jpaAccessType != AccessType.DEFAULT - && hibernateAccessType != jpaAccessType ) { - - StringBuilder builder = new StringBuilder(); - builder.append( property.toString() ); - builder.append( - " defines @AccessType and @Access with contradicting values. Use of @Access only is recommended." - ); - throw new MappingException( builder.toString() ); - } - - if ( hibernateAccessType != AccessType.DEFAULT ) { - accessType = hibernateAccessType; - } - else if ( jpaAccessType != AccessType.DEFAULT ) { + if ( jpaAccessType != AccessType.DEFAULT ) { accessType = jpaAccessType; } return accessType; diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java index c45a6fd30723..2b0b4fd19c54 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/CollectionBinder.java @@ -23,11 +23,15 @@ */ package org.hibernate.cfg.annotations; +import static org.hibernate.cfg.BinderHelper.toAliasEntityMap; +import static org.hibernate.cfg.BinderHelper.toAliasTableMap; + import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Properties; + import javax.persistence.AttributeOverride; import javax.persistence.AttributeOverrides; import javax.persistence.ElementCollection; @@ -53,7 +57,6 @@ import org.hibernate.annotations.FilterJoinTable; import org.hibernate.annotations.FilterJoinTables; import org.hibernate.annotations.Filters; -import org.hibernate.annotations.ForeignKey; import org.hibernate.annotations.Immutable; import org.hibernate.annotations.LazyCollection; import org.hibernate.annotations.LazyCollectionOption; @@ -67,10 +70,8 @@ import org.hibernate.annotations.SQLDeleteAll; import org.hibernate.annotations.SQLInsert; import org.hibernate.annotations.SQLUpdate; -import org.hibernate.annotations.Sort; import org.hibernate.annotations.SortComparator; import org.hibernate.annotations.SortNatural; -import org.hibernate.annotations.SortType; import org.hibernate.annotations.Where; import org.hibernate.annotations.WhereJoinTable; import org.hibernate.annotations.common.AssertionFailure; @@ -92,7 +93,6 @@ import org.hibernate.cfg.PropertyHolderBuilder; import org.hibernate.cfg.PropertyInferredData; import org.hibernate.cfg.PropertyPreloadedData; -import org.hibernate.cfg.RecoverableException; import org.hibernate.cfg.SecondPass; import org.hibernate.engine.spi.ExecuteUpdateResultCheckStyle; import org.hibernate.internal.CoreMessageLogger; @@ -112,12 +112,8 @@ import org.hibernate.mapping.SimpleValue; import org.hibernate.mapping.Table; import org.hibernate.mapping.TypeDef; - import org.jboss.logging.Logger; -import static org.hibernate.cfg.BinderHelper.toAliasEntityMap; -import static org.hibernate.cfg.BinderHelper.toAliasTableMap; - /** * Base class for binding different types of collections to Hibernate configuration objects. * @@ -165,7 +161,6 @@ public abstract class CollectionBinder { private boolean isSortedCollection; private javax.persistence.OrderBy jpaOrderBy; private OrderBy sqlOrderBy; - private Sort deprecatedSort; private SortNatural naturalSort; private SortComparator comparatorSort; @@ -234,10 +229,6 @@ public void setSqlOrderBy(OrderBy sqlOrderBy) { this.sqlOrderBy = sqlOrderBy; } - public void setSort(Sort deprecatedSort) { - this.deprecatedSort = deprecatedSort; - } - public void setNaturalSort(SortNatural naturalSort) { this.naturalSort = naturalSort; } @@ -553,21 +544,7 @@ private void applySortingAndOrdering(Collection collection) { Class comparatorClass = null; if ( jpaOrderBy == null && sqlOrderBy == null ) { - if ( deprecatedSort != null ) { - LOG.debug( "Encountered deprecated @Sort annotation; use @SortNatural or @SortComparator instead." ); - if ( naturalSort != null || comparatorSort != null ) { - throw buildIllegalSortCombination(); - } - hadExplicitSort = deprecatedSort.type() != SortType.UNSORTED; - if ( deprecatedSort.type() == SortType.NATURAL ) { - isSorted = true; - } - else if ( deprecatedSort.type() == SortType.COMPARATOR ) { - isSorted = true; - comparatorClass = deprecatedSort.comparator(); - } - } - else if ( naturalSort != null ) { + if ( naturalSort != null ) { if ( comparatorSort != null ) { throw buildIllegalSortCombination(); } @@ -630,7 +607,6 @@ private AnnotationException buildIllegalSortCombination() { String.format( "Illegal combination of annotations on %s. Only one of @%s, @%s and @%s can be used", safeCollectionRole(), - Sort.class.getName(), SortNatural.class.getName(), SortComparator.class.getName() ) @@ -1091,9 +1067,6 @@ private static SimpleValue buildCollectionKey( key.setUpdateable( joinColumns.length == 0 || joinColumns[0].isUpdatable() ); key.setCascadeDeleteEnabled( cascadeDeleteEnabled ); collValue.setKey( key ); - ForeignKey fk = property != null ? property.getAnnotation( ForeignKey.class ) : null; - String fkName = fk != null ? fk.name() : ""; - if ( !BinderHelper.isEmptyAnnotationValue( fkName ) ) key.setForeignKeyName( fkName ); return key; } @@ -1245,11 +1218,6 @@ else if ( anyAnn != null ) { buildOrderByClauseFromHql( hqlOrderBy, collectionEntity, collValue.getRole() ) ); } - final ForeignKey fk = property.getAnnotation( ForeignKey.class ); - String fkName = fk != null ? fk.inverseName() : ""; - if ( !BinderHelper.isEmptyAnnotationValue( fkName ) ) { - element.setForeignKeyName( fkName ); - } } else if ( anyAnn != null ) { //@ManyToAny diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/EntityBinder.java b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/EntityBinder.java index 92a69b2e62cb..9bd4f0553414 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/EntityBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/EntityBinder.java @@ -23,10 +23,14 @@ */ package org.hibernate.cfg.annotations; +import static org.hibernate.cfg.BinderHelper.toAliasEntityMap; +import static org.hibernate.cfg.BinderHelper.toAliasTableMap; + import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; + import javax.persistence.Access; import javax.persistence.Entity; import javax.persistence.JoinColumn; @@ -39,22 +43,17 @@ import org.hibernate.AnnotationException; import org.hibernate.AssertionFailure; -import org.hibernate.EntityMode; import org.hibernate.MappingException; import org.hibernate.annotations.BatchSize; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; -import org.hibernate.annotations.DynamicInsert; -import org.hibernate.annotations.DynamicUpdate; import org.hibernate.annotations.FetchMode; import org.hibernate.annotations.Filter; import org.hibernate.annotations.Immutable; import org.hibernate.annotations.Loader; import org.hibernate.annotations.NaturalIdCache; import org.hibernate.annotations.OptimisticLockType; -import org.hibernate.annotations.OptimisticLocking; import org.hibernate.annotations.Persister; -import org.hibernate.annotations.Polymorphism; import org.hibernate.annotations.PolymorphismType; import org.hibernate.annotations.Proxy; import org.hibernate.annotations.RowId; @@ -62,7 +61,6 @@ import org.hibernate.annotations.SQLDeleteAll; import org.hibernate.annotations.SQLInsert; import org.hibernate.annotations.SQLUpdate; -import org.hibernate.annotations.SelectBeforeUpdate; import org.hibernate.annotations.Subselect; import org.hibernate.annotations.Synchronize; import org.hibernate.annotations.Tables; @@ -86,7 +84,6 @@ import org.hibernate.engine.spi.ExecuteUpdateResultCheckStyle; import org.hibernate.engine.spi.FilterDefinition; import org.hibernate.internal.CoreMessageLogger; -import org.hibernate.internal.util.ReflectHelper; import org.hibernate.internal.util.StringHelper; import org.hibernate.mapping.DependantValue; import org.hibernate.mapping.Join; @@ -96,12 +93,8 @@ import org.hibernate.mapping.Table; import org.hibernate.mapping.TableOwner; import org.hibernate.mapping.Value; - import org.jboss.logging.Logger; -import static org.hibernate.cfg.BinderHelper.toAliasEntityMap; -import static org.hibernate.cfg.BinderHelper.toAliasTableMap; - /** * Stateful holder and processor for binding Entity information @@ -154,7 +147,6 @@ public EntityBinder() { public EntityBinder( Entity ejb3Ann, - org.hibernate.annotations.Entity hibAnn, XClass annotatedClass, PersistentClass persistentClass, Mappings mappings) { @@ -162,52 +154,6 @@ public EntityBinder( this.persistentClass = persistentClass; this.annotatedClass = annotatedClass; bindEjb3Annotation( ejb3Ann ); - bindHibernateAnnotation( hibAnn ); - } - - - @SuppressWarnings("SimplifiableConditionalExpression") - private void bindHibernateAnnotation(org.hibernate.annotations.Entity hibAnn) { - { - final DynamicInsert dynamicInsertAnn = annotatedClass.getAnnotation( DynamicInsert.class ); - this.dynamicInsert = dynamicInsertAnn == null - ? ( hibAnn == null ? false : hibAnn.dynamicInsert() ) - : dynamicInsertAnn.value(); - } - - { - final DynamicUpdate dynamicUpdateAnn = annotatedClass.getAnnotation( DynamicUpdate.class ); - this.dynamicUpdate = dynamicUpdateAnn == null - ? ( hibAnn == null ? false : hibAnn.dynamicUpdate() ) - : dynamicUpdateAnn.value(); - } - - { - final SelectBeforeUpdate selectBeforeUpdateAnn = annotatedClass.getAnnotation( SelectBeforeUpdate.class ); - this.selectBeforeUpdate = selectBeforeUpdateAnn == null - ? ( hibAnn == null ? false : hibAnn.selectBeforeUpdate() ) - : selectBeforeUpdateAnn.value(); - } - - { - final OptimisticLocking optimisticLockingAnn = annotatedClass.getAnnotation( OptimisticLocking.class ); - this.optimisticLockType = optimisticLockingAnn == null - ? ( hibAnn == null ? OptimisticLockType.VERSION : hibAnn.optimisticLock() ) - : optimisticLockingAnn.type(); - } - - { - final Polymorphism polymorphismAnn = annotatedClass.getAnnotation( Polymorphism.class ); - this.polymorphismType = polymorphismAnn == null - ? ( hibAnn == null ? PolymorphismType.IMPLICIT : hibAnn.polymorphism() ) - : polymorphismAnn.type(); - } - - if ( hibAnn != null ) { - // used later in bind for logging - explicitHibernateEntityAnnotation = true; - //persister handled in bind - } } private void bindEjb3Annotation(Entity ejb3Ann) { @@ -260,13 +206,6 @@ public void bindEntity() { if ( annotatedClass.isAnnotationPresent( Immutable.class ) ) { mutable = false; } - else { - org.hibernate.annotations.Entity entityAnn = - annotatedClass.getAnnotation( org.hibernate.annotations.Entity.class ); - if ( entityAnn != null ) { - mutable = entityAnn.mutable(); - } - } rootClass.setMutable( mutable ); rootClass.setExplicitPolymorphism( isExplicitPolymorphism( polymorphismType ) ); if ( StringHelper.isNotEmpty( where ) ) rootClass.setWhere( where ); @@ -301,17 +240,6 @@ public void bindEntity() { if ( persisterAnn != null ) { persister = persisterAnn.impl(); } - else { - org.hibernate.annotations.Entity entityAnn = annotatedClass.getAnnotation( org.hibernate.annotations.Entity.class ); - if ( entityAnn != null && !BinderHelper.isEmptyAnnotationValue( entityAnn.persister() ) ) { - try { - persister = ReflectHelper.classForName( entityAnn.persister() ); - } - catch (ClassNotFoundException cnfe) { - throw new AnnotationException( "Could not find persister class: " + persister ); - } - } - } if ( persister != null ) { persistentClass.setEntityPersisterClass( persister ); } @@ -367,16 +295,12 @@ public void bindEntity() { //tuplizers if ( annotatedClass.isAnnotationPresent( Tuplizers.class ) ) { for (Tuplizer tuplizer : annotatedClass.getAnnotation( Tuplizers.class ).value()) { - EntityMode mode = EntityMode.parse( tuplizer.entityMode() ); - //todo tuplizer.entityModeType - persistentClass.addTuplizer( mode, tuplizer.impl().getName() ); + persistentClass.addTuplizer( tuplizer.entityModeType(), tuplizer.impl().getName() ); } } if ( annotatedClass.isAnnotationPresent( Tuplizer.class ) ) { Tuplizer tuplizer = annotatedClass.getAnnotation( Tuplizer.class ); - EntityMode mode = EntityMode.parse( tuplizer.entityMode() ); - //todo tuplizer.entityModeType - persistentClass.addTuplizer( mode, tuplizer.impl().getName() ); + persistentClass.addTuplizer( tuplizer.entityModeType(), tuplizer.impl().getName() ); } for ( Filter filter : filters ) { @@ -998,30 +922,9 @@ public AccessType getPropertyAccessor(XAnnotatedElement element) { public AccessType getExplicitAccessType(XAnnotatedElement element) { AccessType accessType = null; - AccessType hibernateAccessType = null; - AccessType jpaAccessType = null; - - org.hibernate.annotations.AccessType accessTypeAnnotation = element.getAnnotation( org.hibernate.annotations.AccessType.class ); - if ( accessTypeAnnotation != null ) { - hibernateAccessType = AccessType.getAccessStrategy( accessTypeAnnotation.value() ); - } - Access access = element.getAnnotation( Access.class ); if ( access != null ) { - jpaAccessType = AccessType.getAccessStrategy( access.value() ); - } - - if ( hibernateAccessType != null && jpaAccessType != null && hibernateAccessType != jpaAccessType ) { - throw new MappingException( - "Found @Access and @AccessType with conflicting values on a property in class " + annotatedClass.toString() - ); - } - - if ( hibernateAccessType != null ) { - accessType = hibernateAccessType; - } - else if ( jpaAccessType != null ) { - accessType = jpaAccessType; + accessType = AccessType.getAccessStrategy( access.value() ); } return accessType; diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/ListBinder.java b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/ListBinder.java index c79cc22a267e..b4e2f0adf1c0 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/ListBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/ListBinder.java @@ -28,7 +28,6 @@ import org.hibernate.AnnotationException; import org.hibernate.MappingException; import org.hibernate.annotations.OrderBy; -import org.hibernate.annotations.Sort; import org.hibernate.annotations.common.reflection.XClass; import org.hibernate.annotations.common.reflection.XProperty; import org.hibernate.cfg.CollectionSecondPass; @@ -46,7 +45,6 @@ import org.hibernate.mapping.OneToMany; import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.SimpleValue; - import org.jboss.logging.Logger; /** @@ -74,12 +72,6 @@ public void setSqlOrderBy(OrderBy orderByAnn) { LOG.orderByAnnotationIndexedCollection(); } - @Override - public void setSort(Sort sortAnn) { - if ( sortAnn != null ) - LOG.sortAnnotationIndexedCollection(); - } - @Override public SecondPass getSecondPass( final Ejb3JoinColumn[] fkJoinColumns, diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/QueryBinder.java b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/QueryBinder.java index d3ddd8a71666..22149d2d8730 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/QueryBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/QueryBinder.java @@ -24,6 +24,7 @@ package org.hibernate.cfg.annotations; import java.util.HashMap; + import javax.persistence.NamedNativeQueries; import javax.persistence.NamedNativeQuery; import javax.persistence.NamedQueries; @@ -50,7 +51,6 @@ import org.hibernate.engine.spi.NamedSQLQueryDefinition; import org.hibernate.engine.spi.NamedSQLQueryDefinitionBuilder; import org.hibernate.internal.CoreMessageLogger; - import org.jboss.logging.Logger; /** @@ -279,9 +279,6 @@ private static FlushMode getFlushMode(FlushModeType flushModeType) { case COMMIT: flushMode = FlushMode.COMMIT; break; - case NEVER: - flushMode = FlushMode.MANUAL; - break; case MANUAL: flushMode = FlushMode.MANUAL; break; diff --git a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/TableBinder.java b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/TableBinder.java index 83041f6af89e..6e59709cf31e 100644 --- a/hibernate-core/src/main/java/org/hibernate/cfg/annotations/TableBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/cfg/annotations/TableBinder.java @@ -26,14 +26,14 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; + +import javax.persistence.Index; import javax.persistence.UniqueConstraint; import org.hibernate.AnnotationException; import org.hibernate.AssertionFailure; -import org.hibernate.annotations.Index; import org.hibernate.cfg.BinderHelper; import org.hibernate.cfg.Ejb3JoinColumn; -import org.hibernate.cfg.IndexOrUniqueKeySecondPass; import org.hibernate.cfg.JPAIndexHolder; import org.hibernate.cfg.Mappings; import org.hibernate.cfg.NamingStrategy; @@ -53,7 +53,6 @@ import org.hibernate.mapping.Table; import org.hibernate.mapping.ToOne; import org.hibernate.mapping.Value; - import org.jboss.logging.Logger; /** @@ -107,7 +106,7 @@ public void setUniqueConstraints(UniqueConstraint[] uniqueConstraints) { this.uniqueConstraints = TableBinder.buildUniqueConstraintHolders( uniqueConstraints ); } - public void setJpaIndex(javax.persistence.Index[] jpaIndex){ + public void setJpaIndex(Index[] jpaIndex){ this.jpaIndexHolders = buildJpaIndexHolder( jpaIndex ); } @@ -536,21 +535,12 @@ public static void createUniqueConstraint(Value value) { } public static void addIndexes(Table hibTable, Index[] indexes, Mappings mappings) { - for (Index index : indexes) { - //no need to handle inSecondPass here since it is only called from EntityBinder - mappings.addSecondPass( - new IndexOrUniqueKeySecondPass( hibTable, index.name(), index.columnNames(), mappings ) - ); - } - } - - public static void addIndexes(Table hibTable, javax.persistence.Index[] indexes, Mappings mappings) { mappings.addJpaIndexHolders( hibTable, buildJpaIndexHolder( indexes ) ); } - public static List buildJpaIndexHolder(javax.persistence.Index[] indexes){ + public static List buildJpaIndexHolder(Index[] indexes){ List holders = new ArrayList( indexes.length ); - for(javax.persistence.Index index : indexes){ + for(Index index : indexes){ holders.add( new JPAIndexHolder( index ) ); } return holders; diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/BasicPluralAttributeIndexSourceImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/BasicPluralAttributeIndexSourceImpl.java index 0883944ec5cf..e49fa97b00d4 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/BasicPluralAttributeIndexSourceImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/BasicPluralAttributeIndexSourceImpl.java @@ -26,17 +26,15 @@ import java.util.Collections; import java.util.List; -import org.jboss.jandex.AnnotationInstance; - import org.hibernate.metamodel.internal.Binder; import org.hibernate.metamodel.internal.source.annotations.attribute.Column; import org.hibernate.metamodel.internal.source.annotations.attribute.PluralAssociationAttribute; -import org.hibernate.metamodel.internal.source.annotations.util.HibernateDotNames; import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames; import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper; import org.hibernate.metamodel.spi.binding.PluralAttributeIndexBinding; import org.hibernate.metamodel.spi.source.BasicPluralAttributeIndexSource; import org.hibernate.metamodel.spi.source.RelationalValueSource; +import org.jboss.jandex.AnnotationInstance; /** * @author Strong Liu @@ -66,14 +64,8 @@ public BasicPluralAttributeIndexSourceImpl( private static List createRelationalValueSources(PluralAssociationAttribute attribute) { AnnotationInstance columnAnnotation = JandexHelper.getSingleAnnotation( attribute.annotations(), - HibernateDotNames.INDEX_COLUMN + JPADotNames.ORDER_COLUMN ); - if ( columnAnnotation == null ) { - columnAnnotation = JandexHelper.getSingleAnnotation( - attribute.annotations(), - JPADotNames.ORDER_COLUMN - ); - } if ( columnAnnotation == null ) { columnAnnotation = JandexHelper.getSingleAnnotation( attribute.annotations(), diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/IndexedPluralAttributeSourceImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/IndexedPluralAttributeSourceImpl.java index fade466a2455..df6172810fe2 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/IndexedPluralAttributeSourceImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/IndexedPluralAttributeSourceImpl.java @@ -33,7 +33,6 @@ import org.hibernate.metamodel.internal.source.annotations.attribute.MappedAttribute; import org.hibernate.metamodel.internal.source.annotations.attribute.PluralAssociationAttribute; import org.hibernate.metamodel.internal.source.annotations.entity.ConfiguredClass; -import org.hibernate.metamodel.internal.source.annotations.util.HibernateDotNames; import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames; import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper; import org.hibernate.metamodel.spi.source.AttributeSource; @@ -73,10 +72,9 @@ public IndexedPluralAttributeSourceImpl( } if ( attribute.getPluralAttributeNature() == PluralAttributeSource.Nature.ARRAY - && !attribute.annotations().containsKey( JPADotNames.ORDER_COLUMN ) - && !attribute.annotations().containsKey( HibernateDotNames.INDEX_COLUMN ) ) { + && !attribute.annotations().containsKey( JPADotNames.ORDER_COLUMN ) ) { throw new AnnotationException( "The array attribute '" + attribute.getRole() - + "' must be annotated with @OrderColumn or @IndexColumn!" ); + + "' must be annotated with @OrderColumn!" ); } if ( attribute.isSequentiallyIndexed() ) { diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/SequentialPluralAttributeIndexSourceImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/SequentialPluralAttributeIndexSourceImpl.java index 66c51f27fe09..810b272d269b 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/SequentialPluralAttributeIndexSourceImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/SequentialPluralAttributeIndexSourceImpl.java @@ -26,15 +26,13 @@ import java.util.Collections; import java.util.Map; -import org.jboss.jandex.AnnotationInstance; - import org.hibernate.metamodel.internal.Binder; import org.hibernate.metamodel.internal.source.annotations.attribute.PluralAssociationAttribute; -import org.hibernate.metamodel.internal.source.annotations.util.HibernateDotNames; import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames; import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper; import org.hibernate.metamodel.spi.source.HibernateTypeSource; import org.hibernate.metamodel.spi.source.SequentialPluralAttributeIndexSource; +import org.jboss.jandex.AnnotationInstance; /** * @author Gail Badner @@ -67,14 +65,8 @@ public SequentialPluralAttributeIndexSourceImpl( super( indexedPluralAttributeSource, attribute, defaultNamingStrategy ); AnnotationInstance columnAnnotation = JandexHelper.getSingleAnnotation( attribute.annotations(), - HibernateDotNames.INDEX_COLUMN + JPADotNames.ORDER_COLUMN ); - if ( columnAnnotation == null ) { - columnAnnotation = JandexHelper.getSingleAnnotation( - attribute.annotations(), - JPADotNames.ORDER_COLUMN - ); - } this.base = columnAnnotation.value( "base" ) != null ? columnAnnotation.value( "base" ) .asInt() : 0; } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/ToOneAttributeSourceImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/ToOneAttributeSourceImpl.java index 3487b644cb58..a9e2775fc12f 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/ToOneAttributeSourceImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/ToOneAttributeSourceImpl.java @@ -32,14 +32,12 @@ import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; import org.hibernate.cfg.NamingStrategy; import org.hibernate.cfg.NotYetImplementedException; -import org.hibernate.internal.util.StringHelper; import org.hibernate.metamodel.internal.Binder; import org.hibernate.metamodel.internal.source.annotations.attribute.AssociationAttribute; import org.hibernate.metamodel.internal.source.annotations.attribute.Column; import org.hibernate.metamodel.internal.source.annotations.attribute.MappedAttribute; import org.hibernate.metamodel.internal.source.annotations.attribute.SingularAssociationAttribute; import org.hibernate.metamodel.internal.source.annotations.entity.EntityBindingContext; -import org.hibernate.metamodel.internal.source.annotations.util.HibernateDotNames; import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames; import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper; import org.hibernate.metamodel.spi.binding.AttributeBinding; @@ -112,23 +110,15 @@ else if ( associationAttribute.getJoinColumnValues() == null || private String resolveForeignKeyName(SingularAssociationAttribute associationAttribute) { String fkName = null; - final AnnotationInstance fkAnnotation = JandexHelper.getSingleAnnotation( associationAttribute().annotations(), - HibernateDotNames.FOREIGN_KEY ); - fkName = fkAnnotation != null ? JandexHelper.getValue( fkAnnotation, "name", String.class, cls ) : null; - - if (StringHelper.isEmpty( fkName) ) { - final AnnotationInstance joinColumnAnnotation = JandexHelper.getSingleAnnotation( - associationAttribute().annotations(), JPADotNames.JOIN_COLUMN ); - if (joinColumnAnnotation != null) { - final AnnotationInstance jpaFkAnnotation = JandexHelper.getValue( - joinColumnAnnotation, "foreignKey", AnnotationInstance.class, cls ); - fkName = jpaFkAnnotation != null ? JandexHelper.getValue( jpaFkAnnotation, "name", String.class, cls ) - : null; - } + final AnnotationInstance joinColumnAnnotation = JandexHelper.getSingleAnnotation( + associationAttribute().annotations(), JPADotNames.JOIN_COLUMN ); + if (joinColumnAnnotation != null) { + final AnnotationInstance jpaFkAnnotation = JandexHelper.getValue( + joinColumnAnnotation, "foreignKey", AnnotationInstance.class, cls ); + fkName = jpaFkAnnotation != null ? JandexHelper.getValue( jpaFkAnnotation, "name", String.class, cls ) + : null; } - // TODO: join tables? - return fkName; } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/attribute/Column.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/attribute/Column.java index 33f65d31487c..3897f4a49170 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/attribute/Column.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/attribute/Column.java @@ -23,14 +23,12 @@ */ package org.hibernate.metamodel.internal.source.annotations.attribute; +import org.hibernate.AssertionFailure; +import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames; import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.AnnotationValue; import org.jboss.jandex.DotName; -import org.hibernate.AssertionFailure; -import org.hibernate.metamodel.internal.source.annotations.util.HibernateDotNames; -import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames; - /** * Container for the properties defined by {@link javax.persistence.Column} or {@link javax.persistence.JoinColumn}. * @@ -64,7 +62,6 @@ protected void applyCheck(AnnotationInstance columnAnnotation) { if ( !( JPADotNames.COLUMN.equals( name ) || JPADotNames.JOIN_COLUMN.equals( name ) || JPADotNames.ORDER_COLUMN.equals( name ) - || HibernateDotNames.INDEX_COLUMN.equals( name ) || JPADotNames.PRIMARY_KEY_JOIN_COLUMN.equals( name ) || JPADotNames.MAP_KEY_COLUMN.equals( name ) ) ) { diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/attribute/PluralAssociationAttribute.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/attribute/PluralAssociationAttribute.java index 31474071e992..83e9ce568c5d 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/attribute/PluralAssociationAttribute.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/attribute/PluralAssociationAttribute.java @@ -37,7 +37,6 @@ import org.hibernate.annotations.FetchMode; import org.hibernate.annotations.LazyCollectionOption; import org.hibernate.annotations.OnDeleteAction; -import org.hibernate.annotations.SortType; import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; import org.hibernate.internal.util.StringHelper; import org.hibernate.metamodel.internal.source.annotations.attribute.type.AttributeTypeResolver; @@ -216,35 +215,26 @@ private PluralAssociationAttribute( final ClassLoaderService cls = context.getServiceRegistry().getService( ClassLoaderService.class ); // TODO: This is UGLY -- pull into a util and find a better pattern? - AnnotationInstance foreignKey = JandexHelper.getSingleAnnotation( - annotations(), HibernateDotNames.FOREIGN_KEY ); AnnotationInstance joinTable = JandexHelper.getSingleAnnotation( annotations(), JPADotNames.JOIN_TABLE ); AnnotationInstance collectionTable = JandexHelper.getSingleAnnotation( annotations(), JPADotNames.COLLECTION_TABLE ); - if (foreignKey != null) { - explicitForeignKeyName = JandexHelper.getValue( foreignKey, "name", String.class, cls ); - String temp = JandexHelper.getValue( foreignKey, "inverseName", String.class, cls ); - inverseForeignKeyName = StringHelper.isNotEmpty( temp ) ? temp : null; - } - if (joinTable != null && StringHelper.isEmpty( explicitForeignKeyName )) { - final AnnotationInstance jpaFkAnnotation = JandexHelper.getValue( + if (joinTable != null) { + AnnotationInstance jpaFkAnnotation = JandexHelper.getValue( joinTable, "foreignKey", AnnotationInstance.class, cls ); explicitForeignKeyName = jpaFkAnnotation != null ? JandexHelper.getValue( jpaFkAnnotation, "name", String.class, cls ) : null; + jpaFkAnnotation = JandexHelper.getValue( + joinTable, "inverseForeignKey", AnnotationInstance.class, cls ); + inverseForeignKeyName = jpaFkAnnotation != null + ? JandexHelper.getValue( jpaFkAnnotation, "name", String.class, cls ) : null; } - if (collectionTable != null && StringHelper.isEmpty( explicitForeignKeyName )) { + if (collectionTable != null) { final AnnotationInstance jpaFkAnnotation = JandexHelper.getValue( collectionTable, "foreignKey", AnnotationInstance.class, cls ); explicitForeignKeyName = jpaFkAnnotation != null ? JandexHelper.getValue( jpaFkAnnotation, "name", String.class, cls ) : null; } - if (joinTable != null && StringHelper.isEmpty( inverseForeignKeyName )) { - final AnnotationInstance jpaFkAnnotation = JandexHelper.getValue( - joinTable, "inverseForeignKey", AnnotationInstance.class, cls ); - inverseForeignKeyName = jpaFkAnnotation != null - ? JandexHelper.getValue( jpaFkAnnotation, "name", String.class, cls ) : null; - } this.mutable = JandexHelper.getSingleAnnotation( annotations(), HibernateDotNames.IMMUTABLE ) == null; @@ -269,7 +259,6 @@ HibernateDotNames.SQL_DELETE_ALL, annotations() annotations, HibernateDotNames.COLLECTION_ID ) != null; - final AnnotationInstance sortAnnotation = JandexHelper.getSingleAnnotation( annotations, HibernateDotNames.SORT ); final AnnotationInstance sortNaturalAnnotation = JandexHelper.getSingleAnnotation( annotations, HibernateDotNames.SORT_NATURAL ); final AnnotationInstance sortComparatorAnnotation = JandexHelper.getSingleAnnotation( annotations, HibernateDotNames.SORT_COMPARATOR ); @@ -281,33 +270,6 @@ else if ( sortComparatorAnnotation != null ) { this.sorted = true; this.comparatorName = JandexHelper.getValue( sortComparatorAnnotation, "value", String.class, cls ); } - else if ( sortAnnotation != null ) { - final SortType sortType = JandexHelper.getEnumValue( sortAnnotation, "type", SortType.class, - getContext().getServiceRegistry().getService( ClassLoaderService.class ) ); - switch ( sortType ){ - - case NATURAL: - this.sorted = true; - this.comparatorName = "natural"; - break; - case COMPARATOR: - String comparatorName = JandexHelper.getValue( sortAnnotation, "comparator", String.class, - getContext().getServiceRegistry().getService( ClassLoaderService.class ) ); - if ( StringHelper.isEmpty( comparatorName ) ) { - throw new MappingException( - "Comparator class must be provided when using SortType.COMPARATOR on property: " + getRole(), - getContext().getOrigin() - ); - } - this.sorted = true; - this.comparatorName = comparatorName; - break; - default: - this.sorted = false; - this.comparatorName = null; - break; - } - } else { this.sorted = false; this.comparatorName = null; @@ -315,14 +277,7 @@ else if ( sortAnnotation != null ) { AnnotationInstance orderColumnAnnotation = JandexHelper.getSingleAnnotation( annotations, JPADotNames.ORDER_COLUMN ); - AnnotationInstance indexColumnAnnotation = JandexHelper.getSingleAnnotation( annotations, HibernateDotNames.INDEX_COLUMN ); - if ( orderColumnAnnotation != null && indexColumnAnnotation != null ) { - throw new MappingException( - "@OrderColumn and @IndexColumn can't be used together on property: " + getRole(), - getContext().getOrigin() - ); - } - this.isSequentiallyIndexed = orderColumnAnnotation != null || indexColumnAnnotation != null; + this.isSequentiallyIndexed = orderColumnAnnotation != null; this.pluralAttributeNature = resolvePluralAttributeNature(); AnnotationInstance batchAnnotation = JandexHelper.getSingleAnnotation( annotations, HibernateDotNames.BATCH_SIZE ); @@ -357,7 +312,7 @@ private void checkSortedTypeIsSortable() { || SortedSet.class.isAssignableFrom( getAttributeType() ) ) { if ( !isSorted() ) { throw new MappingException( - "A sorted collection has to define @Sort: " + getRole(), + "A sorted collection has to define @SortNatural or @SortComparator: " + getRole(), getContext().getOrigin() ); } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/entity/ConfiguredClass.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/entity/ConfiguredClass.java index 01bab955a3fa..b9ad755652cc 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/entity/ConfiguredClass.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/entity/ConfiguredClass.java @@ -322,11 +322,6 @@ private AccessType determineClassAccessType(AccessType defaultAccessType) { if ( accessAnnotation != null ) { accessType = JandexHelper.getEnumValue( accessAnnotation, "value", AccessType.class, localBindingContext.getServiceRegistry().getService( ClassLoaderService.class ) ); - } else { - accessAnnotation = JandexHelper.getSingleAnnotation( classInfo, HibernateDotNames.ACCESS_TYPE, ClassInfo.class ); - if ( accessAnnotation != null ) { - accessType = AccessType.valueOf( accessAnnotation.value().asString().toUpperCase() ); - } } return accessType; @@ -380,14 +375,8 @@ private Set createExplicitlyConfiguredAccessProperties() { Set explicitAccessPropertyNames = new HashSet(); List accessAnnotations = classInfo.annotations().get( JPADotNames.ACCESS ); - List hibernateAccessAnnotations = classInfo.annotations().get( HibernateDotNames.ACCESS_TYPE ); if ( accessAnnotations == null ) { - accessAnnotations = hibernateAccessAnnotations; - if ( accessAnnotations == null ) { - return explicitAccessPropertyNames; - } - } else if ( hibernateAccessAnnotations != null ) { - accessAnnotations.addAll( hibernateAccessAnnotations ); + return explicitAccessPropertyNames; } // iterate over all @Access annotations defined on the current class diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/entity/EntityClass.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/entity/EntityClass.java index 2378a398a209..8e93ad4e8d5a 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/entity/EntityClass.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/entity/EntityClass.java @@ -144,24 +144,10 @@ public EntityClass( processProxyGeneration(); processDiscriminatorValue(); - AnnotationInstance foreignKey = JandexHelper.getSingleAnnotation( - classInfo, - HibernateDotNames.FOREIGN_KEY, - ClassInfo.class - ); this.joinedSubclassPrimaryKeyJoinColumnSources = determinePrimaryKeyJoinColumns(); - if ( foreignKey != null ) { - ensureJoinedSubEntity(); - explicitForeignKeyName = JandexHelper.getValue( foreignKey, "name", String.class, - getLocalBindingContext().getServiceRegistry().getService( ClassLoaderService.class ) ); - String temp = JandexHelper.getValue( foreignKey, "inverseName", String.class, - getLocalBindingContext().getServiceRegistry().getService( ClassLoaderService.class ) ); - inverseForeignKeyName = StringHelper.isNotEmpty( temp ) ? temp : null; - } - else { - explicitForeignKeyName = null; - inverseForeignKeyName = null; - } + // TODO: bind JPA @ForeignKey? + explicitForeignKeyName = null; + inverseForeignKeyName = null; this.onDeleteAction = determineOnDeleteAction(); } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/global/QueryProcessor.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/global/QueryProcessor.java index b5e61930f468..e11cee606179 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/global/QueryProcessor.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/global/QueryProcessor.java @@ -171,9 +171,6 @@ public static FlushMode getFlushMode(FlushModeType flushModeType) { case COMMIT: flushMode = FlushMode.COMMIT; break; - case NEVER: - flushMode = FlushMode.MANUAL; - break; case MANUAL: flushMode = FlushMode.MANUAL; break; diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/util/EnumConversionHelper.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/util/EnumConversionHelper.java index fbb273c9da2b..1858c567ea33 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/util/EnumConversionHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/util/EnumConversionHelper.java @@ -25,6 +25,7 @@ import java.util.HashSet; import java.util.Set; + import javax.persistence.CascadeType; import javax.persistence.GenerationType; @@ -127,9 +128,6 @@ public static CascadeStyle cascadeTypeToCascadeStyle( case LOCK: { return CascadeStyles.LOCK; } - case DELETE_ORPHAN: { - return CascadeStyles.DELETE_ORPHAN; - } default: { throw new AssertionFailure( "Unknown cascade type: " + cascadeType ); } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/util/HibernateDotNames.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/util/HibernateDotNames.java index 92ac7f05d6dc..89185d42cb69 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/util/HibernateDotNames.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/source/annotations/util/HibernateDotNames.java @@ -23,9 +23,6 @@ */ package org.hibernate.metamodel.internal.source.annotations.util; -import org.jboss.jandex.DotName; - -import org.hibernate.annotations.AccessType; import org.hibernate.annotations.Any; import org.hibernate.annotations.AnyMetaDef; import org.hibernate.annotations.AnyMetaDefs; @@ -50,14 +47,11 @@ import org.hibernate.annotations.FilterJoinTable; import org.hibernate.annotations.FilterJoinTables; import org.hibernate.annotations.Filters; -import org.hibernate.annotations.ForeignKey; import org.hibernate.annotations.Formula; import org.hibernate.annotations.Generated; import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerators; import org.hibernate.annotations.Immutable; -import org.hibernate.annotations.Index; -import org.hibernate.annotations.IndexColumn; import org.hibernate.annotations.JoinColumnOrFormula; import org.hibernate.annotations.JoinColumnsOrFormulas; import org.hibernate.annotations.JoinFormula; @@ -90,7 +84,6 @@ import org.hibernate.annotations.SQLInsert; import org.hibernate.annotations.SQLUpdate; import org.hibernate.annotations.SelectBeforeUpdate; -import org.hibernate.annotations.Sort; import org.hibernate.annotations.SortComparator; import org.hibernate.annotations.SortNatural; import org.hibernate.annotations.Source; @@ -108,6 +101,7 @@ import org.hibernate.annotations.TypeDefs; import org.hibernate.annotations.Where; import org.hibernate.annotations.WhereJoinTable; +import org.jboss.jandex.DotName; /** * Defines the dot names for the Hibernate specific mapping annotations. @@ -115,7 +109,6 @@ * @author Hardy Ferentschik */ public interface HibernateDotNames { - DotName ACCESS_TYPE = DotName.createSimple( AccessType.class.getName() ); DotName ANY = DotName.createSimple( Any.class.getName() ); DotName ANY_META_DEF = DotName.createSimple( AnyMetaDef.class.getName() ); DotName ANY_META_DEFS = DotName.createSimple( AnyMetaDefs.class.getName() ); @@ -141,14 +134,11 @@ public interface HibernateDotNames { DotName FILTER_DEFS = DotName.createSimple( FilterDefs.class.getName() ); DotName FILTER_JOIN_TABLE = DotName.createSimple( FilterJoinTable.class.getName() ); DotName FILTER_JOIN_TABLES = DotName.createSimple( FilterJoinTables.class.getName() ); - DotName FOREIGN_KEY = DotName.createSimple( ForeignKey.class.getName() ); DotName FORMULA = DotName.createSimple( Formula.class.getName() ); DotName GENERATED = DotName.createSimple( Generated.class.getName() ); DotName GENERIC_GENERATOR = DotName.createSimple( GenericGenerator.class.getName() ); DotName GENERIC_GENERATORS = DotName.createSimple( GenericGenerators.class.getName() ); DotName IMMUTABLE = DotName.createSimple( Immutable.class.getName() ); - DotName INDEX = DotName.createSimple( Index.class.getName() ); - DotName INDEX_COLUMN = DotName.createSimple( IndexColumn.class.getName() ); DotName JOIN_COLUMN_OR_FORMULA = DotName.createSimple( JoinColumnOrFormula.class.getName() ); DotName JOIN_COLUMNS_OR_FORMULAS = DotName.createSimple( JoinColumnsOrFormulas.class.getName() ); DotName JOIN_FORMULA = DotName.createSimple( JoinFormula.class.getName() ); @@ -177,7 +167,6 @@ public interface HibernateDotNames { DotName PROXY = DotName.createSimple( Proxy.class.getName() ); DotName ROW_ID = DotName.createSimple( RowId.class.getName() ); DotName SELECT_BEFORE_UPDATE = DotName.createSimple( SelectBeforeUpdate.class.getName() ); - DotName SORT = DotName.createSimple( Sort.class.getName() ); DotName SORT_COMPARATOR = DotName.createSimple( SortComparator.class.getName()); DotName SORT_NATURAL = DotName.createSimple( SortNatural.class.getName() ); DotName SOURCE = DotName.createSimple( Source.class.getName() ); diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/util/JandexHelperTest.java b/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/util/JandexHelperTest.java index 950618ad6765..7ee5c0a63c74 100644 --- a/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/util/JandexHelperTest.java +++ b/hibernate-core/src/test/java/org/hibernate/metamodel/internal/source/annotations/util/JandexHelperTest.java @@ -23,9 +23,15 @@ */ package org.hibernate.metamodel.internal.source.annotations.util; +import static junit.framework.Assert.assertTrue; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + import java.util.Collection; import java.util.List; import java.util.Map; + import javax.persistence.AttributeOverride; import javax.persistence.Basic; import javax.persistence.Column; @@ -33,28 +39,20 @@ import javax.persistence.LockModeType; import javax.persistence.NamedQuery; +import org.hibernate.AssertionFailure; +import org.hibernate.annotations.NamedNativeQuery; +import org.hibernate.boot.registry.StandardServiceRegistryBuilder; +import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; +import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl; +import org.hibernate.testing.junit4.BaseUnitTestCase; import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.ClassInfo; import org.jboss.jandex.DotName; -import org.jboss.jandex.Index; import org.jboss.jandex.IndexView; import org.junit.After; -import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import org.hibernate.AssertionFailure; -import org.hibernate.annotations.NamedNativeQuery; -import org.hibernate.boot.registry.StandardServiceRegistryBuilder; -import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; -import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl; -import org.hibernate.testing.junit4.BaseUnitTestCase; - -import static junit.framework.Assert.assertTrue; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; - /** * Tests for the helper class {@link JandexHelper}. * @@ -179,23 +177,6 @@ class Foo { assertEquals( "Wrong lock mode", LockModeType.OPTIMISTIC, lockMode ); } - @Test - public void testRetrieveStringArray() { - class Foo { - @org.hibernate.annotations.Index(name = "index", columnNames = { "a", "b", "c" }) - private String foo; - } - - IndexView index = JandexHelper.indexForClass( classLoaderService, Foo.class ); - Collection annotationInstances = index.getAnnotations( HibernateDotNames.INDEX ); - assertTrue( annotationInstances.size() == 1 ); - AnnotationInstance annotationInstance = annotationInstances.iterator().next(); - - String[] columnNames = JandexHelper.getValue( annotationInstance, "columnNames", String[].class, - classLoaderService ); - Assert.assertTrue( columnNames.length == 3 ); - } - @Test(expected = AssertionFailure.class) public void testRetrieveClassParameterAsClass() { @NamedNativeQuery(name = "foo", query = "bar", resultClass = Foo.class) diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/onetomany/EntityWithUnidirectionalOneToMany.java b/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/onetomany/EntityWithUnidirectionalOneToMany.java index 0ebfdc1016e1..c0c5cecc71bd 100644 --- a/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/onetomany/EntityWithUnidirectionalOneToMany.java +++ b/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/onetomany/EntityWithUnidirectionalOneToMany.java @@ -7,13 +7,14 @@ import java.util.List; import java.util.Map; import java.util.Set; + import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.OneToMany; +import javax.persistence.OrderColumn; -import org.hibernate.annotations.IndexColumn; import org.hibernate.annotations.LazyCollection; import org.hibernate.annotations.LazyCollectionOption; /** @@ -70,7 +71,7 @@ public void setTheSet(Set theSet) { @OneToMany(fetch = FetchType.EAGER) @JoinColumn(name = "theListOwner", nullable = false) - @IndexColumn( name = "list_index") + @OrderColumn( name = "list_index") public List getTheList() { return theList; } diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/Customer.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/Customer.java index ce8b4b6af16b..f950ec9a31b0 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/Customer.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/Customer.java @@ -1,8 +1,11 @@ //$Id$ package org.hibernate.test.annotations; +import static org.hibernate.annotations.CascadeType.ALL; + import java.io.Serializable; import java.util.Collection; import java.util.SortedSet; + import javax.persistence.CascadeType; import javax.persistence.Entity; import javax.persistence.FetchType; @@ -13,10 +16,7 @@ import javax.persistence.OneToOne; import org.hibernate.annotations.Cascade; -import org.hibernate.annotations.Sort; -import org.hibernate.annotations.SortType; - -import static org.hibernate.annotations.CascadeType.ALL; +import org.hibernate.annotations.SortComparator; /** @@ -55,7 +55,7 @@ public void setName(String string) { @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER) @JoinColumn(name = "CUST_ID") - @Sort(type = SortType.COMPARATOR, comparator = TicketComparator.class) + @SortComparator(TicketComparator.class) public SortedSet getTickets() { return tickets; } diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/access/Bed.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/access/Bed.java index 62e72decff75..ceca9181bf29 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/access/Bed.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/access/Bed.java @@ -3,13 +3,13 @@ import javax.persistence.Entity; import javax.persistence.Transient; -import org.hibernate.annotations.AccessType; +import org.hibernate.annotations.AttributeAccessor; /** * @author Emmanuel Bernard */ @Entity -@AccessType("property") +@AttributeAccessor("property") public class Bed extends Furniture { String quality; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/access/Furniture.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/access/Furniture.java index e423d71c0cbb..4a8ac61487e7 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/access/Furniture.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/access/Furniture.java @@ -5,13 +5,13 @@ import javax.persistence.Id; import javax.persistence.Transient; -import org.hibernate.annotations.AccessType; +import org.hibernate.annotations.AttributeAccessor; /** * @author Emmanuel Bernard */ @Entity -@AccessType("field") +@AttributeAccessor("field") public class Furniture extends Woody { @Id @GeneratedValue @@ -36,7 +36,7 @@ public void setId(Integer id) { this.id = id; } - @AccessType("property") + @AttributeAccessor("property") public long weight; public long getWeight() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/access/Gardenshed.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/access/Gardenshed.java index dad5d73aa659..c67ddef71a7e 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/access/Gardenshed.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/access/Gardenshed.java @@ -5,7 +5,7 @@ import javax.persistence.Id; import javax.persistence.Transient; -import org.hibernate.annotations.AccessType; +import org.hibernate.annotations.AttributeAccessor; /** * This is the opposite of the Furniture test, as this tries to override the class AccessType("property") with @@ -15,7 +15,7 @@ * @since 2007-05-31 */ @Entity -@AccessType( "property" ) +@AttributeAccessor( "property" ) public class Gardenshed extends Woody { @@ -43,7 +43,7 @@ public void setId(Integer id) { } // These 2 functions should not return in Hibernate, but the value should come from the field "floors" - @AccessType( "field" ) + @AttributeAccessor( "field" ) public long getFloors() { return this.floors + 2; } diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/access/Woody.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/access/Woody.java index 2f7f19b79af5..9e4656b90872 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/access/Woody.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/access/Woody.java @@ -2,13 +2,13 @@ package org.hibernate.test.annotations.access; import javax.persistence.MappedSuperclass; -import org.hibernate.annotations.AccessType; +import org.hibernate.annotations.AttributeAccessor; /** * @author Emmanuel Bernard */ @MappedSuperclass -@AccessType("property") +@AttributeAccessor("property") public class Woody extends Thingy { private String color; private String name; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/access/jpa/Course3.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/access/jpa/Course3.java index 6e3a13097114..8d4dde5d92be 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/access/jpa/Course3.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/access/jpa/Course3.java @@ -24,6 +24,7 @@ */ package org.hibernate.test.annotations.access.jpa; import java.util.List; + import javax.persistence.Access; import javax.persistence.AccessType; import javax.persistence.CascadeType; @@ -32,6 +33,8 @@ import javax.persistence.Id; import javax.persistence.OneToMany; +import org.hibernate.annotations.AttributeAccessor; + /** * @author Hardy Ferentschik @@ -48,7 +51,7 @@ public class Course3 { @Id @GeneratedValue - @org.hibernate.annotations.AccessType("field") + @AttributeAccessor("field") public long getId() { return id; } diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/access/xml/Boy.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/access/xml/Boy.java index 27c237c8c992..1350ec29b13e 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/access/xml/Boy.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/access/xml/Boy.java @@ -17,11 +17,11 @@ */ package org.hibernate.test.annotations.access.xml; import java.util.Set; + +import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; -import org.hibernate.annotations.Entity; - /** * @author Hardy Ferentschik */ diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/backquotes/Bug.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/backquotes/Bug.java index 1b5732bf03cd..8f87065b0ab4 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/backquotes/Bug.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/backquotes/Bug.java @@ -1,15 +1,17 @@ //$Id$ package org.hibernate.test.annotations.backquotes; import java.util.List; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; +import javax.persistence.Index; import javax.persistence.JoinTable; import javax.persistence.ManyToMany; - -import org.hibernate.annotations.Index; +import javax.persistence.Table; @Entity +@Table(indexes = @Index(name="`titleindex`", columnList = "title")) public class Bug { @Id @@ -17,7 +19,6 @@ public class Bug private int id; @Column(name="`title`") - @Index(name="`titleindex`") private String title; @ManyToMany diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/cascade/CodedPairSetHolder.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/cascade/CodedPairSetHolder.java index bc5f74328ee3..89b9eac2fa17 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/cascade/CodedPairSetHolder.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/cascade/CodedPairSetHolder.java @@ -27,18 +27,17 @@ import java.util.Collections; import java.util.HashSet; import java.util.Set; + import javax.persistence.CollectionTable; import javax.persistence.Column; import javax.persistence.ElementCollection; import javax.persistence.Entity; +import javax.persistence.ForeignKey; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.JoinColumn; -import javax.persistence.JoinTable; import javax.persistence.Table; -import org.hibernate.annotations.ForeignKey; - @Entity @Table(name = "CODED_PAIR_SET_HOLDER") class CodedPairSetHolder implements Serializable { @@ -54,8 +53,8 @@ class CodedPairSetHolder implements Serializable { private String code; @ElementCollection - @CollectionTable(name = "CODED_PAIR_HOLDER_PAIR_SET", joinColumns = @JoinColumn(name = "CODED_PAIR_HOLDER_ID")) - @ForeignKey(name = "FK_PAIR_SET") + @CollectionTable(name = "CODED_PAIR_HOLDER_PAIR_SET", joinColumns = @JoinColumn(name = "CODED_PAIR_HOLDER_ID"), + foreignKey = @ForeignKey(name = "FK_PAIR_SET")) private final Set pairs = new HashSet(0); CodedPairSetHolder() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/cascade/PersonPair.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/cascade/PersonPair.java index 42a7cc1e158d..b58a7fdbf366 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/cascade/PersonPair.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/cascade/PersonPair.java @@ -24,27 +24,27 @@ package org.hibernate.test.annotations.cascade; import java.io.Serializable; + import javax.persistence.CascadeType; import javax.persistence.Embeddable; import javax.persistence.FetchType; +import javax.persistence.ForeignKey; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; -import org.hibernate.annotations.ForeignKey; - @Embeddable class PersonPair implements Serializable { private static final long serialVersionUID = 4543565503074112720L; @ManyToOne(optional = false, fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH }) - @JoinColumn(name = "LEFT_PERSON_ID", nullable = false, updatable = false) - @ForeignKey(name = "FK_LEFT_PERSON") + @JoinColumn(name = "LEFT_PERSON_ID", nullable = false, updatable = false, + foreignKey = @ForeignKey(name = "FK_LEFT_PERSON")) private Person left; @ManyToOne(optional = false, fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH }) - @JoinColumn(name = "RIGHT_PERSON_ID", nullable = false, updatable = false) - @ForeignKey(name = "FK_RIGHT_PERSON") + @JoinColumn(name = "RIGHT_PERSON_ID", nullable = false, updatable = false, + foreignKey = @ForeignKey(name = "FK_RIGHT_PERSON")) private Person right; PersonPair() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/collectionelement/Matrix.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/collectionelement/Matrix.java index 09a482845121..56f3593ac0ac 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/collectionelement/Matrix.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/collectionelement/Matrix.java @@ -3,6 +3,7 @@ import java.util.Map; import java.util.SortedMap; import java.util.TreeMap; + import javax.persistence.ElementCollection; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -10,8 +11,7 @@ import javax.persistence.MapKeyColumn; import org.hibernate.annotations.MapKeyType; -import org.hibernate.annotations.Sort; -import org.hibernate.annotations.SortType; +import org.hibernate.annotations.SortNatural; import org.hibernate.annotations.Type; /** @@ -25,7 +25,7 @@ public class Matrix { @MapKeyType( @Type(type="integer") ) @ElementCollection - @Sort(type = SortType.NATURAL) + @SortNatural @Type(type = "float") @MapKeyColumn(nullable = false) private SortedMap mvalues = new TreeMap(); diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/embedded/Country.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/embedded/Country.java index 61c81fb793e5..12ae5046e1e9 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/embedded/Country.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/embedded/Country.java @@ -1,10 +1,11 @@ //$Id$ package org.hibernate.test.annotations.embedded; import java.io.Serializable; + import javax.persistence.Column; import javax.persistence.Embeddable; -import org.hibernate.annotations.AccessType; +import org.hibernate.annotations.AttributeAccessor; /** * Non realistic embedded dependent object @@ -12,7 +13,7 @@ * @author Emmanuel Bernard */ @Embeddable -@AccessType("property") +@AttributeAccessor("property") public class Country implements Serializable { private String iso2; private String name; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/embedded/RegionalArticlePk.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/embedded/RegionalArticlePk.java index 8746d85ba7bb..4a4497cd6234 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/embedded/RegionalArticlePk.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/embedded/RegionalArticlePk.java @@ -1,9 +1,10 @@ //$Id$ package org.hibernate.test.annotations.embedded; import java.io.Serializable; + import javax.persistence.Embeddable; -import org.hibernate.annotations.AccessType; +import org.hibernate.annotations.AttributeAccessor; /** * Regional article pk @@ -11,7 +12,7 @@ * @author Emmanuel Bernard */ @Embeddable -@AccessType("field") +@AttributeAccessor("field") public class RegionalArticlePk implements Serializable { /** * country iso2 code diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/embedded/many2one/Address.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/embedded/many2one/Address.java index 45fb61962264..0020a720f449 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/embedded/many2one/Address.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/embedded/many2one/Address.java @@ -25,7 +25,7 @@ import javax.persistence.Embeddable; import javax.persistence.ManyToOne; -import org.hibernate.annotations.AccessType; +import org.hibernate.annotations.AttributeAccessor; /** * TODO : javadoc @@ -33,7 +33,7 @@ * @author Steve Ebersole */ @Embeddable -@AccessType("property") +@AttributeAccessor("property") public class Address { private String line1; private String line2; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/embedded/one2many/Alias.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/embedded/one2many/Alias.java index e3d2f9238644..ec968a1b493d 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/embedded/one2many/Alias.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/embedded/one2many/Alias.java @@ -22,11 +22,10 @@ * Boston, MA 02110-1301 USA */ package org.hibernate.test.annotations.embedded.one2many; +import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; -import org.hibernate.annotations.Entity; - /** * TODO : javadoc * diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/embedded/one2many/Name.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/embedded/one2many/Name.java index d4e7c152aa48..6d90b004420e 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/embedded/one2many/Name.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/embedded/one2many/Name.java @@ -24,7 +24,7 @@ package org.hibernate.test.annotations.embedded.one2many; import javax.persistence.Embeddable; -import org.hibernate.annotations.AccessType; +import org.hibernate.annotations.AttributeAccessor; /** * TODO : javadoc @@ -32,7 +32,7 @@ * @author Steve Ebersole */ @Embeddable -@AccessType("property") +@AttributeAccessor("property") public class Name { private String first; private String last; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/embedded/one2many/PersonName.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/embedded/one2many/PersonName.java index 943030a4836b..58240d7f7e70 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/embedded/one2many/PersonName.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/embedded/one2many/PersonName.java @@ -24,11 +24,12 @@ package org.hibernate.test.annotations.embedded.one2many; import java.util.HashSet; import java.util.Set; + import javax.persistence.CascadeType; import javax.persistence.Embeddable; import javax.persistence.OneToMany; -import org.hibernate.annotations.AccessType; +import org.hibernate.annotations.AttributeAccessor; /** * TODO : javadoc @@ -36,7 +37,7 @@ * @author Steve Ebersole */ @Embeddable -@AccessType("property") +@AttributeAccessor("property") public class PersonName extends Name { private Set aliases = new HashSet(); diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/entity/Forest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/entity/Forest.java index e3086ddc2173..c4b334f53d8b 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/entity/Forest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/entity/Forest.java @@ -1,22 +1,28 @@ //$Id$ package org.hibernate.test.annotations.entity; import java.util.Set; + import javax.persistence.ElementCollection; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; +import javax.persistence.Index; import javax.persistence.Lob; import org.hibernate.annotations.BatchSize; +import org.hibernate.annotations.DynamicInsert; +import org.hibernate.annotations.DynamicUpdate; import org.hibernate.annotations.Filter; import org.hibernate.annotations.FilterDef; import org.hibernate.annotations.Filters; -import org.hibernate.annotations.Index; import org.hibernate.annotations.OptimisticLock; import org.hibernate.annotations.OptimisticLockType; +import org.hibernate.annotations.OptimisticLocking; import org.hibernate.annotations.ParamDef; import org.hibernate.annotations.Parameter; +import org.hibernate.annotations.Polymorphism; import org.hibernate.annotations.PolymorphismType; +import org.hibernate.annotations.SelectBeforeUpdate; import org.hibernate.annotations.Type; import org.hibernate.annotations.Where; @@ -27,11 +33,11 @@ */ @Entity @BatchSize(size = 5) -@org.hibernate.annotations.Entity( - selectBeforeUpdate = true, - dynamicInsert = true, dynamicUpdate = true, - optimisticLock = OptimisticLockType.ALL, - polymorphism = PolymorphismType.EXPLICIT) +@SelectBeforeUpdate +@DynamicInsert +@DynamicUpdate +@OptimisticLocking(type = OptimisticLockType.ALL) +@Polymorphism(type = PolymorphismType.EXPLICIT) @Where(clause = "1=1") @FilterDef(name = "minLength", parameters = {@ParamDef(name = "minLength", type = "integer")}) @Filters({ @@ -39,7 +45,7 @@ @Filter(name = "minLength", condition = ":minLength <= length") }) @org.hibernate.annotations.Table(appliesTo = "Forest", - indexes = {@Index(name = "idx", columnNames = {"name", "length"})}) + indexes = {@Index(name = "idx", columnList = "name, length")}) public class Forest { private Integer id; private String name; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/entity/NewCustomEntityMappingAnnotationsTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/entity/NewCustomEntityMappingAnnotationsTest.java index acf79e82fc32..f12ad07a5486 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/entity/NewCustomEntityMappingAnnotationsTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/entity/NewCustomEntityMappingAnnotationsTest.java @@ -23,16 +23,11 @@ */ package org.hibernate.test.annotations.entity; -import org.hibernate.metamodel.spi.binding.EntityBinding; - -import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; -import org.junit.Test; +import static org.junit.Assert.assertEquals; import org.hibernate.metamodel.spi.binding.EntityBinding; -import org.hibernate.testing.FailureExpectedWithNewMetamodel; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; - -import static org.junit.Assert.assertEquals; +import org.junit.Test; /** * @author Steve Ebersole @@ -49,7 +44,6 @@ protected String[] getAnnotatedPackages() { } @Test - @FailureExpectedWithNewMetamodel public void testSameMappingValues() { EntityBinding forest = metadata().getEntityBinding( Forest.class.getName() ); EntityBinding forest2 = metadata().getEntityBinding( Forest2.class.getName() ); diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/entity/ZipCode.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/entity/ZipCode.java index 21f166100d47..db4ca18fa723 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/entity/ZipCode.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/entity/ZipCode.java @@ -5,13 +5,14 @@ import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; +import org.hibernate.annotations.Immutable; /** * @author Emmanuel Bernard */ @Cache(usage = CacheConcurrencyStrategy.READ_ONLY) @Entity -@org.hibernate.annotations.Entity(mutable = false) +@Immutable public class ZipCode { @Id public String code; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/indexcoll/Training.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/indexcoll/Training.java index b3932e97980b..43842ef4cc7c 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/indexcoll/Training.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/indexcoll/Training.java @@ -2,14 +2,14 @@ package org.hibernate.test.annotations.indexcoll; import java.util.SortedMap; import java.util.TreeMap; + import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.ManyToMany; import javax.persistence.MapKey; -import org.hibernate.annotations.Sort; -import org.hibernate.annotations.SortType; +import org.hibernate.annotations.SortNatural; /** * @author Emmanuel Bernard @@ -17,7 +17,7 @@ @Entity public class Training { @Id @GeneratedValue private Long id; - @Sort(type= SortType.NATURAL) + @SortNatural @MapKey(name="name") @ManyToMany SortedMap trainees = new TreeMap(); public Long getId() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Document.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Document.java index 8eab06736cc2..cdb3eba3b1e9 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Document.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/inheritance/joined/Document.java @@ -3,13 +3,10 @@ import javax.persistence.Column; import javax.persistence.Entity; -import org.hibernate.annotations.ForeignKey; - /** * @author Emmanuel Bernard */ @Entity -@ForeignKey(name = "FK_DOCU_FILE") public class Document extends File { @Column(nullable = false, name="xsize") private int size; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/join/Cat.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/join/Cat.java index d187e5ab4ae3..bddc4aa05460 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/join/Cat.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/join/Cat.java @@ -1,17 +1,18 @@ //$Id$ package org.hibernate.test.annotations.join; import java.io.Serializable; + import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.ForeignKey; import javax.persistence.GeneratedValue; import javax.persistence.Id; +import javax.persistence.Index; import javax.persistence.SecondaryTable; import javax.persistence.SecondaryTables; import javax.persistence.UniqueConstraint; import org.hibernate.annotations.FetchMode; -import org.hibernate.annotations.ForeignKey; -import org.hibernate.annotations.Index; import org.hibernate.annotations.SQLInsert; import org.hibernate.annotations.Table; import org.hibernate.annotations.Tables; @@ -25,11 +26,12 @@ @SecondaryTable(name = "Cat2", uniqueConstraints = {@UniqueConstraint(columnNames = {"storyPart2"})}) }) @Tables( { - @Table(appliesTo = "Cat", indexes = @Index(name = "secondname", - columnNames = "secondName"), comment = "My cat table" ), + @Table(comment = "My cat table", appliesTo = "Cat", indexes = { + @Index(name = "secondname", columnList = "secondName"), + @Index(name = "nameindex", columnList = "name"), + @Index(name = "story1index", columnList = "`Cat nbr1`")}), @Table(appliesTo = "Cat2", foreignKey = @ForeignKey(name="FK_CAT2_CAT"), fetch = FetchMode.SELECT, - sqlInsert=@SQLInsert(sql="insert into Cat2(storyPart2, id) values(upper(?), ?)") ) - } ) + sqlInsert=@SQLInsert(sql="insert into Cat2(storyPart2, id) values(upper(?), ?)"))}) public class Cat implements Serializable { private Integer id; @@ -44,7 +46,6 @@ public Integer getId() { return id; } - @Index(name = "nameindex") public String getName() { return name; } @@ -77,7 +78,6 @@ public void setSecondName(String secondName) { // } @Column(table = "`Cat nbr1`") - @Index(name = "story1index") public String getStoryPart1() { return storyPart1; } diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/manytomany/Woman.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/manytomany/Woman.java index bfb478ed9bfd..6808dd7bf14c 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/manytomany/Woman.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/manytomany/Woman.java @@ -2,15 +2,15 @@ package org.hibernate.test.annotations.manytomany; import java.io.Serializable; import java.util.Set; + import javax.persistence.CascadeType; import javax.persistence.Entity; +import javax.persistence.ForeignKey; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; import javax.persistence.ManyToMany; -import org.hibernate.annotations.ForeignKey; - /** * Woman knowing several mens * @@ -33,19 +33,16 @@ public void setCats(Set cats) { } @ManyToMany(cascade = {CascadeType.ALL}) - @JoinTable( - name = "Man_Woman", + @JoinTable(name = "Man_Woman", joinColumns = { - @JoinColumn(name = "womanLastName", referencedColumnName = "lastName"), - @JoinColumn(name = "womanFirstName", referencedColumnName = "firstName") - }, + @JoinColumn(name = "womanLastName", referencedColumnName = "lastName"), + @JoinColumn(name = "womanFirstName", referencedColumnName = "firstName") }, inverseJoinColumns = { - @JoinColumn(name = "manIsElder", referencedColumnName = "elder"), - @JoinColumn(name = "manLastName", referencedColumnName = "lastName"), - @JoinColumn(name = "manFirstName", referencedColumnName = "firstName") - } - ) - @ForeignKey(name = "WM_W_FK", inverseName = "WM_M_FK") + @JoinColumn(name = "manIsElder", referencedColumnName = "elder"), + @JoinColumn(name = "manLastName", referencedColumnName = "lastName"), + @JoinColumn(name = "manFirstName", referencedColumnName = "firstName") }, + foreignKey = @ForeignKey(name = "WM_W_FK"), + inverseForeignKey = @ForeignKey(name = "WM_M_FK")) public Set getMens() { return mens; } diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/manytoone/Car.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/manytoone/Car.java index d4bb2c9ab5a1..005be7049506 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/manytoone/Car.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/manytoone/Car.java @@ -2,12 +2,12 @@ package org.hibernate.test.annotations.manytoone; import javax.persistence.Entity; import javax.persistence.FetchType; +import javax.persistence.ForeignKey; import javax.persistence.GeneratedValue; import javax.persistence.Id; +import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; -import org.hibernate.annotations.ForeignKey; - /** * Many to one sample using default mapping values * @@ -30,7 +30,7 @@ public void setId(Integer id) { } @ManyToOne(fetch = FetchType.EAGER) - @ForeignKey(name="BODY_COLOR_FK") + @JoinColumn(foreignKey = @ForeignKey(name="BODY_COLOR_FK")) public Color getBodyColor() { return bodyColor; } diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/manytoone/ForestType.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/manytoone/ForestType.java index 3d14010efb4a..04457c426077 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/manytoone/ForestType.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/manytoone/ForestType.java @@ -1,7 +1,9 @@ //$Id$ package org.hibernate.test.annotations.manytoone; import java.util.Set; + import javax.persistence.Entity; +import javax.persistence.ForeignKey; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.JoinColumn; @@ -9,8 +11,6 @@ import javax.persistence.OneToMany; import javax.persistence.OneToOne; -import org.hibernate.annotations.ForeignKey; - /** * @author Emmanuel Bernard */ @@ -24,10 +24,9 @@ public class ForestType { @OneToOne @JoinTable(name="BiggestRepPerForestType", joinColumns = @JoinColumn(name="forest_type"), - inverseJoinColumns = @JoinColumn(name="forest") - ) - @ForeignKey(name="A_TYP_FK", - inverseName = "A_FOR_FK" //inverse fail cause it involves a Join + inverseJoinColumns = @JoinColumn(name="forest"), + foreignKey = @ForeignKey(name="A_TYP_FK"), + inverseForeignKey = @ForeignKey(name="A_FOR_FK") //inverse fail cause it involves a Join ) public BiggestForest getBiggestRepresentative() { return biggestRepresentative; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/onetomany/City.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/onetomany/City.java index b03aba307182..79b2b51d6ca6 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/onetomany/City.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/onetomany/City.java @@ -2,15 +2,15 @@ package org.hibernate.test.annotations.onetomany; import java.util.ArrayList; import java.util.List; + import javax.persistence.Entity; -import javax.persistence.FetchType; +import javax.persistence.ForeignKey; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.OneToMany; import javax.persistence.OrderBy; -import org.hibernate.annotations.ForeignKey; import org.hibernate.annotations.Immutable; /** @@ -52,8 +52,7 @@ public void setStreets(List streets) { } @OneToMany - @JoinColumn(name = "mainstreetcity_id") - @ForeignKey(name = "CITYSTR_FK") + @JoinColumn(name = "mainstreetcity_id", foreignKey = @ForeignKey(name = "CITYSTR_FK")) @OrderBy @Immutable public List getMainStreets() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/onetomany/Trainer.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/onetomany/Trainer.java index fbc08e76c570..fe0e615af6a1 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/onetomany/Trainer.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/onetomany/Trainer.java @@ -1,15 +1,15 @@ //$Id$ package org.hibernate.test.annotations.onetomany; import java.util.Set; + import javax.persistence.Entity; +import javax.persistence.ForeignKey; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; import javax.persistence.OneToMany; -import org.hibernate.annotations.ForeignKey; - /** * Unidirectional one to many sample * @@ -54,9 +54,10 @@ public void setTrainedTigers(Set trainedTigers) { name = "TrainedMonkeys", //columns are optional, here we explicit them joinColumns = @JoinColumn(name = "trainer_id"), - inverseJoinColumns = @JoinColumn(name = "monkey_id") + inverseJoinColumns = @JoinColumn(name = "monkey_id"), + foreignKey = @ForeignKey(name = "TM_TRA_FK"), + inverseForeignKey = @ForeignKey(name = "TM_MON_FK") ) - @ForeignKey(name = "TM_TRA_FK", inverseName = "TM_MON_FK") public Set getTrainedMonkeys() { return trainedMonkeys; } diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/onetomany/Troop.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/onetomany/Troop.java index fb985a7d958b..ddf2f1745b87 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/onetomany/Troop.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/onetomany/Troop.java @@ -2,6 +2,7 @@ package org.hibernate.test.annotations.onetomany; import java.util.HashSet; import java.util.Set; + import javax.persistence.CascadeType; import javax.persistence.Entity; import javax.persistence.FetchType; @@ -24,9 +25,8 @@ public class Troop { private String name; private Set soldiers; - @OneToMany(mappedBy = "troop", cascade = {CascadeType.ALL}, fetch = FetchType.LAZY) + @OneToMany(mappedBy = "troop", cascade = {CascadeType.ALL}, fetch = FetchType.LAZY, orphanRemoval = true) @OrderBy(clause = "name desc") - @org.hibernate.annotations.Cascade(org.hibernate.annotations.CascadeType.DELETE_ORPHAN) @OnDelete(action = OnDeleteAction.CASCADE) public Set getSoldiers() { return soldiers; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/persister/Card.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/persister/Card.java index 5d832a7e9515..c8ab16365e29 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/persister/Card.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/persister/Card.java @@ -1,15 +1,18 @@ package org.hibernate.test.annotations.persister; import java.io.Serializable; + import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; +import org.hibernate.annotations.Persister; + /** * @author Shawn Clowater */ @Entity -@org.hibernate.annotations.Entity( persister = "org.hibernate.persister.entity.SingleTableEntityPersister" ) +@Persister(impl = org.hibernate.persister.entity.SingleTableEntityPersister.class) public class Card implements Serializable { @Id public Integer id; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/persister/Deck.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/persister/Deck.java index 8d5a29382bc4..3264e67d5788 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/persister/Deck.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/persister/Deck.java @@ -1,6 +1,7 @@ package org.hibernate.test.annotations.persister; import java.io.Serializable; import java.util.Set; + import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.OneToMany; @@ -12,7 +13,6 @@ * @author Shawn Clowater */ @Entity -@org.hibernate.annotations.Entity( persister = "org.hibernate.persister.entity.SingleTableEntityPersister" ) @Persister( impl = org.hibernate.test.annotations.persister.EntityPersister.class ) public class Deck implements Serializable { @Id diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/persister/PersisterTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/persister/PersisterTest.java index f33663cdc7eb..7eb3c23b5d11 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/persister/PersisterTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/persister/PersisterTest.java @@ -23,15 +23,14 @@ */ package org.hibernate.test.annotations.persister; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.hibernate.metamodel.spi.binding.PluralAttributeBinding; import org.hibernate.persister.entity.SingleTableEntityPersister; -import org.hibernate.testing.FailureExpectedWithNewMetamodel; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - /** * @author Shawn Clowater */ @@ -46,7 +45,6 @@ public void testEntityEntityPersisterAndPersisterSpecified() throws Exception { } @Test - @FailureExpectedWithNewMetamodel public void testEntityEntityPersisterSpecified() throws Exception { //tests the persister specified with an @Entity.persister() Class clazz = diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/polymorphism/Car.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/polymorphism/Car.java index e9c31007134d..88aad34c41d1 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/polymorphism/Car.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/polymorphism/Car.java @@ -8,6 +8,7 @@ import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; +import org.hibernate.annotations.Polymorphism; import org.hibernate.annotations.PolymorphismType; /** @@ -15,7 +16,7 @@ */ @Entity @Inheritance(strategy= InheritanceType.TABLE_PER_CLASS) -@org.hibernate.annotations.Entity(polymorphism = PolymorphismType.EXPLICIT) +@Polymorphism(type = PolymorphismType.EXPLICIT) public class Car extends Automobile { @Id diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/polymorphism/PolymorphismTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/polymorphism/PolymorphismTest.java index e80b9fc7d8c0..acd2cb9a2d1f 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/polymorphism/PolymorphismTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/polymorphism/PolymorphismTest.java @@ -27,7 +27,6 @@ import org.hibernate.Session; import org.hibernate.Transaction; -import org.hibernate.testing.FailureExpectedWithNewMetamodel; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.junit.Test; @@ -39,7 +38,6 @@ public class PolymorphismTest extends BaseCoreFunctionalTestCase { @Test - @FailureExpectedWithNewMetamodel public void testPolymorphism() throws Exception { Car car = new Car(); car.setModel( "SUV" ); diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/polymorphism/SportCar.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/polymorphism/SportCar.java index 5e25658abf63..2bd5366761dc 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/polymorphism/SportCar.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/polymorphism/SportCar.java @@ -3,6 +3,7 @@ import javax.persistence.Entity; import javax.persistence.Table; +import org.hibernate.annotations.Polymorphism; import org.hibernate.annotations.PolymorphismType; /** @@ -10,6 +11,6 @@ */ @Entity @Table(name = "sport_car") -@org.hibernate.annotations.Entity(polymorphism = PolymorphismType.EXPLICIT) //raise a warn +@Polymorphism(type = PolymorphismType.EXPLICIT) //raise a warn public class SportCar extends Car { } diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/strategy/Storm.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/strategy/Storm.java index 9f404e4e0603..f20a11299de3 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/strategy/Storm.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/strategy/Storm.java @@ -5,18 +5,16 @@ import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; +import javax.persistence.Index; import javax.persistence.Table; import javax.persistence.UniqueConstraint; -import org.hibernate.annotations.Index; -import org.hibernate.testing.FailureExpectedWithNewMetamodel; - /** * @author Emmanuel Bernard */ @Entity -@FailureExpectedWithNewMetamodel -@Table(uniqueConstraints = {@UniqueConstraint(columnNames = {"start.country", "start.city"})}) +@Table(uniqueConstraints = @UniqueConstraint(columnNames = {"start.country", "start.city"}), + indexes = @Index(name="storm_name_idx", columnList = "stormName")) public class Storm { private Integer id; private Location start; @@ -51,7 +49,6 @@ public void setEnd(Location end) { this.end = end; } - @Index(name="storm_name_idx") @Column(unique = true) public String getStormName() { return stormName; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/tableperclass/Component.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/tableperclass/Component.java index 776647757fc1..d8be2baa7020 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/tableperclass/Component.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/tableperclass/Component.java @@ -3,16 +3,17 @@ import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; +import javax.persistence.Index; import javax.persistence.Inheritance; import javax.persistence.InheritanceType; - -import org.hibernate.annotations.Index; +import javax.persistence.Table; /** * @author Emmanuel Bernard */ @Entity(name = "xpmComponent") @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) +@Table(indexes = @Index(name = "manufacturerPartNumber", columnList = "manufacturerPartNumber")) public abstract class Component { private String manufacturerPartNumber; private Long manufacturerId; @@ -31,7 +32,6 @@ public Long getId() { } @Column(nullable = false) - @Index(name = "manufacturerPartNumber") public String getManufacturerPartNumber() { return manufacturerPartNumber; } diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/various/Conductor.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/various/Conductor.java index d29877ea8006..aa65d6e0e771 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/various/Conductor.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/various/Conductor.java @@ -4,22 +4,23 @@ import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; +import javax.persistence.Index; +import javax.persistence.Table; import javax.persistence.Version; -import org.hibernate.annotations.Index; import org.hibernate.annotations.OptimisticLock; /** * @author Emmanuel Bernard */ @Entity +@Table(indexes = @Index(name = "cond_name", columnList = "cond_name")) public class Conductor { @Id @GeneratedValue private Integer id; @Column(name = "cond_name") - @Index(name = "cond_name") @OptimisticLock(excluded = true) private String name; diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/various/Truck.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/various/Truck.java index 8c8f530ed50b..48abeee32041 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/various/Truck.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/various/Truck.java @@ -1,22 +1,23 @@ //$Id$ package org.hibernate.test.annotations.various; import javax.persistence.Entity; +import javax.persistence.Index; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; - -import org.hibernate.annotations.Index; +import javax.persistence.Table; /** * @author Emmanuel Bernard */ @Entity +@Table(indexes = { + @Index(name = "weigth_idx", columnList = "weight"), + @Index(name = "agreement_idx", columnList = "agreement_id")}) public class Truck extends Vehicule { - @Index(name = "weigth_idx") private int weight; @ManyToOne @JoinColumn(name = "agreement_id") - @Index(name = "agreement_idx") private ProfessionalAgreement agreement; public int getWeight() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/various/Vehicule.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/various/Vehicule.java index 0dca01802509..5c4a2a50b0c4 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/various/Vehicule.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/various/Vehicule.java @@ -4,25 +4,26 @@ import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; +import javax.persistence.Index; import javax.persistence.Inheritance; import javax.persistence.InheritanceType; import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import org.hibernate.annotations.GenericGenerator; -import org.hibernate.annotations.Index; +import org.hibernate.annotations.Table; /** * @author Emmanuel Bernard */ @Entity @Inheritance(strategy = InheritanceType.JOINED) -@org.hibernate.annotations.Table(appliesTo = "Vehicule", - indexes = { - @Index(name = "improbableindex", columnNames = {"registration", "Conductor_fk"}), - @Index(name = "secondone", columnNames = {"Conductor_fk"}) - } -) +@Table(appliesTo = "Vehicule", indexes = { + @Index(name = "improbableindex", columnList = "registration, Conductor_fk"), + @Index(name = "secondone", columnList = "Conductor_fk"), + @Index(name = "thirdone", columnList = "Conductor_fk"), + @Index(name = "year_idx", columnList = "year"), + @Index(name = "forthone", columnList = "previousConductor")}) public class Vehicule { @Id @GeneratedValue(generator = "gen") @@ -32,12 +33,9 @@ public class Vehicule { private String registrationNumber; @ManyToOne(optional = false) @JoinColumn(name = "Conductor_fk") - @Index(name = "thirdone") private Conductor currentConductor; - @Index(name = "year_idx") private Integer year; @ManyToOne(optional = true) - @Index(name = "forthone") private Conductor previousConductor; public String getId() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/constraint/ConstraintTest.java b/hibernate-core/src/test/java/org/hibernate/test/constraint/ConstraintTest.java index 6168ea565221..451aacdfda48 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/constraint/ConstraintTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/constraint/ConstraintTest.java @@ -56,18 +56,16 @@ public class ConstraintTest extends BaseCoreFunctionalTestCase { private static final String EXPLICIT_UK_NAME = "EXPLICIT_UK_NAME"; - private static final String EXPLICIT_COLUMN_NAME_NATIVE = "EXPLICIT_COLUMN_NAME_NATIVE"; - private static final String EXPLICIT_FK_NAME_NATIVE = "EXPLICIT_FK_NAME_NATIVE"; - private static final String EXPLICIT_COLUMN_NAME_JPA_O2O = "EXPLICIT_COLUMN_NAME_JPA_O2O"; - private static final String EXPLICIT_FK_NAME_JPA_O2O = "EXPLICIT_FK_NAME_JPA_O2O"; - private static final String EXPLICIT_COLUMN_NAME_JPA_M2O = "EXPLICIT_COLUMN_NAME_JPA_M2O"; - private static final String EXPLICIT_FK_NAME_JPA_M2O = "EXPLICIT_FK_NAME_JPA_M2O"; - private static final String EXPLICIT_JOINTABLE_NAME_JPA_M2M = "EXPLICIT_JOINTABLE_NAME_JPA_M2M"; - private static final String EXPLICIT_COLUMN_NAME_JPA_M2M = "EXPLICIT_COLUMN_NAME_JPA_M2M"; - private static final String EXPLICIT_FK_NAME_JPA_M2M = "EXPLICIT_FK_NAME_JPA_M2M"; - private static final String EXPLICIT_COLLECTIONTABLE_NAME_JPA_ELEMENT = "EXPLICIT_COLLECTIONTABLE_NAME_JPA_ELEMENT"; - private static final String EXPLICIT_COLUMN_NAME_JPA_ELEMENT = "EXPLICIT_COLUMN_NAME_JPA_ELEMENT"; - private static final String EXPLICIT_FK_NAME_JPA_ELEMENT = "EXPLICIT_FK_NAME_JPA_ELEMENT"; + private static final String EXPLICIT_COLUMN_NAME_O2O = "EXPLICIT_COLUMN_NAME_O2O"; + private static final String EXPLICIT_FK_NAME_O2O = "EXPLICIT_FK_NAME_O2O"; + private static final String EXPLICIT_COLUMN_NAME_M2O = "EXPLICIT_COLUMN_NAME_M2O"; + private static final String EXPLICIT_FK_NAME_M2O = "EXPLICIT_FK_NAME_M2O"; + private static final String EXPLICIT_JOINTABLE_NAME_M2M = "EXPLICIT_JOINTABLE_NAME_M2M"; + private static final String EXPLICIT_COLUMN_NAME_M2M = "EXPLICIT_COLUMN_NAME_M2M"; + private static final String EXPLICIT_FK_NAME_M2M = "EXPLICIT_FK_NAME_M2M"; + private static final String EXPLICIT_COLLECTIONTABLE_NAME_ELEMENT = "EXPLICIT_COLLECTIONTABLE_NAME_ELEMENT"; + private static final String EXPLICIT_COLUMN_NAME_ELEMENT = "EXPLICIT_COLUMN_NAME_ELEMENT"; + private static final String EXPLICIT_FK_NAME_ELEMENT = "EXPLICIT_FK_NAME_ELEMENT"; private static final String INDEX_1 = "INDEX_1"; private static final String INDEX_2 = "INDEX_2"; private static final String INDEX_3 = "INDEX_3"; @@ -121,13 +119,12 @@ public void testConstraintNames() { assertTrue( SchemaUtil.hasUniqueKey( table1, EXPLICIT_UK_NAME, "explicit" ) ); TableSpecification table2 = SchemaUtil.getTable( DataPoint2.class, metadata() ); - TableSpecification joinTable = SchemaUtil.getTable( EXPLICIT_JOINTABLE_NAME_JPA_M2M, metadata() ); - TableSpecification collectionTable = SchemaUtil.getTable( EXPLICIT_COLLECTIONTABLE_NAME_JPA_ELEMENT, metadata() ); - assertTrue( SchemaUtil.hasForeignKey( table2, EXPLICIT_FK_NAME_NATIVE, EXPLICIT_COLUMN_NAME_NATIVE ) ); - assertTrue( SchemaUtil.hasForeignKey( table2, EXPLICIT_FK_NAME_JPA_O2O, EXPLICIT_COLUMN_NAME_JPA_O2O ) ); - assertTrue( SchemaUtil.hasForeignKey( table2, EXPLICIT_FK_NAME_JPA_M2O, EXPLICIT_COLUMN_NAME_JPA_M2O ) ); - assertTrue( SchemaUtil.hasForeignKey( joinTable, EXPLICIT_FK_NAME_JPA_M2M, EXPLICIT_COLUMN_NAME_JPA_M2M ) ); - assertTrue( SchemaUtil.hasForeignKey( collectionTable, EXPLICIT_FK_NAME_JPA_ELEMENT, EXPLICIT_COLUMN_NAME_JPA_ELEMENT ) ); + TableSpecification joinTable = SchemaUtil.getTable( EXPLICIT_JOINTABLE_NAME_M2M, metadata() ); + TableSpecification collectionTable = SchemaUtil.getTable( EXPLICIT_COLLECTIONTABLE_NAME_ELEMENT, metadata() ); + assertTrue( SchemaUtil.hasForeignKey( table2, EXPLICIT_FK_NAME_O2O, EXPLICIT_COLUMN_NAME_O2O ) ); + assertTrue( SchemaUtil.hasForeignKey( table2, EXPLICIT_FK_NAME_M2O, EXPLICIT_COLUMN_NAME_M2O ) ); + assertTrue( SchemaUtil.hasForeignKey( joinTable, EXPLICIT_FK_NAME_M2M, EXPLICIT_COLUMN_NAME_M2M ) ); + assertTrue( SchemaUtil.hasForeignKey( collectionTable, EXPLICIT_FK_NAME_ELEMENT, EXPLICIT_COLUMN_NAME_ELEMENT ) ); testConstraintLength( table1 ); testConstraintLength( table2 ); @@ -184,31 +181,26 @@ private static class DataPoint2 { public DataPoint dp; @OneToOne - @org.hibernate.annotations.ForeignKey(name = EXPLICIT_FK_NAME_NATIVE) - @JoinColumn(name = EXPLICIT_COLUMN_NAME_NATIVE) - public DataPoint explicit_native; - - @OneToOne - @JoinColumn(name = EXPLICIT_COLUMN_NAME_JPA_O2O, - foreignKey = @javax.persistence.ForeignKey(name = EXPLICIT_FK_NAME_JPA_O2O)) - public DataPoint explicit_jpa_o2o; + @JoinColumn(name = EXPLICIT_COLUMN_NAME_O2O, + foreignKey = @javax.persistence.ForeignKey(name = EXPLICIT_FK_NAME_O2O)) + public DataPoint explicit_o2o; @ManyToOne - @JoinColumn(name = EXPLICIT_COLUMN_NAME_JPA_M2O, - foreignKey = @javax.persistence.ForeignKey(name = EXPLICIT_FK_NAME_JPA_M2O)) - public DataPoint explicit_jpa_m2o; + @JoinColumn(name = EXPLICIT_COLUMN_NAME_M2O, + foreignKey = @javax.persistence.ForeignKey(name = EXPLICIT_FK_NAME_M2O)) + public DataPoint explicit_m2o; @ManyToMany - @JoinTable(name = EXPLICIT_JOINTABLE_NAME_JPA_M2M, - joinColumns = @JoinColumn(name = EXPLICIT_COLUMN_NAME_JPA_M2M), - foreignKey = @javax.persistence.ForeignKey(name = EXPLICIT_FK_NAME_JPA_M2M)) - public Set explicit_jpa_m2m; + @JoinTable(name = EXPLICIT_JOINTABLE_NAME_M2M, + joinColumns = @JoinColumn(name = EXPLICIT_COLUMN_NAME_M2M), + foreignKey = @javax.persistence.ForeignKey(name = EXPLICIT_FK_NAME_M2M)) + public Set explicit_m2m; @ElementCollection - @CollectionTable(name = EXPLICIT_COLLECTIONTABLE_NAME_JPA_ELEMENT, - joinColumns = @JoinColumn(name = EXPLICIT_COLUMN_NAME_JPA_ELEMENT), - foreignKey = @javax.persistence.ForeignKey(name = EXPLICIT_FK_NAME_JPA_ELEMENT)) - public Set explicit_jpa_element; + @CollectionTable(name = EXPLICIT_COLLECTIONTABLE_NAME_ELEMENT, + joinColumns = @JoinColumn(name = EXPLICIT_COLUMN_NAME_ELEMENT), + foreignKey = @javax.persistence.ForeignKey(name = EXPLICIT_FK_NAME_ELEMENT)) + public Set explicit_element; } public static enum SimpleEnum { diff --git a/hibernate-core/src/test/java/org/hibernate/test/event/collection/detached/MultipleCollectionRefEntity1.java b/hibernate-core/src/test/java/org/hibernate/test/event/collection/detached/MultipleCollectionRefEntity1.java index a7e82862fd47..d70a4a5ec21d 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/event/collection/detached/MultipleCollectionRefEntity1.java +++ b/hibernate-core/src/test/java/org/hibernate/test/event/collection/detached/MultipleCollectionRefEntity1.java @@ -25,6 +25,7 @@ import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.ForeignKey; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; @@ -43,8 +44,8 @@ public class MultipleCollectionRefEntity1 implements org.hibernate.test.event.co private String text; @ManyToOne - @JoinColumn(name = "MCE_ID", nullable = false, insertable = false, updatable = false) - @org.hibernate.annotations.ForeignKey(name = "FK_RE1_MCE") + @JoinColumn(name = "MCE_ID", nullable = false, insertable = false, updatable = false, + foreignKey = @ForeignKey(name = "FK_RE1_MCE")) private MultipleCollectionEntity multipleCollectionEntity; @Column(name = "MCE_ID", insertable = false, updatable = false) diff --git a/hibernate-core/src/test/java/org/hibernate/test/event/collection/detached/MultipleCollectionRefEntity2.java b/hibernate-core/src/test/java/org/hibernate/test/event/collection/detached/MultipleCollectionRefEntity2.java index eafb2ab82f1e..d9f77d30afab 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/event/collection/detached/MultipleCollectionRefEntity2.java +++ b/hibernate-core/src/test/java/org/hibernate/test/event/collection/detached/MultipleCollectionRefEntity2.java @@ -25,6 +25,7 @@ import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.ForeignKey; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; @@ -43,8 +44,8 @@ public class MultipleCollectionRefEntity2 implements org.hibernate.test.event.co private String text; @ManyToOne - @JoinColumn(name = "MCE_ID", nullable = false, insertable = false, updatable = false) - @org.hibernate.annotations.ForeignKey(name = "FK_RE2_MCE") + @JoinColumn(name = "MCE_ID", nullable = false, insertable = false, updatable = false, + foreignKey = @ForeignKey(name = "FK_RE2_MCE")) private MultipleCollectionEntity multipleCollectionEntity; @Column(name = "MCE_ID", insertable = false, updatable = false) diff --git a/hibernate-core/src/test/java/org/hibernate/test/propertyref/DoesNotWork.java b/hibernate-core/src/test/java/org/hibernate/test/propertyref/DoesNotWork.java index 60aa29b906fe..403b23b3404d 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/propertyref/DoesNotWork.java +++ b/hibernate-core/src/test/java/org/hibernate/test/propertyref/DoesNotWork.java @@ -23,20 +23,19 @@ */ package org.hibernate.test.propertyref; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + import javax.persistence.CollectionTable; import javax.persistence.Column; import javax.persistence.ElementCollection; import javax.persistence.EmbeddedId; import javax.persistence.Entity; import javax.persistence.JoinColumn; -import javax.persistence.JoinTable; import javax.persistence.OrderColumn; import javax.persistence.Table; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; -import org.hibernate.annotations.IndexColumn; import org.hibernate.annotations.ListIndexBase; /**