remove deprecated @Entity annotation
This commit is contained in:
parent
50363dcc2c
commit
3b3487a74e
|
@ -773,11 +773,6 @@ See the <<chapters/pc/PersistenceContext.adoc#pc-managed-state-dynamic-update,`@
|
|||
For reattachment of detached entities, the dynamic update is not possible without having the <<annotations-hibernate-selectbeforeupdate>> annotation as well.
|
||||
====
|
||||
|
||||
[[annotations-hibernate-entity]]
|
||||
==== [line-through]#`@Entity`#
|
||||
|
||||
The https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/annotations/Entity.html[[line-through]#`@Entity`#] annotation is deprecated. Use the JPA <<annotations-jpa-entity>> annotation instead.
|
||||
|
||||
[[annotations-hibernate-fetch]]
|
||||
==== `@Fetch`
|
||||
|
||||
|
|
|
@ -1,69 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
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 "";
|
||||
}
|
|
@ -605,12 +605,8 @@ public final class AnnotationBinder {
|
|||
|
||||
PersistentClass persistentClass = makePersistentClass( inheritanceState, superEntity, context );
|
||||
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,
|
||||
context
|
||||
|
@ -1346,10 +1342,6 @@ public final class AnnotationBinder {
|
|||
|| 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -117,7 +117,6 @@ public class EntityBinder {
|
|||
private Boolean insertableDiscriminator;
|
||||
private boolean dynamicInsert;
|
||||
private boolean dynamicUpdate;
|
||||
private boolean explicitHibernateEntityAnnotation;
|
||||
private OptimisticLockType optimisticLockType;
|
||||
private PolymorphismType polymorphismType;
|
||||
private boolean selectBeforeUpdate;
|
||||
|
@ -154,7 +153,6 @@ public class EntityBinder {
|
|||
|
||||
public EntityBinder(
|
||||
Entity ejb3Ann,
|
||||
org.hibernate.annotations.Entity hibAnn,
|
||||
XClass annotatedClass,
|
||||
PersistentClass persistentClass,
|
||||
MetadataBuildingContext context) {
|
||||
|
@ -162,7 +160,7 @@ public class EntityBinder {
|
|||
this.persistentClass = persistentClass;
|
||||
this.annotatedClass = annotatedClass;
|
||||
bindEjb3Annotation( ejb3Ann );
|
||||
bindHibernateAnnotation( hibAnn );
|
||||
bindHibernateAnnotation();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -184,47 +182,41 @@ public class EntityBinder {
|
|||
}
|
||||
|
||||
@SuppressWarnings("SimplifiableConditionalExpression")
|
||||
private void bindHibernateAnnotation(org.hibernate.annotations.Entity hibAnn) {
|
||||
private void bindHibernateAnnotation() {
|
||||
{
|
||||
final DynamicInsert dynamicInsertAnn = annotatedClass.getAnnotation( DynamicInsert.class );
|
||||
this.dynamicInsert = dynamicInsertAnn == null
|
||||
? ( hibAnn == null ? false : hibAnn.dynamicInsert() )
|
||||
? false
|
||||
: dynamicInsertAnn.value();
|
||||
}
|
||||
|
||||
{
|
||||
final DynamicUpdate dynamicUpdateAnn = annotatedClass.getAnnotation( DynamicUpdate.class );
|
||||
this.dynamicUpdate = dynamicUpdateAnn == null
|
||||
? ( hibAnn == null ? false : hibAnn.dynamicUpdate() )
|
||||
? false
|
||||
: dynamicUpdateAnn.value();
|
||||
}
|
||||
|
||||
{
|
||||
final SelectBeforeUpdate selectBeforeUpdateAnn = annotatedClass.getAnnotation( SelectBeforeUpdate.class );
|
||||
this.selectBeforeUpdate = selectBeforeUpdateAnn == null
|
||||
? ( hibAnn == null ? false : hibAnn.selectBeforeUpdate() )
|
||||
? false
|
||||
: selectBeforeUpdateAnn.value();
|
||||
}
|
||||
|
||||
{
|
||||
final OptimisticLocking optimisticLockingAnn = annotatedClass.getAnnotation( OptimisticLocking.class );
|
||||
this.optimisticLockType = optimisticLockingAnn == null
|
||||
? ( hibAnn == null ? OptimisticLockType.VERSION : hibAnn.optimisticLock() )
|
||||
? OptimisticLockType.VERSION
|
||||
: optimisticLockingAnn.type();
|
||||
}
|
||||
|
||||
{
|
||||
final Polymorphism polymorphismAnn = annotatedClass.getAnnotation( Polymorphism.class );
|
||||
this.polymorphismType = polymorphismAnn == null
|
||||
? ( hibAnn == null ? PolymorphismType.IMPLICIT : hibAnn.polymorphism() )
|
||||
? PolymorphismType.IMPLICIT
|
||||
: polymorphismAnn.type();
|
||||
}
|
||||
|
||||
if ( hibAnn != null ) {
|
||||
// used later in bind for logging
|
||||
explicitHibernateEntityAnnotation = true;
|
||||
//persister handled in bind
|
||||
}
|
||||
}
|
||||
|
||||
private void bindEjb3Annotation(Entity ejb3Ann) {
|
||||
|
@ -276,13 +268,7 @@ public class EntityBinder {
|
|||
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 ) );
|
||||
|
||||
|
@ -309,9 +295,6 @@ public class EntityBinder {
|
|||
}
|
||||
}
|
||||
else {
|
||||
if (explicitHibernateEntityAnnotation) {
|
||||
LOG.entityAnnotationOnNonRoot(annotatedClass.getName());
|
||||
}
|
||||
if (annotatedClass.isAnnotationPresent(Immutable.class)) {
|
||||
LOG.immutableAnnotationOnNonRoot(annotatedClass.getName());
|
||||
}
|
||||
|
@ -324,22 +307,8 @@ public class EntityBinder {
|
|||
|
||||
//set persister if needed
|
||||
Persister persisterAnn = annotatedClass.getAnnotation( Persister.class );
|
||||
Class persister = null;
|
||||
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 = context.getBootstrapContext().getClassLoaderAccess().classForName( entityAnn.persister() );
|
||||
}
|
||||
catch (ClassLoadingException e) {
|
||||
throw new AnnotationException( "Could not find persister class: " + entityAnn.persister(), e );
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( persister != null ) {
|
||||
Class persister = persisterAnn.impl();
|
||||
persistentClass.setEntityPersisterClass( persister );
|
||||
}
|
||||
|
||||
|
|
|
@ -233,10 +233,6 @@ public interface CoreMessageLogger extends BasicLogger {
|
|||
@Message(value = "Entities updated: %s", id = 80)
|
||||
void entitiesUpdated(long entityUpdateCount);
|
||||
|
||||
@LogMessage(level = WARN)
|
||||
@Message(value = "@org.hibernate.annotations.Entity used on a non root entity: ignored for %s", id = 81)
|
||||
void entityAnnotationOnNonRoot(String className);
|
||||
|
||||
@LogMessage(level = WARN)
|
||||
@Message(value = "Entity Manager closed by someone else (%s must not be used)", id = 82)
|
||||
void entityManagerClosedBySomeoneElse(String autoCloseSession);
|
||||
|
@ -511,12 +507,6 @@ public interface CoreMessageLogger extends BasicLogger {
|
|||
int anticipatedNumberOfArguments,
|
||||
int numberOfArguments);
|
||||
|
||||
@LogMessage(level = WARN)
|
||||
@Message(value = "Class annotated @org.hibernate.annotations.Entity but not javax.persistence.Entity (most likely a user error): %s",
|
||||
id = 175)
|
||||
void missingEntityAnnotation(String className);
|
||||
|
||||
|
||||
@LogMessage(level = ERROR)
|
||||
@Message(value = "Error in named query: %s", id = 177)
|
||||
void namedQueryError(
|
||||
|
|
|
@ -8,7 +8,7 @@ package org.hibernate.orm.test.annotations.embedded.one2many;
|
|||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
|
||||
import org.hibernate.annotations.Entity;
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* TODO : javadoc
|
||||
|
|
|
@ -12,7 +12,7 @@ import java.util.Set;
|
|||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
|
||||
import org.hibernate.annotations.Entity;
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* @author Hardy Ferentschik
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
|
||||
//$Id$
|
||||
package org.hibernate.orm.test.jpa.cascade;
|
||||
import org.hibernate.annotations.DynamicInsert;
|
||||
import org.hibernate.annotations.DynamicUpdate;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import javax.persistence.CascadeType;
|
||||
|
@ -30,7 +33,7 @@ import javax.persistence.Table;
|
|||
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
|
||||
@DiscriminatorColumn(name = "type", discriminatorType = DiscriminatorType.CHAR)
|
||||
@DiscriminatorValue("X")
|
||||
@org.hibernate.annotations.Entity(dynamicInsert = true, dynamicUpdate = true)
|
||||
@DynamicUpdate @DynamicInsert
|
||||
public class Conference implements Serializable {
|
||||
private Long id;
|
||||
private Date date;
|
||||
|
|
|
@ -17,6 +17,8 @@ import javax.persistence.JoinColumn;
|
|||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.DynamicInsert;
|
||||
import org.hibernate.annotations.DynamicUpdate;
|
||||
import org.hibernate.annotations.Proxy;
|
||||
|
||||
/**
|
||||
|
@ -24,8 +26,7 @@ import org.hibernate.annotations.Proxy;
|
|||
*/
|
||||
@Entity
|
||||
@Table(name = "portal_pk_docs_extraction")
|
||||
//@Cache(usage = READ_WRITE)
|
||||
@org.hibernate.annotations.Entity(dynamicInsert = true, dynamicUpdate = true)
|
||||
@DynamicUpdate @DynamicInsert
|
||||
@Proxy
|
||||
public class ExtractionDocument implements Serializable {
|
||||
private Long id;
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
|
||||
//$Id$
|
||||
package org.hibernate.orm.test.jpa.cascade;
|
||||
import org.hibernate.annotations.DynamicInsert;
|
||||
import org.hibernate.annotations.DynamicUpdate;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
@ -29,8 +32,7 @@ import javax.persistence.Transient;
|
|||
*/
|
||||
@Entity
|
||||
@Table(name = "portal_pk_docs_extraction_info")
|
||||
//@Cache(usage = READ_WRITE)
|
||||
@org.hibernate.annotations.Entity(dynamicInsert = true, dynamicUpdate = true)
|
||||
@DynamicUpdate @DynamicInsert
|
||||
public class ExtractionDocumentInfo implements Serializable {
|
||||
private Long id;
|
||||
private Date lastModified;
|
||||
|
|
|
@ -13,7 +13,7 @@ import javax.persistence.JoinColumn;
|
|||
import javax.persistence.Lob;
|
||||
import javax.persistence.OneToOne;
|
||||
|
||||
import org.hibernate.annotations.Entity;
|
||||
import javax.persistence.Entity;
|
||||
|
||||
/**
|
||||
* @author Hardy Ferentschik
|
||||
|
|
|
@ -16,14 +16,19 @@ import javax.persistence.Id;
|
|||
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.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;
|
||||
|
||||
|
@ -34,11 +39,10 @@ import org.hibernate.annotations.Where;
|
|||
*/
|
||||
@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")})
|
||||
@Filter(name = "betweenLength")
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.hibernate.annotations.Type;
|
|||
|
||||
/**
|
||||
* Mapping following lines of {@link Forest}, but using the replacements for the now deprecated
|
||||
* {@link org.hibernate.annotations.Entity} annotation.
|
||||
* {@link javax.persistence.Entity} annotation.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
|
|
|
@ -12,13 +12,14 @@ import javax.persistence.Id;
|
|||
|
||||
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;
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.test.annotations.persister;
|
||||
import org.hibernate.annotations.Persister;
|
||||
|
||||
import java.io.Serializable;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
|
@ -15,7 +17,7 @@ import javax.persistence.ManyToOne;
|
|||
* @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;
|
||||
|
|
|
@ -18,7 +18,6 @@ import org.hibernate.annotations.Persister;
|
|||
* @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
|
||||
|
|
|
@ -15,6 +15,7 @@ import javax.persistence.InheritanceType;
|
|||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
|
||||
import org.hibernate.annotations.Polymorphism;
|
||||
import org.hibernate.annotations.PolymorphismType;
|
||||
|
||||
/**
|
||||
|
@ -22,7 +23,7 @@ import org.hibernate.annotations.PolymorphismType;
|
|||
*/
|
||||
@Entity
|
||||
@Inheritance(strategy= InheritanceType.TABLE_PER_CLASS)
|
||||
@org.hibernate.annotations.Entity(polymorphism = PolymorphismType.EXPLICIT)
|
||||
@Polymorphism(type = PolymorphismType.EXPLICIT)
|
||||
public class Car extends Automobile {
|
||||
|
||||
@Id
|
||||
|
|
|
@ -10,6 +10,7 @@ package org.hibernate.test.annotations.polymorphism;
|
|||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.hibernate.annotations.Polymorphism;
|
||||
import org.hibernate.annotations.PolymorphismType;
|
||||
|
||||
/**
|
||||
|
@ -17,6 +18,6 @@ import org.hibernate.annotations.PolymorphismType;
|
|||
*/
|
||||
@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 {
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue