From 5d91c890573f42c7c7228cd7e5e8a3ffa33a0823 Mon Sep 17 00:00:00 2001 From: Gavin King Date: Sat, 15 Jun 2024 21:47:50 +0200 Subject: [PATCH] HHH-18192 remove @Loader Signed-off-by: Gavin King --- .../org/hibernate/annotations/HQLSelect.java | 3 - .../org/hibernate/annotations/Loader.java | 33 ---------- .../org/hibernate/annotations/SQLSelect.java | 3 - .../boot/model/internal/CollectionBinder.java | 6 -- .../boot/model/internal/EntityBinder.java | 10 ---- .../boot/models/HibernateAnnotations.java | 4 -- .../internal/LoaderAnnotation.java | 60 ------------------- .../test/annotations/loader/LoaderTest.java | 6 -- .../loader/LoaderWithInvalidQueryTest.java | 10 ++-- .../orm/test/annotations/loader/Team.java | 8 ++- .../orm/test/annotations/query/Chaos.java | 6 +- .../CustomSqlSchemaResolvingIdentityTest.java | 10 +--- .../entity/CustomSqlSchemaResolvingTest.java | 10 +--- .../orm/test/sql/CollectionLoaderTest.java | 20 +------ .../test/sql/CustomSQLSecondaryTableTest.java | 27 ++++----- ...racleCustomSQLWithStoredProcedureTest.java | 15 +---- .../test/annotations/loader/Loader.hbm.xml | 27 --------- 17 files changed, 31 insertions(+), 227 deletions(-) delete mode 100644 hibernate-core/src/main/java/org/hibernate/annotations/Loader.java delete mode 100644 hibernate-core/src/main/java/org/hibernate/boot/models/annotations/internal/LoaderAnnotation.java delete mode 100644 hibernate-core/src/test/resources/org/hibernate/orm/test/annotations/loader/Loader.hbm.xml diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/HQLSelect.java b/hibernate-core/src/main/java/org/hibernate/annotations/HQLSelect.java index 3da87ef4ea..c6e86f948b 100644 --- a/hibernate-core/src/main/java/org/hibernate/annotations/HQLSelect.java +++ b/hibernate-core/src/main/java/org/hibernate/annotations/HQLSelect.java @@ -36,9 +36,6 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME; * @author Gavin King * * @since 6.2 - * - * @implNote This annotation is just an abbreviation for {@link Loader} - * together with {@link NamedQuery}. */ @Target({TYPE, FIELD, METHOD}) @Retention(RUNTIME) diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/Loader.java b/hibernate-core/src/main/java/org/hibernate/annotations/Loader.java deleted file mode 100644 index 38f18e15b7..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/annotations/Loader.java +++ /dev/null @@ -1,33 +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 . - */ -package org.hibernate.annotations; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -/** - * Specifies that a named query should be used to load an entity or - * collection, overriding the SQL that Hibernate generates by default. - * - * @author László Benke - * - * @deprecated Use {@link SQLSelect} or {@link HQLSelect}. - */ -@Target( {TYPE, FIELD, METHOD} ) -@Retention( RUNTIME ) -@Deprecated(since = "6.2") -public @interface Loader { - /** - * The named query to use for loading the entity or collection. - */ - String namedQuery() default ""; -} diff --git a/hibernate-core/src/main/java/org/hibernate/annotations/SQLSelect.java b/hibernate-core/src/main/java/org/hibernate/annotations/SQLSelect.java index a42956c32f..77e8927fe5 100644 --- a/hibernate-core/src/main/java/org/hibernate/annotations/SQLSelect.java +++ b/hibernate-core/src/main/java/org/hibernate/annotations/SQLSelect.java @@ -56,9 +56,6 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME; * @author Gavin King * * @since 6.2 - * - * @implNote This annotation is just an abbreviation for {@link Loader} - * together with {@link NamedNativeQuery}. */ @Target({TYPE, FIELD, METHOD}) @Retention(RUNTIME) diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionBinder.java index c2c26c25a4..7ed5ba0a6a 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/CollectionBinder.java @@ -46,7 +46,6 @@ import org.hibernate.annotations.ListIndexBase; import org.hibernate.annotations.ListIndexJavaType; import org.hibernate.annotations.ListIndexJdbcType; import org.hibernate.annotations.ListIndexJdbcTypeCode; -import org.hibernate.annotations.Loader; import org.hibernate.annotations.ManyToAny; import org.hibernate.annotations.MapKeyJavaType; import org.hibernate.annotations.MapKeyJdbcType; @@ -1414,11 +1413,6 @@ public abstract class CollectionBinder { collection.setLoaderName( loaderName ); QueryBinder.bindQuery( loaderName, hqlSelect, buildingContext ); } - - final Loader loader = property.getDirectAnnotationUsage( Loader.class ); - if ( loader != null ) { - collection.setLoaderName( loader.namedQuery() ); - } } private void applySortingAndOrdering() { diff --git a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java index da85ff3ed9..f5b5764038 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/model/internal/EntityBinder.java @@ -32,7 +32,6 @@ import org.hibernate.annotations.Filter; import org.hibernate.annotations.Filters; import org.hibernate.annotations.HQLSelect; import org.hibernate.annotations.Immutable; -import org.hibernate.annotations.Loader; import org.hibernate.annotations.Mutability; import org.hibernate.annotations.NaturalIdCache; import org.hibernate.annotations.OnDelete; @@ -1348,8 +1347,6 @@ public class EntityBinder { ensureNoMutabilityPlan(); - bindCustomLoader(); - registerImportName(); processNamedEntityGraphs(); @@ -1466,13 +1463,6 @@ public class EntityBinder { } } - private void bindCustomLoader() { - final Loader loader = annotatedClass.getAnnotationUsage( Loader.class, getSourceModelContext() ); - if ( loader != null ) { - persistentClass.setLoaderName( loader.namedQuery() ); - } - } - private void bindSubselect() { final Subselect subselect = annotatedClass.getAnnotationUsage( Subselect.class, getSourceModelContext() ); if ( subselect != null ) { diff --git a/hibernate-core/src/main/java/org/hibernate/boot/models/HibernateAnnotations.java b/hibernate-core/src/main/java/org/hibernate/boot/models/HibernateAnnotations.java index 955160d5ce..22832091fb 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/models/HibernateAnnotations.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/models/HibernateAnnotations.java @@ -402,10 +402,6 @@ public interface HibernateAnnotations { ListIndexJdbcTypeCode.class, ListIndexJdbcTypeCodeAnnotation.class ); - OrmAnnotationDescriptor LOADER = new OrmAnnotationDescriptor<>( - Loader.class, - LoaderAnnotation.class - ); OrmAnnotationDescriptor MANY_TO_ANY = new OrmAnnotationDescriptor<>( ManyToAny.class, ManyToAnyAnnotation.class diff --git a/hibernate-core/src/main/java/org/hibernate/boot/models/annotations/internal/LoaderAnnotation.java b/hibernate-core/src/main/java/org/hibernate/boot/models/annotations/internal/LoaderAnnotation.java deleted file mode 100644 index 87d2ca1da0..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/boot/models/annotations/internal/LoaderAnnotation.java +++ /dev/null @@ -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.Loader; -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 LoaderAnnotation implements Loader { - private String namedQuery; - - /** - * Used in creating dynamic annotation instances (e.g. from XML) - */ - public LoaderAnnotation(SourceModelBuildingContext modelContext) { - this.namedQuery = ""; - } - - /** - * Used in creating annotation instances from JDK variant - */ - public LoaderAnnotation(Loader annotation, SourceModelBuildingContext modelContext) { - this.namedQuery = annotation.namedQuery(); - } - - /** - * Used in creating annotation instances from Jandex variant - */ - public LoaderAnnotation(AnnotationInstance annotation, SourceModelBuildingContext modelContext) { - this.namedQuery = extractJandexValue( annotation, HibernateAnnotations.LOADER, "namedQuery", modelContext ); - } - - @Override - public Class annotationType() { - return Loader.class; - } - - @Override - public String namedQuery() { - return namedQuery; - } - - public void namedQuery(String value) { - this.namedQuery = value; - } - - -} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/loader/LoaderTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/loader/LoaderTest.java index 978bc5763d..d1b711ab10 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/loader/LoaderTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/loader/LoaderTest.java @@ -24,12 +24,6 @@ import org.junit.Test; * @author Emmanuel Bernard */ public class LoaderTest extends BaseCoreFunctionalTestCase { - @Override - protected String[] getOrmXmlFiles() { - return new String[] { - "org/hibernate/orm/test/annotations/loader/Loader.hbm.xml" - }; - } @Override protected Class[] getAnnotatedClasses() { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/loader/LoaderWithInvalidQueryTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/loader/LoaderWithInvalidQueryTest.java index 437ef460e0..a436721db4 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/loader/LoaderWithInvalidQueryTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/loader/LoaderWithInvalidQueryTest.java @@ -12,7 +12,7 @@ import jakarta.persistence.GeneratedValue; import jakarta.persistence.Id; import org.hibernate.HibernateException; -import org.hibernate.annotations.Loader; +import org.hibernate.annotations.HQLSelect; import org.hibernate.annotations.NamedQuery; import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase; @@ -43,8 +43,8 @@ public class LoaderWithInvalidQueryTest extends BaseEntityManagerFunctionalTestC HibernateException rootCause = (HibernateException) ExceptionUtil.rootCause( expected ); Throwable[] suppressed = rootCause.getSuppressed(); assertEquals( 2, suppressed.length ); - assertTrue( ExceptionUtil.rootCause( suppressed[0] ).getMessage().contains( "Could not resolve attribute 'valid'" ) ); - assertTrue( ExceptionUtil.rootCause( suppressed[1] ).getMessage().contains( "Could not resolve root entity '_Person'" ) ); + assertTrue( ExceptionUtil.rootCause( suppressed[0] ).getMessage().contains( "Could not resolve root entity '_Person'" ) ); + assertTrue( ExceptionUtil.rootCause( suppressed[1] ).getMessage().contains( "Could not resolve attribute 'valid'" ) ); } } @@ -54,9 +54,7 @@ public class LoaderWithInvalidQueryTest extends BaseEntityManagerFunctionalTestC @Entity(name = "Person") - @Loader(namedQuery = "invalid_sql") - @NamedQuery( - name = "invalid_sql", + @HQLSelect( query = "SELECT p " + "FROM Person p " + "WHERE p.id = ?1 and p.valid = true" diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/loader/Team.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/loader/Team.java index 9a046377c0..eaa7e7cc01 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/loader/Team.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/loader/Team.java @@ -8,14 +8,16 @@ package org.hibernate.orm.test.annotations.loader; import java.util.HashSet; import java.util.Set; import jakarta.persistence.Entity; +import jakarta.persistence.EntityResult; import jakarta.persistence.FetchType; import jakarta.persistence.GeneratedValue; import jakarta.persistence.Id; import jakarta.persistence.OneToMany; +import jakarta.persistence.SqlResultSetMapping; import org.hibernate.annotations.Fetch; import org.hibernate.annotations.FetchMode; -import org.hibernate.annotations.Loader; +import org.hibernate.annotations.SQLSelect; @Entity public class Team { @@ -34,7 +36,9 @@ public class Team { @OneToMany(targetEntity = Player.class, mappedBy = "team", fetch = FetchType.EAGER) @Fetch(FetchMode.SELECT) - @Loader(namedQuery = "loadByTeam") + @SQLSelect(sql = "select * from Player where team_id = ?1", + resultSetMapping = @SqlResultSetMapping(name = "", + entities = @EntityResult(entityClass = Player.class))) public Set getPlayers() { return players; } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/query/Chaos.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/query/Chaos.java index b9f15fc164..c17d03b88a 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/query/Chaos.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/query/Chaos.java @@ -13,14 +13,13 @@ import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.Id; import jakarta.persistence.JoinColumn; -import jakarta.persistence.NamedNativeQuery; import jakarta.persistence.OneToMany; import jakarta.persistence.Table; -import org.hibernate.annotations.Loader; import org.hibernate.annotations.SQLDelete; import org.hibernate.annotations.SQLDeleteAll; import org.hibernate.annotations.SQLInsert; +import org.hibernate.annotations.SQLSelect; import org.hibernate.annotations.SQLUpdate; /** @@ -31,8 +30,7 @@ import org.hibernate.annotations.SQLUpdate; @SQLInsert( sql="INSERT INTO CHAOS(name, nick_name, chaos_size, id) VALUES(upper(?),?,?,?)") @SQLUpdate( sql="UPDATE CHAOS SET name = upper(?), nick_name = ?, chaos_size = ? WHERE id = ?") @SQLDelete( sql="DELETE CHAOS WHERE id = ?") -@Loader(namedQuery = "chaos") -@NamedNativeQuery(name="chaos", query="select id, chaos_size, name, lower( nick_name ) as nick_name from CHAOS where id= ?", resultClass = Chaos.class) +@SQLSelect( sql="select id, chaos_size, name, lower( nick_name ) as nick_name from CHAOS where id= ?" ) public class Chaos { @Id private Long id; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/persister/entity/CustomSqlSchemaResolvingIdentityTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/persister/entity/CustomSqlSchemaResolvingIdentityTest.java index 1e022f6b6e..e0b5db7857 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/persister/entity/CustomSqlSchemaResolvingIdentityTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/persister/entity/CustomSqlSchemaResolvingIdentityTest.java @@ -6,11 +6,10 @@ */ package org.hibernate.orm.test.persister.entity; -import org.hibernate.annotations.Loader; -import org.hibernate.annotations.NamedNativeQuery; import org.hibernate.annotations.ResultCheckStyle; import org.hibernate.annotations.SQLDelete; import org.hibernate.annotations.SQLInsert; +import org.hibernate.annotations.SQLSelect; import org.hibernate.annotations.SQLUpdate; import org.hibernate.dialect.H2Dialect; import org.hibernate.persister.entity.AbstractEntityPersister; @@ -87,12 +86,7 @@ public class CustomSqlSchemaResolvingIdentityTest { } @Entity(name = "CardWithCustomSQL") - @Loader(namedQuery = "find_foo_by_id") - @NamedNativeQuery( - name = "find_foo_by_id", - query = "SELECT id, name FROM {h-schema}FOO WHERE id = ?", - resultClass = CustomEntity.class - ) + @SQLSelect(sql = "SELECT id, name FROM {h-schema}FOO WHERE id = ?") @SQLInsert(sql = "INSERT INTO {h-schema}FOO (name) VALUES (?)") @SQLDelete(sql = "DELETE FROM {h-schema}FOO WHERE id = ?", check = ResultCheckStyle.COUNT) @SQLUpdate(sql = "UPDATE {h-schema}FOO SET name = ? WHERE id = ? ") diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/persister/entity/CustomSqlSchemaResolvingTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/persister/entity/CustomSqlSchemaResolvingTest.java index f0e54f3624..d325dfd83a 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/persister/entity/CustomSqlSchemaResolvingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/persister/entity/CustomSqlSchemaResolvingTest.java @@ -6,11 +6,10 @@ */ package org.hibernate.orm.test.persister.entity; -import org.hibernate.annotations.Loader; -import org.hibernate.annotations.NamedNativeQuery; import org.hibernate.annotations.ResultCheckStyle; import org.hibernate.annotations.SQLDelete; import org.hibernate.annotations.SQLInsert; +import org.hibernate.annotations.SQLSelect; import org.hibernate.annotations.SQLUpdate; import org.hibernate.persister.entity.AbstractEntityPersister; import org.hibernate.sql.model.jdbc.JdbcMutationOperation; @@ -81,12 +80,7 @@ public class CustomSqlSchemaResolvingTest { } @Entity(name = "CardWithCustomSQL") - @Loader(namedQuery = "find_foo_by_id") - @NamedNativeQuery( - name = "find_foo_by_id", - query = "SELECT id, name FROM {h-schema}FOO WHERE id = ?", - resultClass = CustomEntity.class - ) + @SQLSelect(sql = "SELECT id, name FROM {h-schema}FOO WHERE id = ?") @SQLInsert(sql = "INSERT INTO {h-schema}FOO (name, id) VALUES (?, ?)") @SQLDelete(sql = "DELETE FROM {h-schema}FOO WHERE id = ?", check = ResultCheckStyle.COUNT) @SQLUpdate(sql = "UPDATE {h-schema}FOO SET name = ? WHERE id = ? ") diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/CollectionLoaderTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/CollectionLoaderTest.java index 74b73fb4e1..13c0736933 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/CollectionLoaderTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/CollectionLoaderTest.java @@ -16,12 +16,11 @@ import jakarta.persistence.ElementCollection; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; import jakarta.persistence.Id; -import jakarta.persistence.NamedNativeQuery; -import org.hibernate.annotations.Loader; import org.hibernate.annotations.SQLDelete; import org.hibernate.annotations.SQLDeleteAll; import org.hibernate.annotations.SQLInsert; +import org.hibernate.annotations.SQLSelect; import org.hibernate.annotations.SQLUpdate; import org.hibernate.dialect.H2Dialect; import org.hibernate.dialect.PostgreSQLDialect; @@ -114,20 +113,7 @@ public class CollectionLoaderTest extends BaseEntityManagerFunctionalTestCase { @SQLInsert(sql = "INSERT INTO person (name, id, valid) VALUES (?, ?, true) ", check = COUNT) @SQLUpdate(sql = "UPDATE person SET name = ? where id = ? ") @SQLDelete(sql = "UPDATE person SET valid = false WHERE id = ? ") - @Loader(namedQuery = "find_valid_person") - @NamedNativeQuery( - name = "find_valid_person", - query = "SELECT id, name " + - "FROM person " + - "WHERE id = ? and valid = true", - resultClass = Person.class - ) - @NamedNativeQuery( - name = "find_valid_phones", - query = "SELECT phones " + - "FROM Person_phones " + - "WHERE person_id = ? and valid = true " - ) + @SQLSelect(sql = "SELECT id, name FROM person WHERE id = ? and valid = true") public static class Person { @Id @@ -139,7 +125,7 @@ public class CollectionLoaderTest extends BaseEntityManagerFunctionalTestCase { @ElementCollection @SQLInsert(sql = "INSERT INTO person_phones (person_id, phones, valid) VALUES (?, ?, true) ") @SQLDeleteAll(sql = "UPDATE person_phones SET valid = false WHERE person_id = ?") - @Loader(namedQuery = "find_valid_phones") + @SQLSelect(sql = "SELECT phones FROM Person_phones WHERE person_id = ? and valid = true") private List phones = new ArrayList<>(); public Long getId() { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/CustomSQLSecondaryTableTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/CustomSQLSecondaryTableTest.java index 5aac7fd3f4..23c03a0422 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/CustomSQLSecondaryTableTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/CustomSQLSecondaryTableTest.java @@ -11,17 +11,15 @@ import jakarta.persistence.Column; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; import jakarta.persistence.Id; -import jakarta.persistence.NamedNativeQueries; -import jakarta.persistence.NamedNativeQuery; import jakarta.persistence.PrimaryKeyJoinColumn; import jakarta.persistence.SecondaryTable; import jakarta.persistence.Table; import org.hibernate.Session; -import org.hibernate.annotations.Loader; import org.hibernate.annotations.ResultCheckStyle; import org.hibernate.annotations.SQLDelete; import org.hibernate.annotations.SQLInsert; +import org.hibernate.annotations.SQLSelect; import org.hibernate.dialect.H2Dialect; import org.hibernate.dialect.PostgreSQLDialect; import org.hibernate.orm.test.jpa.BaseEntityManagerFunctionalTestCase; @@ -108,20 +106,15 @@ public class CustomSQLSecondaryTableTest extends BaseEntityManagerFunctionalTest sql = "UPDATE person_details SET valid = false WHERE person_id = ? " ) - @Loader(namedQuery = "find_valid_person") - @NamedNativeQueries({ - @NamedNativeQuery( - name = "find_valid_person", - query = "SELECT " + - " p.id, " + - " p.name, " + - " pd.image " + - "FROM person p " + - "LEFT OUTER JOIN person_details pd ON p.id = pd.person_id " + - "WHERE p.id = ? AND p.valid = true AND pd.valid = true", - resultClass = Person.class - ) - }) + @SQLSelect( + sql = "SELECT " + + " p.id, " + + " p.name, " + + " pd.image " + + "FROM person p " + + "LEFT OUTER JOIN person_details pd ON p.id = pd.person_id " + + "WHERE p.id = ? AND p.valid = true AND pd.valid = true" + ) public static class Person { @Id diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/OracleCustomSQLWithStoredProcedureTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/OracleCustomSQLWithStoredProcedureTest.java index f37a21303f..a1a92c0044 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/OracleCustomSQLWithStoredProcedureTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/OracleCustomSQLWithStoredProcedureTest.java @@ -9,10 +9,10 @@ package org.hibernate.orm.test.sql; import java.sql.Statement; import org.hibernate.Session; -import org.hibernate.annotations.Loader; import org.hibernate.annotations.ResultCheckStyle; import org.hibernate.annotations.SQLDelete; import org.hibernate.annotations.SQLInsert; +import org.hibernate.annotations.SQLSelect; import org.hibernate.dialect.OracleDialect; import org.hibernate.testing.orm.junit.EntityManagerFactoryScope; @@ -24,8 +24,6 @@ import org.junit.jupiter.api.Test; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; import jakarta.persistence.Id; -import jakarta.persistence.NamedNativeQueries; -import jakarta.persistence.NamedNativeQuery; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; @@ -98,16 +96,7 @@ public class OracleCustomSQLWithStoredProcedureTest { callable = true ) //end::sql-sp-custom-crud-example[] - @Loader(namedQuery = "find_valid_person") - @NamedNativeQueries({ - @NamedNativeQuery( - name = "find_valid_person", - query = "SELECT id, name " + - "FROM person " + - "WHERE id = ? and valid = 1", - resultClass = Person.class - ) - }) + @SQLSelect(sql = "SELECT id, name FROM person WHERE id = ? and valid = 1") public static class Person { @Id diff --git a/hibernate-core/src/test/resources/org/hibernate/orm/test/annotations/loader/Loader.hbm.xml b/hibernate-core/src/test/resources/org/hibernate/orm/test/annotations/loader/Loader.hbm.xml deleted file mode 100644 index b59ba70eb9..0000000000 --- a/hibernate-core/src/test/resources/org/hibernate/orm/test/annotations/loader/Loader.hbm.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - select {p.*} from Player p where p.team_id = ?1 - - - \ No newline at end of file