From 52a9de7cacdded9a0b3ff8f94d2c9afccb1cc917 Mon Sep 17 00:00:00 2001 From: Gavin King Date: Thu, 5 Sep 2024 09:58:11 +0200 Subject: [PATCH] more @SuppressWarnings cleanups Signed-off-by: Gavin King --- .../hibernate/orm/test/cuk/CompositePropertyRefTest.java | 2 +- .../org/hibernate/orm/test/hql/ASTParserLoadingTest.java | 4 +--- .../test/mapping/MappedSuperclassWithGenericsTest.java | 2 +- .../orm/test/nationalized/SimpleNationalizedTest.java | 2 +- .../org/hibernate/orm/test/onetomany/OneToManyTest.java | 4 +++- .../test/java/org/hibernate/orm/test/ops/MergeTest.java | 4 ++-- .../orm/test/sql/hand/query/NativeSQLQueriesTest.java | 9 ++------- .../java/org/hibernate/orm/test/stats/StatsTest.java | 2 +- 8 files changed, 12 insertions(+), 17 deletions(-) diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/cuk/CompositePropertyRefTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/cuk/CompositePropertyRefTest.java index f5a2244fe2..8783f891d8 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/cuk/CompositePropertyRefTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/cuk/CompositePropertyRefTest.java @@ -41,7 +41,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; public class CompositePropertyRefTest { @Test - @SuppressWarnings({ "unchecked", "UnusedAssignment" }) + @SuppressWarnings({ "unchecked", "unused" }) public void testOneToOnePropertyRef(SessionFactoryScope scope) { scope.inTransaction( session -> { diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/hql/ASTParserLoadingTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/hql/ASTParserLoadingTest.java index c03b26fc68..a233c70401 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/hql/ASTParserLoadingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/hql/ASTParserLoadingTest.java @@ -2878,7 +2878,6 @@ public class ASTParserLoadingTest extends BaseCoreFunctionalTestCase { @Test @SkipForDialect(value = CockroachDialect.class, comment = "https://github.com/cockroachdb/cockroach/issues/41943") - @SuppressWarnings( {"UnusedAssignment", "UnusedDeclaration"}) public void testSelectExpressions() { createTestBaseData(); Session session = openSession(); @@ -3417,7 +3416,7 @@ public class ASTParserLoadingTest extends BaseCoreFunctionalTestCase { } @Test - @SuppressWarnings( {"UnusedAssignment"}) + @SuppressWarnings("unused") public void testCachedJoinedAndJoinFetchedManyToOne() throws Exception { Animal a = new Animal(); a.setDescription( "an animal" ); @@ -3469,7 +3468,6 @@ public class ASTParserLoadingTest extends BaseCoreFunctionalTestCase { } @Test - @SuppressWarnings( {"UnusedAssignment", "UnusedDeclaration"}) public void testCachedJoinedAndJoinFetchedOneToMany() throws Exception { Animal a = new Animal(); a.setDescription( "an animal" ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/MappedSuperclassWithGenericsTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/MappedSuperclassWithGenericsTest.java index 9ebed2c128..fdf0d4363d 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/MappedSuperclassWithGenericsTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/MappedSuperclassWithGenericsTest.java @@ -99,7 +99,7 @@ public class MappedSuperclassWithGenericsTest { private String keyThree; } - @SuppressWarnings( "UnusedDeclaration" ) + @SuppressWarnings("unused") public static class PK implements Serializable { private String keyOne; private String keyTwo; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/nationalized/SimpleNationalizedTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/nationalized/SimpleNationalizedTest.java index ef99960b40..bc47be18fa 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/nationalized/SimpleNationalizedTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/nationalized/SimpleNationalizedTest.java @@ -44,7 +44,7 @@ import static org.junit.jupiter.api.Assertions.assertSame; @BaseUnitTest public class SimpleNationalizedTest { - @SuppressWarnings({ "UnusedDeclaration", "SpellCheckingInspection" }) + @SuppressWarnings("unused") @Entity(name = "NationalizedEntity") public static class NationalizedEntity { @Id diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/onetomany/OneToManyTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/onetomany/OneToManyTest.java index 22db17dbcd..8873e4d7a6 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/onetomany/OneToManyTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/onetomany/OneToManyTest.java @@ -25,7 +25,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; @SessionFactory public class OneToManyTest { - @SuppressWarnings({ "unchecked", "UnusedAssignment" }) + @SuppressWarnings("unchecked") @Test @RequiresDialectFeature(feature = DialectFeatureChecks.SupportsTemporaryTable.class) public void testOneToManyLinkTable(SessionFactoryScope scope) { @@ -49,6 +49,7 @@ public class OneToManyTest { } ); + @SuppressWarnings("unused") Child merged = scope.fromTransaction( session -> { c.setParent( null ); @@ -67,6 +68,7 @@ public class OneToManyTest { scope.inTransaction( session -> { + @SuppressWarnings("unused") Child child = (Child) session.createQuery( "from Child" ).uniqueResult(); session.createQuery( "from Child c left join fetch c.parent" ).list(); session.createQuery( "from Child c inner join fetch c.parent" ).list(); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/ops/MergeTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/ops/MergeTest.java index 528733f6cc..bd9fac743b 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/ops/MergeTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/ops/MergeTest.java @@ -310,7 +310,7 @@ public class MergeTest extends AbstractOperationTestCase { } @Test - @SuppressWarnings({ "unchecked", "UnusedAssignment", "UnusedDeclaration" }) + @SuppressWarnings({"unchecked", "unused"}) public void testNoExtraUpdatesOnPersistentMergeVersionedWithCollection(SessionFactoryScope scope) { VersionedEntity parent = new VersionedEntity( "parent", "parent" ); VersionedEntity child = new VersionedEntity( "child", "child" ); @@ -337,7 +337,7 @@ public class MergeTest extends AbstractOperationTestCase { VersionedEntity persistentChild = (VersionedEntity) persistentParent.getChildren() .iterator() .next(); - return (VersionedEntity) session.merge( persistentParent ); // <-- This merge leads to failure + return session.merge( persistentParent ); // <-- This merge leads to failure } ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/hand/query/NativeSQLQueriesTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/hand/query/NativeSQLQueriesTest.java index 91d070efaa..003360af1e 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/hand/query/NativeSQLQueriesTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/hand/query/NativeSQLQueriesTest.java @@ -24,7 +24,6 @@ import org.hibernate.Hibernate; import org.hibernate.QueryException; import org.hibernate.Transaction; import org.hibernate.cfg.Environment; -import org.hibernate.dialect.HANADialect; import org.hibernate.dialect.H2Dialect; import org.hibernate.dialect.MySQLDialect; import org.hibernate.orm.test.sql.hand.Dimension; @@ -79,6 +78,7 @@ import static org.junit.jupiter.api.Assertions.fail; xmlMappings = { "org/hibernate/orm/test/sql/hand/query/NativeSQLQueries.hbm.xml" } ) @SessionFactory +@SuppressWarnings({"deprecation", "unused", "rawtypes", "unchecked"}) public class NativeSQLQueriesTest { protected String getOrganizationFetchJoinEmploymentSQL() { @@ -384,7 +384,6 @@ public class NativeSQLQueriesTest { } @Test - @SuppressWarnings( {"deprecation", "UnusedDeclaration"}) public void testMappedAliasStrategy(SessionFactoryScope scope) { Organization ifa = new Organization("IFA"); Organization jboss = new Organization("JBoss"); @@ -466,7 +465,6 @@ public class NativeSQLQueriesTest { } @Test - @SuppressWarnings( {"unchecked"}) @FailureExpected( jiraKey = "unknown" ) public void testCompositeIdJoins(SessionFactoryScope scope) { scope.inTransaction( @@ -535,7 +533,6 @@ public class NativeSQLQueriesTest { } @Test - @SuppressWarnings( {"UnusedDeclaration", "deprecation", "UnusedAssignment"}) public void testAutoDetectAliasing(SessionFactoryScope scope) { Organization ifa = new Organization("IFA"); Organization jboss = new Organization("JBoss"); @@ -676,7 +673,6 @@ public class NativeSQLQueriesTest { } @Test - @SuppressWarnings("unused") public void testExplicitReturnAPI(SessionFactoryScope scope) { Organization jboss = new Organization( "JBoss" ); Person me = new Person( "Steve" ); @@ -787,7 +783,6 @@ public class NativeSQLQueriesTest { } @Test - @SuppressWarnings( {"unchecked", "UnusedDeclaration"}) public void testAddJoinForManyToMany(SessionFactoryScope scope) { Person gavin = new Person( "Gavin" ); Person max = new Person( "Max" ); @@ -813,7 +808,7 @@ public class NativeSQLQueriesTest { session.flush(); session.clear(); - // todo : see http://opensource.atlassian.com/projects/hibernate/browse/HHH-3908 + // todo : see HHH-3908 // String sqlStr = "SELECT {groupp.*} , {gp.*} " + // "FROM GROUPP groupp, GROUP_PERSON gp, PERSON person WHERE groupp.ID = gp.GROUP_ID and person.PERID = gp.PERSON_ID"; // diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/stats/StatsTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/stats/StatsTest.java index 4215b28245..97d8dc721c 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/stats/StatsTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/stats/StatsTest.java @@ -36,7 +36,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; public class StatsTest { // @Test -// @SuppressWarnings( {"UnusedAssignment"}) +// @SuppressWarnings("unused") // public void testCollectionFetchVsLoad() throws Exception { // SessionFactory sf = buildBaseConfiguration() // .setProperty( AvailableSettings.HBM2DDL_AUTO, "create-drop" )