HHH-18191 - Remove @LazyToOne

This commit is contained in:
Steve Ebersole 2024-07-23 17:33:59 -05:00
parent 9e6d2e006d
commit ea1f74407d
43 changed files with 245 additions and 548 deletions

View File

@ -1,35 +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.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Specifies the machinery used to handle lazy fetching of
* the annotated {@link jakarta.persistence.OneToOne} or
* {@link jakarta.persistence.ManyToOne} association.
* This is an alternative to specifying only the JPA
* {@link jakarta.persistence.FetchType}.
*
* @author Emmanuel Bernard
*
* @deprecated use JPA annotations to specify the
* {@link jakarta.persistence.FetchType}
*/
@Deprecated(since="6.2")
@Target({ElementType.METHOD, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface LazyToOne {
/**
* A {@link LazyToOneOption} which determines how lazy
* fetching should be handled.
*/
LazyToOneOption value() default LazyToOneOption.PROXY;
}

View File

@ -1,87 +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;
/**
* Enumerates the options for lazy loading of a
* {@linkplain jakarta.persistence.ManyToOne many to one}
* or {@linkplain jakarta.persistence.OneToOne one to one}
* association.
*
* @author Emmanuel Bernard
*
* @see LazyToOne
*
* @deprecated since {@link LazyToOne} is deprecated, use
* {@link jakarta.persistence.FetchType} instead
*/
@Deprecated(since="6.2")
public enum LazyToOneOption {
/**
* The association is always loaded eagerly. The identifier
* and concrete type of the associated entity instance,
* along with all the rest of its non-lazy fields, are always
* available immediately.
*
* @deprecated use {@link jakarta.persistence.FetchType#EAGER}
*/
@Deprecated
FALSE,
/**
* The association is proxied and a delegate entity instance
* is lazily fetched when any method of the proxy other than
* the getter method for the identifier property is first
* called.
* <ul>
* <li>The identifier property of the proxy object is set
* when the proxy is instantiated.
* The program may obtain the entity identifier value
* of an unfetched proxy, without triggering lazy
* fetching, by calling the corresponding getter method.
* <li>The proxy does not have the same concrete type as the
* proxied delegate, and so
* {@link org.hibernate.Hibernate#getClass(Object)}
* must be used in place of {@link Object#getClass()},
* and this method fetches the entity by side-effect.
* <li>For a polymorphic association, the concrete type of
* the proxied entity instance is not known until the
* delegate is fetched from the database, and so
* {@link org.hibernate.Hibernate#unproxy(Object, Class)}}
* must be used to perform typecasts, and
* {@link org.hibernate.Hibernate#getClass(Object)}
* must be used instead of the Java {@code instanceof}
* operator.
* </ul>
*
* @deprecated use {@link jakarta.persistence.FetchType#LAZY}
*/
@Deprecated
PROXY,
/**
* The associated entity instance is initially in an unloaded
* state, and is loaded lazily when any field other than the
* field containing the identifier is first accessed.
* <ul>
* <li>The identifier field of an unloaded entity instance is
* set when the unloaded instance is instantiated.
* The program may obtain the identifier of an unloaded
* entity, without triggering lazy fetching, by accessing
* the field containing the identifier.
* <li>Typecasts, the Java {@code instanceof} operator, and
* {@link Object#getClass()} may be used as normal.
* <li>Bytecode enhancement is required. If the class is not
* enhanced, this option is equivalent to {@link #PROXY}.
* </ul>
* <p>
* Hibernate does not support this setting for polymorphic
* associations, and instead falls back to {@link #PROXY}.
*
* @deprecated this setting no longer has any useful effect
*/
@Deprecated
NO_PROXY
}

View File

@ -16,8 +16,6 @@ import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.Columns; import org.hibernate.annotations.Columns;
import org.hibernate.annotations.Fetch; import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchProfileOverride; import org.hibernate.annotations.FetchProfileOverride;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;
import org.hibernate.annotations.NotFound; import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction; import org.hibernate.annotations.NotFoundAction;
import org.hibernate.annotations.OnDelete; import org.hibernate.annotations.OnDelete;
@ -58,7 +56,6 @@ import static org.hibernate.boot.model.internal.BinderHelper.isDefault;
import static org.hibernate.boot.model.internal.BinderHelper.noConstraint; import static org.hibernate.boot.model.internal.BinderHelper.noConstraint;
import static org.hibernate.internal.CoreLogging.messageLogger; import static org.hibernate.internal.CoreLogging.messageLogger;
import static org.hibernate.internal.util.StringHelper.isEmpty; import static org.hibernate.internal.util.StringHelper.isEmpty;
import static org.hibernate.internal.util.StringHelper.isNotEmpty;
import static org.hibernate.internal.util.StringHelper.nullIfEmpty; import static org.hibernate.internal.util.StringHelper.nullIfEmpty;
import static org.hibernate.internal.util.StringHelper.qualify; import static org.hibernate.internal.util.StringHelper.qualify;
@ -415,21 +412,7 @@ public class ToOneBinder {
private static boolean isEager(MemberDetails property, PropertyData inferredData, PropertyHolder propertyHolder) { private static boolean isEager(MemberDetails property, PropertyData inferredData, PropertyHolder propertyHolder) {
final FetchType fetchType = getJpaFetchType( property ); final FetchType fetchType = getJpaFetchType( property );
return fetchType == EAGER;
final LazyToOne lazyToOneAnnotationUsage = property.getDirectAnnotationUsage( LazyToOne.class );
if ( lazyToOneAnnotationUsage != null ) {
final LazyToOneOption option = lazyToOneAnnotationUsage.value();
boolean eager = option == LazyToOneOption.FALSE;
if ( eager && fetchType == LAZY ) {
// conflicts with non-default setting
throw new AnnotationException("Association '" + getPath(propertyHolder, inferredData)
+ "' is marked 'fetch=LAZY' and '@LazyToOne(FALSE)'");
}
return eager;
}
else {
return fetchType == EAGER;
}
} }
private static FetchType getJpaFetchType(MemberDetails property) { private static FetchType getJpaFetchType(MemberDetails property) {

View File

@ -374,10 +374,6 @@ public interface HibernateAnnotations {
LazyGroup.class, LazyGroup.class,
LazyGroupAnnotation.class LazyGroupAnnotation.class
); );
OrmAnnotationDescriptor<LazyToOne, LazyToOneAnnotation> LAZY_TO_ONE = new OrmAnnotationDescriptor<>(
LazyToOne.class,
LazyToOneAnnotation.class
);
OrmAnnotationDescriptor<ListIndexBase, ListIndexBaseAnnotation> LIST_INDEX_BASE = new OrmAnnotationDescriptor<>( OrmAnnotationDescriptor<ListIndexBase, ListIndexBaseAnnotation> LIST_INDEX_BASE = new OrmAnnotationDescriptor<>(
ListIndexBase.class, ListIndexBase.class,
ListIndexBaseAnnotation.class ListIndexBaseAnnotation.class

View File

@ -1,60 +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.boot.models.annotations.internal;
import java.lang.annotation.Annotation;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.boot.models.HibernateAnnotations;
import org.hibernate.models.spi.SourceModelBuildingContext;
import org.jboss.jandex.AnnotationInstance;
import static org.hibernate.boot.models.internal.OrmAnnotationHelper.extractJandexValue;
@SuppressWarnings({ "ClassExplicitlyAnnotation", "unused" })
@jakarta.annotation.Generated("org.hibernate.orm.build.annotations.ClassGeneratorProcessor")
public class LazyToOneAnnotation implements LazyToOne {
private org.hibernate.annotations.LazyToOneOption value;
/**
* Used in creating dynamic annotation instances (e.g. from XML)
*/
public LazyToOneAnnotation(SourceModelBuildingContext modelContext) {
this.value = org.hibernate.annotations.LazyToOneOption.PROXY;
}
/**
* Used in creating annotation instances from JDK variant
*/
public LazyToOneAnnotation(LazyToOne annotation, SourceModelBuildingContext modelContext) {
this.value = annotation.value();
}
/**
* Used in creating annotation instances from Jandex variant
*/
public LazyToOneAnnotation(AnnotationInstance annotation, SourceModelBuildingContext modelContext) {
this.value = extractJandexValue( annotation, HibernateAnnotations.LAZY_TO_ONE, "value", modelContext );
}
@Override
public Class<? extends Annotation> annotationType() {
return LazyToOne.class;
}
@Override
public org.hibernate.annotations.LazyToOneOption value() {
return value;
}
public void value(org.hibernate.annotations.LazyToOneOption value) {
this.value = value;
}
}

View File

@ -7,8 +7,13 @@
//$Id$ //$Id$
package org.hibernate.orm.test.annotations.fetch; package org.hibernate.orm.test.annotations.fetch;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import jakarta.persistence.CascadeType; import jakarta.persistence.CascadeType;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.FetchType; import jakarta.persistence.FetchType;
@ -18,11 +23,6 @@ import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;
/** /**
* @author Emmanuel Bernard * @author Emmanuel Bernard
*/ */
@ -105,8 +105,7 @@ public class Stay implements Serializable {
this.person = person; this.person = person;
} }
@ManyToOne(cascade = CascadeType.ALL) @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@LazyToOne(LazyToOneOption.PROXY)
@Fetch(FetchMode.SELECT) @Fetch(FetchMode.SELECT)
@JoinColumn(name = "oldperson") @JoinColumn(name = "oldperson")
public Person getOldPerson() { public Person getOldPerson() {
@ -118,7 +117,6 @@ public class Stay implements Serializable {
} }
@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY) @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@LazyToOne(LazyToOneOption.PROXY)
@Fetch(FetchMode.JOIN) @Fetch(FetchMode.JOIN)
@JoinColumn(name = "veryoldperson") @JoinColumn(name = "veryoldperson")
public Person getVeryOldPerson() { public Person getVeryOldPerson() {

View File

@ -4,7 +4,6 @@ import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate; import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.Fetch; import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.LazyGroup; import org.hibernate.annotations.LazyGroup;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.testing.bytecode.enhancement.extension.BytecodeEnhanced; import org.hibernate.testing.bytecode.enhancement.extension.BytecodeEnhanced;
import org.hibernate.testing.orm.junit.DomainModel; import org.hibernate.testing.orm.junit.DomainModel;
@ -25,7 +24,6 @@ import jakarta.persistence.Version;
import static jakarta.persistence.CascadeType.ALL; import static jakarta.persistence.CascadeType.ALL;
import static jakarta.persistence.FetchType.LAZY; import static jakarta.persistence.FetchType.LAZY;
import static org.hibernate.annotations.FetchMode.SELECT; import static org.hibernate.annotations.FetchMode.SELECT;
import static org.hibernate.annotations.LazyToOneOption.NO_PROXY;
import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotNull;
@DomainModel( @DomainModel(
@ -83,7 +81,6 @@ public class BidirectionalOneToOneWithNonAggregateIdTest {
protected int lockVersion; protected int lockVersion;
@OneToOne(fetch = LAZY, cascade = ALL, orphanRemoval = true, mappedBy = "parent") @OneToOne(fetch = LAZY, cascade = ALL, orphanRemoval = true, mappedBy = "parent")
@LazyToOne(NO_PROXY)
@LazyGroup("group2") @LazyGroup("group2")
@Fetch(SELECT) @Fetch(SELECT)
protected Entity2 child; protected Entity2 child;
@ -111,7 +108,6 @@ public class BidirectionalOneToOneWithNonAggregateIdTest {
public static class Entity2 { public static class Entity2 {
@Id @Id
@OneToOne(fetch = LAZY, optional = false) @OneToOne(fetch = LAZY, optional = false)
@LazyToOne(NO_PROXY)
@LazyGroup("owner") @LazyGroup("owner")
@JoinColumn(name = "parentid", nullable = false, updatable = false, columnDefinition = "smallint") @JoinColumn(name = "parentid", nullable = false, updatable = false, columnDefinition = "smallint")
@Fetch(SELECT) @Fetch(SELECT)

View File

@ -6,20 +6,7 @@
*/ */
package org.hibernate.orm.test.bytecode.enhancement.cascade; package org.hibernate.orm.test.bytecode.enhancement.cascade;
import jakarta.persistence.Basic;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;
import org.hibernate.bytecode.spi.BytecodeEnhancementMetadata; import org.hibernate.bytecode.spi.BytecodeEnhancementMetadata;
import org.hibernate.proxy.HibernateProxy; import org.hibernate.proxy.HibernateProxy;
@ -32,6 +19,17 @@ import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import jakarta.persistence.Basic;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.hibernate.testing.jdbc.SQLStatementInspector.extractFromSession; import static org.hibernate.testing.jdbc.SQLStatementInspector.extractFromSession;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
@ -42,6 +40,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
/** /**
* @author Luis Barreiro * @author Luis Barreiro
*/ */
@SuppressWarnings("JUnitMalformedDeclaration")
@JiraKey("HHH-10252") @JiraKey("HHH-10252")
@DomainModel( @DomainModel(
annotatedClasses = { annotatedClasses = {
@ -208,7 +207,6 @@ public class CascadeDeleteManyToOneTest {
CascadeType.REMOVE CascadeType.REMOVE
}, fetch = FetchType.LAZY) }, fetch = FetchType.LAZY)
@JoinColumn(name = "parent_id") @JoinColumn(name = "parent_id")
@LazyToOne(LazyToOneOption.NO_PROXY)
Parent parent; Parent parent;
@Basic(fetch = FetchType.LAZY) @Basic(fetch = FetchType.LAZY)

View File

@ -2,20 +2,8 @@ package org.hibernate.orm.test.bytecode.enhancement.cascade;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.proxy.HibernateProxy; import org.hibernate.proxy.HibernateProxy;
@ -29,6 +17,17 @@ import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.hibernate.testing.orm.junit.Setting; import org.hibernate.testing.orm.junit.Setting;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.hibernate.testing.jdbc.SQLStatementInspector.extractFromSession; import static org.hibernate.testing.jdbc.SQLStatementInspector.extractFromSession;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
@ -40,6 +39,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
* @author Bolek Ziobrowski * @author Bolek Ziobrowski
* @author Gail Badner * @author Gail Badner
*/ */
@SuppressWarnings("JUnitMalformedDeclaration")
@JiraKey("HHH-13129") @JiraKey("HHH-13129")
@DomainModel( @DomainModel(
annotatedClasses = { annotatedClasses = {
@ -232,7 +232,6 @@ public class CascadeOnUninitializedTest {
@ManyToOne(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY) @ManyToOne(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY)
@JoinColumn(name = "primary_address_id") @JoinColumn(name = "primary_address_id")
@LazyToOne(LazyToOneOption.NO_PROXY)
private Address primaryAddress; private Address primaryAddress;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY) @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)

View File

@ -1,18 +1,9 @@
package org.hibernate.orm.test.bytecode.enhancement.cascade; package org.hibernate.orm.test.bytecode.enhancement.cascade;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hibernate.testing.jdbc.SQLStatementInspector.extractFromSession;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.proxy.HibernateProxy; import org.hibernate.proxy.HibernateProxy;
@ -24,7 +15,6 @@ import org.hibernate.testing.orm.junit.ServiceRegistry;
import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope; import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.hibernate.testing.orm.junit.Setting; import org.hibernate.testing.orm.junit.Setting;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import jakarta.persistence.CascadeType; import jakarta.persistence.CascadeType;
@ -38,6 +28,13 @@ import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany; import jakarta.persistence.OneToMany;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hibernate.testing.jdbc.SQLStatementInspector.extractFromSession;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
/** /**
* Same as {@link CascadeDeleteCollectionTest}, * Same as {@link CascadeDeleteCollectionTest},
* but with {@code collectionInDefaultFetchGroup} set to {@code false} explicitly. * but with {@code collectionInDefaultFetchGroup} set to {@code false} explicitly.
@ -47,6 +44,7 @@ import jakarta.persistence.Table;
* @author Bolek Ziobrowski * @author Bolek Ziobrowski
* @author Gail Badner * @author Gail Badner
*/ */
@SuppressWarnings("JUnitMalformedDeclaration")
@JiraKey("HHH-13129") @JiraKey("HHH-13129")
@DomainModel( @DomainModel(
annotatedClasses = { annotatedClasses = {
@ -247,7 +245,6 @@ public class CascadeOnUninitializedWithCollectionInDefaultFetchGroupFalseTest {
@ManyToOne(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY) @ManyToOne(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY)
@JoinColumn(name = "primary_address_id") @JoinColumn(name = "primary_address_id")
@LazyToOne(LazyToOneOption.NO_PROXY)
private Address primaryAddress; private Address primaryAddress;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY) @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)

View File

@ -9,8 +9,6 @@ package org.hibernate.orm.test.bytecode.enhancement.join;
import java.util.List; import java.util.List;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.testing.bytecode.enhancement.extension.BytecodeEnhanced; import org.hibernate.testing.bytecode.enhancement.extension.BytecodeEnhanced;
@ -20,6 +18,8 @@ import org.hibernate.testing.orm.junit.ServiceRegistry;
import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope; import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.hibernate.testing.orm.junit.Setting; import org.hibernate.testing.orm.junit.Setting;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.FetchType; import jakarta.persistence.FetchType;
@ -36,9 +36,7 @@ import static org.hibernate.Hibernate.isPropertyInitialized;
import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.BeforeEach; @SuppressWarnings("JUnitMalformedDeclaration")
import org.junit.jupiter.api.Test;
@JiraKey( "HHH-3949" ) @JiraKey( "HHH-3949" )
@DomainModel( @DomainModel(
annotatedClasses = { annotatedClasses = {
@ -201,7 +199,6 @@ public class HHH3949Test {
String name; String name;
@OneToOne( optional = true, mappedBy = "driver", fetch = FetchType.LAZY ) @OneToOne( optional = true, mappedBy = "driver", fetch = FetchType.LAZY )
@LazyToOne( LazyToOneOption.NO_PROXY )
Vehicle vehicle; Vehicle vehicle;
Person() { Person() {

View File

@ -8,17 +8,9 @@ package org.hibernate.orm.test.bytecode.enhancement.lazy;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;
import org.hibernate.bytecode.enhance.spi.DefaultEnhancementContext; import org.hibernate.bytecode.enhance.spi.DefaultEnhancementContext;
import org.hibernate.bytecode.enhance.spi.UnloadedClass; import org.hibernate.bytecode.enhance.spi.UnloadedClass;
import org.hibernate.bytecode.enhance.spi.UnloadedField; import org.hibernate.bytecode.enhance.spi.UnloadedField;
@ -38,6 +30,13 @@ import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.hibernate.testing.orm.junit.Setting; import org.hibernate.testing.orm.junit.Setting;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
@ -51,6 +50,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
* *
* @author Gail Badner * @author Gail Badner
*/ */
@SuppressWarnings("JUnitMalformedDeclaration")
@JiraKey("HHH-13241") @JiraKey("HHH-13241")
@DomainModel( @DomainModel(
annotatedClasses = { annotatedClasses = {
@ -357,7 +357,6 @@ public class BidirectionalLazyTest {
} }
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@LazyToOne(LazyToOneOption.NO_PROXY)
@JoinColumn(name = "employer_name") @JoinColumn(name = "employer_name")
public Employer getEmployer() { public Employer getEmployer() {
return employer; return employer;

View File

@ -6,10 +6,12 @@
*/ */
package org.hibernate.orm.test.bytecode.enhancement.lazy; package org.hibernate.orm.test.bytecode.enhancement.lazy;
import org.hibernate.annotations.LazyToOne; import java.util.ArrayList;
import org.hibernate.annotations.LazyToOneOption; import java.util.List;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.proxy.HibernateProxy; import org.hibernate.proxy.HibernateProxy;
import org.hibernate.testing.bytecode.enhancement.extension.BytecodeEnhanced; import org.hibernate.testing.bytecode.enhancement.extension.BytecodeEnhanced;
import org.hibernate.testing.orm.junit.DomainModel; import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.JiraKey; import org.hibernate.testing.orm.junit.JiraKey;
@ -29,8 +31,6 @@ import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany; import jakarta.persistence.OneToMany;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import java.util.ArrayList;
import java.util.List;
import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.CoreMatchers.instanceOf;
@ -53,6 +53,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@SuppressWarnings("JUnitMalformedDeclaration")
@JiraKey( "HHH-10055" ) @JiraKey( "HHH-10055" )
@DomainModel( @DomainModel(
annotatedClasses = { annotatedClasses = {
@ -186,7 +187,6 @@ public class LazyCollectionLoadingTest {
Long id; Long id;
@ManyToOne( cascade = CascadeType.ALL, fetch = FetchType.LAZY ) @ManyToOne( cascade = CascadeType.ALL, fetch = FetchType.LAZY )
@LazyToOne( LazyToOneOption.NO_PROXY )
Parent parent; Parent parent;
String name; String name;

View File

@ -6,8 +6,9 @@
*/ */
package org.hibernate.orm.test.bytecode.enhancement.lazy; package org.hibernate.orm.test.bytecode.enhancement.lazy;
import org.hibernate.annotations.LazyToOne; import java.util.ArrayList;
import org.hibernate.annotations.LazyToOneOption; import java.util.List;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.testing.bytecode.enhancement.extension.BytecodeEnhanced; import org.hibernate.testing.bytecode.enhancement.extension.BytecodeEnhanced;
@ -28,8 +29,6 @@ import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany; import jakarta.persistence.OneToMany;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import java.util.ArrayList;
import java.util.List;
import static org.hibernate.testing.bytecode.enhancement.EnhancerTestUtils.checkDirtyTracking; import static org.hibernate.testing.bytecode.enhancement.EnhancerTestUtils.checkDirtyTracking;
import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertNull;
@ -120,7 +119,6 @@ public class LazyLoadingIntegrationTest {
Long id; Long id;
@ManyToOne( cascade = CascadeType.ALL, fetch = FetchType.LAZY ) @ManyToOne( cascade = CascadeType.ALL, fetch = FetchType.LAZY )
@LazyToOne( LazyToOneOption.NO_PROXY )
Parent parent; Parent parent;
String name; String name;

View File

@ -9,19 +9,8 @@ package org.hibernate.orm.test.bytecode.enhancement.lazy;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;
import org.hibernate.bytecode.enhance.spi.interceptor.EnhancementAsProxyLazinessInterceptor; import org.hibernate.bytecode.enhance.spi.interceptor.EnhancementAsProxyLazinessInterceptor;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.engine.spi.PersistentAttributeInterceptable; import org.hibernate.engine.spi.PersistentAttributeInterceptable;
@ -37,6 +26,16 @@ import org.hibernate.testing.orm.junit.Setting;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.CoreMatchers.not;
@ -47,6 +46,7 @@ import static org.junit.Assert.assertThat;
/** /**
* @author Luis Barreiro * @author Luis Barreiro
*/ */
@SuppressWarnings("JUnitMalformedDeclaration")
@DomainModel( @DomainModel(
annotatedClasses = { annotatedClasses = {
LazyLoadingTest.Parent.class, LazyLoadingTest.Child.class LazyLoadingTest.Parent.class, LazyLoadingTest.Child.class
@ -149,7 +149,6 @@ public class LazyLoadingTest {
Long id; Long id;
@ManyToOne( cascade = CascadeType.ALL, fetch = FetchType.LAZY ) @ManyToOne( cascade = CascadeType.ALL, fetch = FetchType.LAZY )
@LazyToOne( LazyToOneOption.NO_PROXY )
Parent parent; Parent parent;
String name; String name;

View File

@ -6,14 +6,15 @@
*/ */
package org.hibernate.orm.test.bytecode.enhancement.lazy; package org.hibernate.orm.test.bytecode.enhancement.lazy;
import org.hibernate.annotations.LazyToOne; import java.util.HashSet;
import org.hibernate.annotations.LazyToOneOption; import java.util.Objects;
import java.util.Set;
import org.hibernate.testing.bytecode.enhancement.extension.BytecodeEnhanced; import org.hibernate.testing.bytecode.enhancement.extension.BytecodeEnhanced;
import org.hibernate.testing.orm.junit.DomainModel; import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.JiraKey; import org.hibernate.testing.orm.junit.JiraKey;
import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope; import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -26,11 +27,8 @@ import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany; import jakarta.persistence.OneToMany;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
@SuppressWarnings("JUnitMalformedDeclaration")
@JiraKey("HHH-13380") @JiraKey("HHH-13380")
@DomainModel( @DomainModel(
annotatedClasses = { annotatedClasses = {
@ -100,7 +98,6 @@ public class LazyOneToManyWithEqualsImplementationTest {
public String getTitle() { return title; } public String getTitle() { return title; }
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@LazyToOne(LazyToOneOption.NO_PROXY)
private Person person; private Person person;
public Person getPerson() { return person; } public Person getPerson() { return person; }

View File

@ -6,15 +6,7 @@
*/ */
package org.hibernate.orm.test.bytecode.enhancement.lazy; package org.hibernate.orm.test.bytecode.enhancement.lazy;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;
import org.hibernate.annotations.NaturalId; import org.hibernate.annotations.NaturalId;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
@ -30,6 +22,12 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
@ -37,6 +35,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
/** /**
* @author Gail Badner * @author Gail Badner
*/ */
@SuppressWarnings("JUnitMalformedDeclaration")
@JiraKey( "HHH-13607" ) @JiraKey( "HHH-13607" )
@DomainModel( @DomainModel(
annotatedClasses = { annotatedClasses = {
@ -133,11 +132,9 @@ public class NaturalIdInUninitializedAssociationTest {
private int id; private int id;
@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@LazyToOne(LazyToOneOption.NO_PROXY )
private EntityMutableNaturalId entityMutableNaturalId; private EntityMutableNaturalId entityMutableNaturalId;
@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@LazyToOne(LazyToOneOption.NO_PROXY )
private EntityImmutableNaturalId entityImmutableNaturalId; private EntityImmutableNaturalId entityImmutableNaturalId;
} }

View File

@ -2,21 +2,10 @@ package org.hibernate.orm.test.bytecode.enhancement.lazy.cache;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import jakarta.persistence.Basic;
import jakarta.persistence.Cacheable;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.annotations.Cache; import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy; import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.proxy.HibernateProxy; import org.hibernate.proxy.HibernateProxy;
import org.hibernate.stat.CacheRegionStatistics; import org.hibernate.stat.CacheRegionStatistics;
@ -28,6 +17,18 @@ import org.hibernate.testing.orm.junit.ServiceRegistry;
import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope; import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.hibernate.testing.orm.junit.Setting; import org.hibernate.testing.orm.junit.Setting;
import org.junit.Assert;
import org.junit.jupiter.api.Test;
import jakarta.persistence.Basic;
import jakarta.persistence.Cacheable;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.not; import static org.hamcrest.CoreMatchers.not;
@ -35,9 +36,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat; import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import org.junit.Assert; @SuppressWarnings("JUnitMalformedDeclaration")
import org.junit.jupiter.api.Test;
@DomainModel( @DomainModel(
annotatedClasses = { annotatedClasses = {
UninitializedAssociationsInCacheTest.Employee.class UninitializedAssociationsInCacheTest.Employee.class
@ -157,7 +156,6 @@ public class UninitializedAssociationsInCacheTest {
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "SUPERIOR") @JoinColumn(name = "SUPERIOR")
@LazyToOne( value = LazyToOneOption.NO_PROXY )
Employee superior; Employee superior;
@OneToMany(mappedBy = "superior") @OneToMany(mappedBy = "superior")

View File

@ -6,24 +6,10 @@
*/ */
package org.hibernate.orm.test.bytecode.enhancement.lazy.group; package org.hibernate.orm.test.bytecode.enhancement.lazy.group;
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Embeddable;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import org.hibernate.annotations.LazyGroup; import org.hibernate.annotations.LazyGroup;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;
import org.hibernate.bytecode.enhance.spi.DefaultEnhancementContext; import org.hibernate.bytecode.enhance.spi.DefaultEnhancementContext;
import org.hibernate.bytecode.enhance.spi.UnloadedClass; import org.hibernate.bytecode.enhance.spi.UnloadedClass;
@ -37,6 +23,16 @@ import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Embeddable;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
/** /**
* Tests removing non-owning side of the bidirectional association, * Tests removing non-owning side of the bidirectional association,
* where owning side is in an embeddable. * where owning side is in an embeddable.
@ -45,6 +41,7 @@ import org.junit.jupiter.api.Test;
* *
* @author Gail Badner * @author Gail Badner
*/ */
@SuppressWarnings("JUnitMalformedDeclaration")
@JiraKey("HHH-13241") @JiraKey("HHH-13241")
@DomainModel( @DomainModel(
annotatedClasses = { annotatedClasses = {
@ -206,7 +203,6 @@ public class BidirectionalLazyGroupsInEmbeddableTest {
private Employer employer; private Employer employer;
@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REMOVE) @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
@LazyToOne(LazyToOneOption.NO_PROXY)
@LazyGroup("EmployerForEmployee") @LazyGroup("EmployerForEmployee")
@JoinColumn(name = "employer_name") @JoinColumn(name = "employer_name")
public Employer getEmployer() { public Employer getEmployer() {

View File

@ -8,18 +8,9 @@ package org.hibernate.orm.test.bytecode.enhancement.lazy.group;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.annotations.LazyGroup; import org.hibernate.annotations.LazyGroup;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;
import org.hibernate.bytecode.enhance.spi.DefaultEnhancementContext; import org.hibernate.bytecode.enhance.spi.DefaultEnhancementContext;
import org.hibernate.bytecode.enhance.spi.UnloadedClass; import org.hibernate.bytecode.enhance.spi.UnloadedClass;
@ -30,19 +21,27 @@ import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.JiraKey; import org.hibernate.testing.orm.junit.JiraKey;
import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope; import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.junit.jupiter.api.Test;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
/** /**
* Tests removing non-owning side of the bidirectional association, * Tests removing non-owning side of the bidirectional association,
* with and without dirty-checking using enhancement. * with and without dirty-checking using enhancement.
* *
* @author Gail Badner * @author Gail Badner
*/ */
@SuppressWarnings("JUnitMalformedDeclaration")
@JiraKey("HHH-13241") @JiraKey("HHH-13241")
@DomainModel( @DomainModel(
annotatedClasses = { annotatedClasses = {
@ -158,7 +157,6 @@ public class BidirectionalLazyGroupsTest {
} }
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@LazyToOne(LazyToOneOption.NO_PROXY)
@LazyGroup("EmployerForEmployee") @LazyGroup("EmployerForEmployee")
@JoinColumn(name = "employer_name") @JoinColumn(name = "employer_name")
public Employer getEmployer() { public Employer getEmployer() {

View File

@ -1,5 +1,7 @@
package org.hibernate.orm.test.bytecode.enhancement.lazy.group; package org.hibernate.orm.test.bytecode.enhancement.lazy.group;
import org.hibernate.annotations.LazyGroup;
import jakarta.persistence.Access; import jakarta.persistence.Access;
import jakarta.persistence.AccessType; import jakarta.persistence.AccessType;
import jakarta.persistence.Basic; import jakarta.persistence.Basic;
@ -14,10 +16,6 @@ import jakarta.persistence.Lob;
import jakarta.persistence.OneToOne; import jakarta.persistence.OneToOne;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import org.hibernate.annotations.LazyGroup;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;
/** /**
* Source of a LazyToOne - relationship with FK on the other side * Source of a LazyToOne - relationship with FK on the other side
* *
@ -39,7 +37,6 @@ public class LGMB_From {
// Lazy-Association with mappdedBy in own LazyGroup // Lazy-Association with mappdedBy in own LazyGroup
@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "fromRelation", optional = true) @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "fromRelation", optional = true)
@LazyToOne(LazyToOneOption.NO_PROXY)
@LazyGroup(value = "toRelationLazyGroup") @LazyGroup(value = "toRelationLazyGroup")
private LGMB_To toRelation; private LGMB_To toRelation;

View File

@ -17,12 +17,9 @@ import org.junit.jupiter.api.Test;
* *
* @author Jan-Oliver Lustig, Sebastian Viefhaus * @author Jan-Oliver Lustig, Sebastian Viefhaus
*/ */
@SuppressWarnings("JUnitMalformedDeclaration")
@JiraKey("HHH-11986") @JiraKey("HHH-11986")
@DomainModel( @DomainModel(annotatedClasses = {LGMB_From.class, LGMB_To.class})
annotatedClasses = {
LGMB_From.class, LGMB_To.class
}
)
@SessionFactory @SessionFactory
@BytecodeEnhanced @BytecodeEnhanced
public class LazyGroupMappedByTest { public class LazyGroupMappedByTest {

View File

@ -8,21 +8,9 @@ package org.hibernate.orm.test.bytecode.enhancement.lazy.group;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import jakarta.persistence.Basic;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.annotations.LazyGroup; import org.hibernate.annotations.LazyGroup;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.proxy.HibernateProxy; import org.hibernate.proxy.HibernateProxy;
@ -34,18 +22,29 @@ import org.hibernate.testing.orm.junit.ServiceRegistry;
import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope; import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.hibernate.testing.orm.junit.Setting; import org.hibernate.testing.orm.junit.Setting;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import jakarta.persistence.Basic;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/** /**
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@SuppressWarnings("JUnitMalformedDeclaration")
@JiraKey( "HHH-11155" ) @JiraKey( "HHH-11155" )
@DomainModel( @DomainModel(
annotatedClasses = { annotatedClasses = {
@ -257,11 +256,9 @@ public class LazyGroupTest {
String nickName; String nickName;
@ManyToOne( cascade = CascadeType.ALL, fetch = FetchType.LAZY ) @ManyToOne( cascade = CascadeType.ALL, fetch = FetchType.LAZY )
@LazyToOne( LazyToOneOption.NO_PROXY )
Parent parent; Parent parent;
@ManyToOne( cascade = CascadeType.ALL, fetch = FetchType.LAZY ) @ManyToOne( cascade = CascadeType.ALL, fetch = FetchType.LAZY )
@LazyToOne( LazyToOneOption.NO_PROXY )
@LazyGroup( "SECONDARY" ) @LazyGroup( "SECONDARY" )
Parent alternateParent; Parent alternateParent;

View File

@ -6,6 +6,17 @@
*/ */
package org.hibernate.orm.test.bytecode.enhancement.lazy.notfound; package org.hibernate.orm.test.bytecode.enhancement.lazy.notfound;
import org.hibernate.Hibernate;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.testing.bytecode.enhancement.extension.BytecodeEnhanced;
import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.JiraKey;
import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.junit.jupiter.api.Test;
import jakarta.persistence.CascadeType; import jakarta.persistence.CascadeType;
import jakarta.persistence.ConstraintMode; import jakarta.persistence.ConstraintMode;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
@ -16,26 +27,13 @@ import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import org.hibernate.Hibernate;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.testing.bytecode.enhancement.extension.BytecodeEnhanced;
import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.JiraKey;
import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertNull;
import org.junit.jupiter.api.Test;
/** /**
* @author Gail Badner * @author Gail Badner
*/ */
@SuppressWarnings("JUnitMalformedDeclaration")
@JiraKey("HHH-12226") @JiraKey("HHH-12226")
@DomainModel( @DomainModel(
annotatedClasses = { annotatedClasses = {
@ -81,7 +79,6 @@ public class LazyNotFoundManyToOneNonUpdatableNonInsertableTest {
private Integer id; private Integer id;
@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, optional = true) @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, optional = true)
@LazyToOne(value = LazyToOneOption.NO_PROXY)
@NotFound(action = NotFoundAction.IGNORE) @NotFound(action = NotFoundAction.IGNORE)
@JoinColumn( @JoinColumn(
foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT), foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT),

View File

@ -6,9 +6,16 @@
*/ */
package org.hibernate.orm.test.bytecode.enhancement.lazy.notfound; package org.hibernate.orm.test.bytecode.enhancement.lazy.notfound;
/** import org.hibernate.Hibernate;
* @author Gail Badner import org.hibernate.annotations.NotFound;
*/ import org.hibernate.annotations.NotFoundAction;
import org.hibernate.testing.bytecode.enhancement.extension.BytecodeEnhanced;
import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.JiraKey;
import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.junit.jupiter.api.Test;
import jakarta.persistence.CascadeType; import jakarta.persistence.CascadeType;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
@ -18,22 +25,9 @@ import jakarta.persistence.JoinColumn;
import jakarta.persistence.OneToOne; import jakarta.persistence.OneToOne;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import org.hibernate.Hibernate;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.testing.bytecode.enhancement.extension.BytecodeEnhanced;
import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.JiraKey;
import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import org.junit.jupiter.api.Test; @SuppressWarnings("JUnitMalformedDeclaration")
@JiraKey("HHH-12226") @JiraKey("HHH-12226")
@DomainModel( @DomainModel(
annotatedClasses = { annotatedClasses = {
@ -80,7 +74,6 @@ public class LazyNotFoundOneToOneNonUpdatableNonInsertableTest {
private Integer id; private Integer id;
@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, optional = true) @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, optional = true)
@LazyToOne(value = LazyToOneOption.NO_PROXY)
@NotFound(action = NotFoundAction.IGNORE) @NotFound(action = NotFoundAction.IGNORE)
@JoinColumn( @JoinColumn(
name = "id", name = "id",

View File

@ -6,6 +6,18 @@
*/ */
package org.hibernate.orm.test.bytecode.enhancement.lazy.notfound; package org.hibernate.orm.test.bytecode.enhancement.lazy.notfound;
import org.hibernate.Hibernate;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.testing.bytecode.enhancement.extension.BytecodeEnhanced;
import org.hibernate.testing.jdbc.SQLStatementInspector;
import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.JiraKey;
import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.junit.jupiter.api.Test;
import jakarta.persistence.CascadeType; import jakarta.persistence.CascadeType;
import jakarta.persistence.ConstraintMode; import jakarta.persistence.ConstraintMode;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
@ -16,27 +28,13 @@ import jakarta.persistence.JoinColumn;
import jakarta.persistence.OneToOne; import jakarta.persistence.OneToOne;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import org.hibernate.Hibernate;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.testing.bytecode.enhancement.extension.BytecodeEnhanced;
import org.hibernate.testing.jdbc.SQLStatementInspector;
import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.JiraKey;
import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertNull;
import org.junit.jupiter.api.Test;
/** /**
* @author Gail Badner * @author Gail Badner
*/ */
@SuppressWarnings("JUnitMalformedDeclaration")
@JiraKey("HHH-12226") @JiraKey("HHH-12226")
@DomainModel( @DomainModel(
annotatedClasses = { annotatedClasses = {
@ -93,7 +91,6 @@ public class LazyNotFoundOneToOneTest {
private Integer id; private Integer id;
@OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@LazyToOne(value = LazyToOneOption.NO_PROXY)
@NotFound(action = NotFoundAction.IGNORE) @NotFound(action = NotFoundAction.IGNORE)
@JoinColumn(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT)) @JoinColumn(foreignKey = @ForeignKey(ConstraintMode.NO_CONSTRAINT))
private Lazy lazy; private Lazy lazy;

View File

@ -8,6 +8,7 @@ package org.hibernate.orm.test.bytecode.enhancement.lazy.proxy;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.FetchType; import jakarta.persistence.FetchType;
@ -18,9 +19,6 @@ import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany; import jakarta.persistence.OneToMany;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;
/** /**
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@ -75,7 +73,6 @@ public abstract class Customer {
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn @JoinColumn
@LazyToOne(LazyToOneOption.NO_PROXY)
public Address getAddress() { public Address getAddress() {
return address; return address;
} }
@ -86,7 +83,6 @@ public abstract class Customer {
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn @JoinColumn
@LazyToOne(LazyToOneOption.NO_PROXY)
public Customer getParentCustomer() { public Customer getParentCustomer() {
return parentCustomer; return parentCustomer;
} }

View File

@ -8,6 +8,7 @@ package org.hibernate.orm.test.bytecode.enhancement.lazy.proxy;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.FetchType; import jakarta.persistence.FetchType;
@ -20,9 +21,6 @@ import jakarta.persistence.OneToMany;
import jakarta.persistence.OneToOne; import jakarta.persistence.OneToOne;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;
/** /**
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@ -98,7 +96,6 @@ public class Order {
} }
@OneToOne(fetch = FetchType.LAZY, mappedBy = "order") @OneToOne(fetch = FetchType.LAZY, mappedBy = "order")
@LazyToOne(LazyToOneOption.NO_PROXY)
public OrderSupplemental2 getSupplemental2() { public OrderSupplemental2 getSupplemental2() {
return supplemental2; return supplemental2;
} }

View File

@ -15,6 +15,9 @@ package org.hibernate.orm.test.bytecode.enhancement.lazy.proxy;
import java.io.Serializable; import java.io.Serializable;
import org.hibernate.annotations.LazyGroup;
import jakarta.persistence.Basic; import jakarta.persistence.Basic;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
@ -25,10 +28,6 @@ import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import org.hibernate.annotations.LazyGroup;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;
@Entity(name = "RoleEntity") @Entity(name = "RoleEntity")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@Table(name = "PP_DCRolleKey") @Table(name = "PP_DCRolleKey")
@ -39,13 +38,11 @@ public class RoleEntity extends ModelEntity implements Serializable {
Short value; Short value;
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@LazyToOne(LazyToOneOption.PROXY)
@LazyGroup("Key") @LazyGroup("Key")
@JoinColumn @JoinColumn
protected AbstractKey key = null; protected AbstractKey key = null;
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@LazyToOne(LazyToOneOption.PROXY)
@LazyGroup("Key") @LazyGroup("Key")
@JoinColumn @JoinColumn
protected SpecializedKey specializedKey = null; protected SpecializedKey specializedKey = null;

View File

@ -14,6 +14,9 @@
package org.hibernate.orm.test.bytecode.enhancement.lazy.proxy; package org.hibernate.orm.test.bytecode.enhancement.lazy.proxy;
import java.io.Serializable; import java.io.Serializable;
import org.hibernate.annotations.LazyGroup;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.FetchType; import jakarta.persistence.FetchType;
@ -24,10 +27,6 @@ import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import org.hibernate.annotations.LazyGroup;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;
@Entity(name="SpecializedEntity") @Entity(name="SpecializedEntity")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@ -49,7 +48,6 @@ public class SpecializedEntity implements Serializable {
String value; String value;
@ManyToOne(fetch=FetchType.LAZY) @ManyToOne(fetch=FetchType.LAZY)
@LazyToOne(LazyToOneOption.PROXY)
@LazyGroup("SpecializedKey") @LazyGroup("SpecializedKey")
@JoinColumn @JoinColumn
protected SpecializedKey specializedKey = null; protected SpecializedKey specializedKey = null;

View File

@ -4,7 +4,6 @@ import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate; import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.Fetch; import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.LazyGroup; import org.hibernate.annotations.LazyGroup;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.testing.bytecode.enhancement.extension.BytecodeEnhanced; import org.hibernate.testing.bytecode.enhancement.extension.BytecodeEnhanced;
import org.hibernate.testing.orm.junit.DomainModel; import org.hibernate.testing.orm.junit.DomainModel;
@ -25,9 +24,9 @@ import jakarta.persistence.Version;
import static jakarta.persistence.CascadeType.ALL; import static jakarta.persistence.CascadeType.ALL;
import static jakarta.persistence.FetchType.LAZY; import static jakarta.persistence.FetchType.LAZY;
import static org.hibernate.annotations.FetchMode.SELECT; import static org.hibernate.annotations.FetchMode.SELECT;
import static org.hibernate.annotations.LazyToOneOption.NO_PROXY;
import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertNull;
@SuppressWarnings("JUnitMalformedDeclaration")
@DomainModel( @DomainModel(
annotatedClasses = { annotatedClasses = {
OrphanRemovalTest.Entity1.class, OrphanRemovalTest.Entity1.class,
@ -86,7 +85,6 @@ public class OrphanRemovalTest {
protected int lockVersion; protected int lockVersion;
@OneToOne(fetch = LAZY, cascade = ALL, orphanRemoval = true, mappedBy = "parent") @OneToOne(fetch = LAZY, cascade = ALL, orphanRemoval = true, mappedBy = "parent")
@LazyToOne(NO_PROXY)
@LazyGroup("group2") @LazyGroup("group2")
@Fetch(SELECT) @Fetch(SELECT)
protected Entity2 child; protected Entity2 child;
@ -114,7 +112,6 @@ public class OrphanRemovalTest {
public static class Entity2 { public static class Entity2 {
@Id @Id
@OneToOne(fetch = LAZY, optional = false) @OneToOne(fetch = LAZY, optional = false)
@LazyToOne(NO_PROXY)
@LazyGroup("owner") @LazyGroup("owner")
@JoinColumn(name = "parentid", nullable = false, updatable = false, columnDefinition = "smallint") @JoinColumn(name = "parentid", nullable = false, updatable = false, columnDefinition = "smallint")
@Fetch(SELECT) @Fetch(SELECT)

View File

@ -15,14 +15,12 @@ import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode; import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.LazyCollection; import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption; import org.hibernate.annotations.LazyCollectionOption;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.orm.test.util.connections.ConnectionCheckingConnectionProvider; import org.hibernate.orm.test.util.connections.ConnectionCheckingConnectionProvider;
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode; import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.orm.junit.EntityManagerFactoryBasedFunctionalTest; import org.hibernate.testing.orm.junit.EntityManagerFactoryBasedFunctionalTest;
import org.hibernate.testing.orm.junit.JiraKey;
import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@ -41,7 +39,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
/** /**
* @author Selaron * @author Selaron
*/ */
@TestForIssue(jiraKey = "HHH-4808") @JiraKey("HHH-4808")
public class LazyLoadingConnectionCloseTest extends EntityManagerFactoryBasedFunctionalTest { public class LazyLoadingConnectionCloseTest extends EntityManagerFactoryBasedFunctionalTest {
private ConnectionCheckingConnectionProvider connectionProvider; private ConnectionCheckingConnectionProvider connectionProvider;
@ -279,7 +277,6 @@ public class LazyLoadingConnectionCloseTest extends EntityManagerFactoryBasedFun
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn @JoinColumn
@LazyToOne(LazyToOneOption.PROXY)
public SimpleEntity getParent() { public SimpleEntity getParent() {
return parent; return parent;
} }

View File

@ -6,13 +6,21 @@
*/ */
package org.hibernate.orm.test.joinfetch.enhanced; package org.hibernate.orm.test.joinfetch.enhanced;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.HashSet; import java.util.HashSet;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.Set; import java.util.Set;
import org.hibernate.Hibernate;
import org.hibernate.annotations.LazyGroup;
import org.hibernate.testing.bytecode.enhancement.extension.BytecodeEnhanced;
import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.JiraKey;
import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import jakarta.persistence.Access; import jakarta.persistence.Access;
import jakarta.persistence.AccessType; import jakarta.persistence.AccessType;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
@ -22,18 +30,10 @@ import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany; import jakarta.persistence.OneToMany;
import org.hibernate.Hibernate; import static org.junit.jupiter.api.Assertions.assertEquals;
import org.hibernate.annotations.LazyGroup; import static org.junit.jupiter.api.Assertions.assertTrue;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;
import org.hibernate.testing.bytecode.enhancement.extension.BytecodeEnhanced;
import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.JiraKey;
import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@SuppressWarnings("JUnitMalformedDeclaration")
@JiraKey("HHH-12298") @JiraKey("HHH-12298")
@DomainModel( @DomainModel(
annotatedClasses = { annotatedClasses = {
@ -90,7 +90,6 @@ public class JoinFetchWithEnhancementTest {
} }
@OneToMany(targetEntity=OtherEntity.class, mappedBy="employee", fetch=FetchType.LAZY) @OneToMany(targetEntity=OtherEntity.class, mappedBy="employee", fetch=FetchType.LAZY)
@LazyToOne(LazyToOneOption.NO_PROXY)
@LazyGroup("pOtherEntites") @LazyGroup("pOtherEntites")
@Access(AccessType.PROPERTY) @Access(AccessType.PROPERTY)
public Set<OtherEntity> getOtherEntities() { public Set<OtherEntity> getOtherEntities() {
@ -117,7 +116,6 @@ public class JoinFetchWithEnhancementTest {
private String id; private String id;
@ManyToOne @ManyToOne
@LazyToOne(LazyToOneOption.NO_PROXY)
@LazyGroup("Employee") @LazyGroup("Employee")
@JoinColumn(name = "Employee_Id") @JoinColumn(name = "Employee_Id")
private Employee employee = null; private Employee employee = null;

View File

@ -12,10 +12,7 @@ import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import org.hibernate.annotations.LazyToOne;
import static jakarta.persistence.FetchType.LAZY; import static jakarta.persistence.FetchType.LAZY;
import static org.hibernate.annotations.LazyToOneOption.NO_PROXY;
/** /**
* @author Steve Ebersole * @author Steve Ebersole
@ -33,7 +30,6 @@ public class Flight {
private Airport origination; private Airport origination;
@ManyToOne( fetch = LAZY ) @ManyToOne( fetch = LAZY )
@LazyToOne( NO_PROXY )
private Airport destination; private Airport destination;
public Flight() { public Flight() {

View File

@ -27,6 +27,7 @@ import org.junit.jupiter.api.Test;
* Same as {@link LazyToOneTest} except here we have bytecode-enhanced entities * Same as {@link LazyToOneTest} except here we have bytecode-enhanced entities
* via {@link BytecodeEnhanced} * via {@link BytecodeEnhanced}
*/ */
@SuppressWarnings("JUnitMalformedDeclaration")
@DomainModel( @DomainModel(
annotatedClasses = { annotatedClasses = {
Airport.class, Flight.class Airport.class, Flight.class

View File

@ -30,6 +30,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
/** /**
* Same as {@link InstrumentedLazyToOneTest} except here we enable bytecode-enhanced proxies * Same as {@link InstrumentedLazyToOneTest} except here we enable bytecode-enhanced proxies
*/ */
@SuppressWarnings("JUnitMalformedDeclaration")
@DomainModel( @DomainModel(
annotatedClasses = { annotatedClasses = {
Airport.class, Flight.class Airport.class, Flight.class

View File

@ -7,13 +7,8 @@
package org.hibernate.orm.test.mapping.lazytoone; package org.hibernate.orm.test.mapping.lazytoone;
import java.math.BigDecimal; import java.math.BigDecimal;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.bytecode.enhance.spi.interceptor.BytecodeLazyAttributeInterceptor; import org.hibernate.bytecode.enhance.spi.interceptor.BytecodeLazyAttributeInterceptor;
import org.hibernate.bytecode.enhance.spi.interceptor.EnhancementAsProxyLazinessInterceptor; import org.hibernate.bytecode.enhance.spi.interceptor.EnhancementAsProxyLazinessInterceptor;
import org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeLoadingInterceptor; import org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeLoadingInterceptor;
@ -27,6 +22,14 @@ import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.JiraKey; import org.hibernate.testing.orm.junit.JiraKey;
import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope; import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import static jakarta.persistence.FetchType.LAZY; import static jakarta.persistence.FetchType.LAZY;
import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.CoreMatchers.instanceOf;
@ -36,18 +39,14 @@ import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.CoreMatchers.sameInstance; import static org.hamcrest.CoreMatchers.sameInstance;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hibernate.annotations.LazyToOneOption.NO_PROXY;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/** /**
* Baseline test for uni-directional to-one, using an explicit @LazyToOne(NO_PROXY) * Baseline test for uni-directional to-one, using an explicit @LazyToOne(NO_PROXY)
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@SuppressWarnings("JUnitMalformedDeclaration")
@DomainModel( @DomainModel(
annotatedClasses = { annotatedClasses = {
ManyToOneExplicitOptionTests.Customer.class, ManyToOneExplicitOptionTests.Order.class ManyToOneExplicitOptionTests.Customer.class, ManyToOneExplicitOptionTests.Order.class
@ -232,7 +231,6 @@ public class ManyToOneExplicitOptionTests {
@Id @Id
private Integer id; private Integer id;
@ManyToOne( fetch = LAZY ) @ManyToOne( fetch = LAZY )
@LazyToOne( NO_PROXY )
private Customer customer; private Customer customer;
private BigDecimal amount; private BigDecimal amount;

View File

@ -6,13 +6,7 @@
*/ */
package org.hibernate.orm.test.mapping.lazytoone.mappedby; package org.hibernate.orm.test.mapping.lazytoone.mappedby;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.bytecode.enhance.spi.interceptor.EnhancementAsProxyLazinessInterceptor; import org.hibernate.bytecode.enhance.spi.interceptor.EnhancementAsProxyLazinessInterceptor;
import org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeLoadingInterceptor; import org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeLoadingInterceptor;
import org.hibernate.bytecode.spi.BytecodeEnhancementMetadata; import org.hibernate.bytecode.spi.BytecodeEnhancementMetadata;
@ -29,16 +23,21 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import static jakarta.persistence.FetchType.LAZY; import static jakarta.persistence.FetchType.LAZY;
import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hibernate.annotations.LazyToOneOption.NO_PROXY;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
/** /**
* Baseline test for inverse (mappedBy) to-one, using an explicit @LazyToOne(NO_PROXY) * Baseline test for inverse (mappedBy) to-one, using an explicit @LazyToOne(NO_PROXY)
*/ */
@SuppressWarnings("JUnitMalformedDeclaration")
@DomainModel( @DomainModel(
annotatedClasses = { annotatedClasses = {
InverseToOneExplicitOptionTests.Customer.class, InverseToOneExplicitOptionTests.SupplementalInfo.class InverseToOneExplicitOptionTests.Customer.class, InverseToOneExplicitOptionTests.SupplementalInfo.class
@ -217,7 +216,6 @@ public class InverseToOneExplicitOptionTests {
private Integer id; private Integer id;
@OneToOne( fetch = LAZY, mappedBy = "supplementalInfo", optional = false ) @OneToOne( fetch = LAZY, mappedBy = "supplementalInfo", optional = false )
@LazyToOne( value = NO_PROXY )
private Customer customer; private Customer customer;
private String something; private String something;

View File

@ -6,13 +6,7 @@
*/ */
package org.hibernate.orm.test.mapping.lazytoone.onetoone; package org.hibernate.orm.test.mapping.lazytoone.onetoone;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.bytecode.enhance.spi.interceptor.BytecodeLazyAttributeInterceptor; import org.hibernate.bytecode.enhance.spi.interceptor.BytecodeLazyAttributeInterceptor;
import org.hibernate.bytecode.enhance.spi.interceptor.EnhancementAsProxyLazinessInterceptor; import org.hibernate.bytecode.enhance.spi.interceptor.EnhancementAsProxyLazinessInterceptor;
import org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeLoadingInterceptor; import org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeLoadingInterceptor;
@ -30,6 +24,11 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import static jakarta.persistence.FetchType.LAZY; import static jakarta.persistence.FetchType.LAZY;
import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
@ -38,12 +37,12 @@ import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.CoreMatchers.sameInstance; import static org.hamcrest.CoreMatchers.sameInstance;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hibernate.annotations.LazyToOneOption.NO_PROXY;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
/** /**
* Baseline test for uni-directional one-to-one, using an explicit @LazyToOne(NO_PROXY) and allowing enhanced proxies * Baseline test for uni-directional one-to-one, using an explicit @LazyToOne(NO_PROXY) and allowing enhanced proxies
*/ */
@SuppressWarnings("JUnitMalformedDeclaration")
@DomainModel( @DomainModel(
annotatedClasses = { annotatedClasses = {
OneToOneExplicitOptionTests.Customer.class, OneToOneExplicitOptionTests.SupplementalInfo.class OneToOneExplicitOptionTests.Customer.class, OneToOneExplicitOptionTests.SupplementalInfo.class
@ -229,7 +228,6 @@ public class OneToOneExplicitOptionTests {
private Integer id; private Integer id;
@OneToOne( fetch = LAZY, optional = false ) @OneToOne( fetch = LAZY, optional = false )
@LazyToOne( value = NO_PROXY )
private Customer customer; private Customer customer;
private String something; private String something;

View File

@ -1,12 +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>.
*/
/**
* Tests related to {@link org.hibernate.annotations.LazyToOne}, especially
* regarding handling of {@link org.hibernate.annotations.LazyToOneOption#NO_PROXY}
*/
package org.hibernate.orm.test.mapping.lazytoone;

View File

@ -7,16 +7,8 @@
package org.hibernate.orm.test.mapping.lazytoone.polymorphic; package org.hibernate.orm.test.mapping.lazytoone.polymorphic;
import java.math.BigDecimal; import java.math.BigDecimal;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Inheritance;
import jakarta.persistence.InheritanceType;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;
import org.hibernate.proxy.HibernateProxy; import org.hibernate.proxy.HibernateProxy;
import org.hibernate.testing.bytecode.enhancement.EnhancementOptions; import org.hibernate.testing.bytecode.enhancement.EnhancementOptions;
@ -30,6 +22,13 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Inheritance;
import jakarta.persistence.InheritanceType;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import static jakarta.persistence.FetchType.LAZY; import static jakarta.persistence.FetchType.LAZY;
import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
@ -39,6 +38,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
/** /**
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@SuppressWarnings("JUnitMalformedDeclaration")
@DomainModel( @DomainModel(
annotatedClasses = { annotatedClasses = {
PolymorphicToOneExplicitOptionTests.Order.class, PolymorphicToOneExplicitOptionTests.Order.class,
@ -153,7 +153,6 @@ public class PolymorphicToOneExplicitOptionTests {
private Integer id; private Integer id;
private BigDecimal amount; private BigDecimal amount;
@ManyToOne( fetch = LAZY, optional = false ) @ManyToOne( fetch = LAZY, optional = false )
@LazyToOne( LazyToOneOption.NO_PROXY )
private Customer customer; private Customer customer;
public Order() { public Order() {

View File

@ -7,29 +7,29 @@
package org.hibernate.orm.test.proxy; package org.hibernate.orm.test.proxy;
import java.util.List; import java.util.List;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.JiraKey;
import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import jakarta.persistence.CascadeType; import jakarta.persistence.CascadeType;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.FetchType; import jakarta.persistence.FetchType;
import jakarta.persistence.Id; import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne; import jakarta.persistence.ManyToOne;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.orm.junit.DomainModel;
import org.hibernate.testing.orm.junit.SessionFactory;
import org.hibernate.testing.orm.junit.SessionFactoryScope;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
/** /**
* @author Christian Beikov * @author Christian Beikov
*/ */
@TestForIssue(jiraKey = "HHH-9638") @SuppressWarnings("JUnitMalformedDeclaration")
@JiraKey("HHH-9638")
@DomainModel( @DomainModel(
annotatedClasses = { annotatedClasses = {
ProxyReferenceEqualityTest.A.class, ProxyReferenceEqualityTest.A.class,
@ -38,8 +38,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
) )
@SessionFactory @SessionFactory
public class ProxyReferenceEqualityTest { public class ProxyReferenceEqualityTest {
@AfterEach @AfterEach
public void tearDown(SessionFactoryScope scope){ public void tearDown(SessionFactoryScope scope){
scope.inTransaction( scope.inTransaction(
@ -74,7 +72,6 @@ public class ProxyReferenceEqualityTest {
Long id; Long id;
@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL) @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@LazyToOne(LazyToOneOption.NO_PROXY)
B b; B b;
String name; String name;

View File

@ -9,20 +9,12 @@ package org.hibernate.orm.test.serialization;
import java.io.Serializable; import java.io.Serializable;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.annotations.Fetch; import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode; import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.LazyCollection; import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption; import org.hibernate.annotations.LazyCollectionOption;
import org.hibernate.annotations.LazyToOne;
import org.hibernate.annotations.LazyToOneOption;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.internal.util.SerializationHelper; import org.hibernate.internal.util.SerializationHelper;
import org.hibernate.proxy.AbstractLazyInitializer; import org.hibernate.proxy.AbstractLazyInitializer;
@ -37,6 +29,13 @@ import org.hibernate.testing.orm.junit.Setting;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToMany;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
@ -44,6 +43,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
/** /**
* @author Selaron * @author Selaron
*/ */
@SuppressWarnings("JUnitMalformedDeclaration")
@DomainModel(annotatedClasses = { @DomainModel(annotatedClasses = {
EntityProxySerializationTest.SimpleEntity.class, EntityProxySerializationTest.ChildEntity.class EntityProxySerializationTest.SimpleEntity.class, EntityProxySerializationTest.ChildEntity.class
}) })
@ -245,7 +245,6 @@ public class EntityProxySerializationTest {
@ManyToOne(fetch = FetchType.LAZY) @ManyToOne(fetch = FetchType.LAZY)
@JoinColumn @JoinColumn
@LazyToOne(LazyToOneOption.PROXY)
public SimpleEntity getParent() { public SimpleEntity getParent() {
return parent; return parent;
} }