From f4cc72b2d3fb968cf460ffe56a7c3abef9bd8882 Mon Sep 17 00:00:00 2001 From: Hardy Ferentschik Date: Mon, 27 Jun 2011 14:03:39 +0200 Subject: [PATCH] Revert "HHH-6368 remove deprecated hibernate annotations" This reverts commit 5781948ab28ea2ae4fab11814d3638c0d40e0782. Re-adding the removed annotations since they are still used. --- .../annotations/CollectionOfElements.java | 50 ++++++++++++++++ .../annotations/ForceDiscriminator.java | 40 +++++++++++++ .../org/hibernate/annotations/MapKey.java | 57 +++++++++++++++++++ .../annotations/MapKeyManyToMany.java | 51 +++++++++++++++++ 4 files changed, 198 insertions(+) create mode 100644 hibernate-core/src/main/java/org/hibernate/annotations/CollectionOfElements.java create mode 100644 hibernate-core/src/main/java/org/hibernate/annotations/ForceDiscriminator.java create mode 100644 hibernate-core/src/main/java/org/hibernate/annotations/MapKey.java create mode 100644 hibernate-core/src/main/java/org/hibernate/annotations/MapKeyManyToMany.java diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/CollectionOfElements.java b/hibernate-core/src/main/java/org/hibernate/annotations/CollectionOfElements.java new file mode 100644 index 0000000000..e967b364ab --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/annotations/CollectionOfElements.java @@ -0,0 +1,50 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2010, Red Hat Inc. or third-party contributors as + * indicated by the @author tags or express copyright attribution + * statements applied by the authors. All third-party contributions are + * distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ +package org.hibernate.annotations; +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; +import javax.persistence.FetchType; + +/** + * Annotation used to mark a collection as a collection of elements or + * a collection of embedded objects + * + * @deprecated use @ElementCollection + * @author Emmanuel Bernard + */ +@Target({METHOD, FIELD}) +@Retention(RUNTIME) +@Deprecated +public @interface CollectionOfElements { + /** + * Represent the element class in the collection + * Only useful if the collection does not use generics + */ + Class targetElement() default void.class; + + FetchType fetch() default FetchType.LAZY; +} diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/ForceDiscriminator.java b/hibernate-core/src/main/java/org/hibernate/annotations/ForceDiscriminator.java new file mode 100644 index 0000000000..ec9c7c3e3b --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/annotations/ForceDiscriminator.java @@ -0,0 +1,40 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2010, Red Hat Inc. or third-party contributors as + * indicated by the @author tags or express copyright attribution + * statements applied by the authors. All third-party contributions are + * distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ +package org.hibernate.annotations; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * ForceDiscriminator flag + * To be placed at the root entity near @DiscriminatorColumn or @DiscriminatorFormula + * + * @author Serg Prasolov + * @deprecated use {@link org.hibernate.annotations.DiscriminatorOptions} instead + */ +@Target({ ElementType.TYPE }) +@Retention(RetentionPolicy.RUNTIME) +public @interface ForceDiscriminator { +} diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/MapKey.java b/hibernate-core/src/main/java/org/hibernate/annotations/MapKey.java new file mode 100644 index 0000000000..271119ba31 --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/annotations/MapKey.java @@ -0,0 +1,57 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2010, Red Hat Inc. or third-party contributors as + * indicated by the @author tags or express copyright attribution + * statements applied by the authors. All third-party contributions are + * distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ +package org.hibernate.annotations; +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.RetentionPolicy.RUNTIME; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; +import javax.persistence.Column; + +/** + * Define the map key columns as an explicit column holding the map key + * This is completely different from {@link javax.persistence.MapKey} which use an existing column + * This annotation and {@link javax.persistence.MapKey} are mutually exclusive + * + * @deprecated Use {@link javax.persistence.MapKeyColumn} + * This is the default behavior for Map properties marked as @OneToMany, @ManyToMany + * or @ElementCollection + * @author Emmanuel Bernard + */ +@Target({METHOD, FIELD}) +@Retention(RUNTIME) +@Deprecated +public @interface MapKey { + Column[] columns() default {}; + /** + * Represent the key class in a Map + * Only useful if the collection does not use generics + */ + Class targetElement() default void.class; + + /** + * The optional map key type. Guessed if default + */ + Type type() default @Type(type = ""); +} diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/MapKeyManyToMany.java b/hibernate-core/src/main/java/org/hibernate/annotations/MapKeyManyToMany.java new file mode 100644 index 0000000000..b3582e65f7 --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/annotations/MapKeyManyToMany.java @@ -0,0 +1,51 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2010, Red Hat Inc. or third-party contributors as + * indicated by the @author tags or express copyright attribution + * statements applied by the authors. All third-party contributions are + * distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ +package org.hibernate.annotations; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import javax.persistence.JoinColumn; + +/** + * Define the map key columns as an explicit column holding the map key + * This is completely different from {@link javax.persistence.MapKey} which use an existing column + * This annotation and {@link javax.persistence.MapKey} are mutually exclusive + * + * @deprecated Use {@link javax.persistence.MapKeyJoinColumn} {@link javax.persistence.MapKeyJoinColumns} + * This is the default behavior for Map properties marked as @OneToMany, @ManyToMany + * or @ElementCollection + * @author Emmanuel Bernard + */ +@Target({ElementType.METHOD, ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +@Deprecated +public @interface MapKeyManyToMany { + JoinColumn[] joinColumns() default {}; + /** + * Represent the key class in a Map + * Only useful if the collection does not use generics + */ + Class targetEntity() default void.class; +}