more @SuppressWarnings cleanups

Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
Gavin King 2024-09-05 09:58:11 +02:00
parent 5748376edc
commit 52a9de7cac
8 changed files with 12 additions and 17 deletions

View File

@ -41,7 +41,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class CompositePropertyRefTest { public class CompositePropertyRefTest {
@Test @Test
@SuppressWarnings({ "unchecked", "UnusedAssignment" }) @SuppressWarnings({ "unchecked", "unused" })
public void testOneToOnePropertyRef(SessionFactoryScope scope) { public void testOneToOnePropertyRef(SessionFactoryScope scope) {
scope.inTransaction( scope.inTransaction(
session -> { session -> {

View File

@ -2878,7 +2878,6 @@ public class ASTParserLoadingTest extends BaseCoreFunctionalTestCase {
@Test @Test
@SkipForDialect(value = CockroachDialect.class, comment = "https://github.com/cockroachdb/cockroach/issues/41943") @SkipForDialect(value = CockroachDialect.class, comment = "https://github.com/cockroachdb/cockroach/issues/41943")
@SuppressWarnings( {"UnusedAssignment", "UnusedDeclaration"})
public void testSelectExpressions() { public void testSelectExpressions() {
createTestBaseData(); createTestBaseData();
Session session = openSession(); Session session = openSession();
@ -3417,7 +3416,7 @@ public class ASTParserLoadingTest extends BaseCoreFunctionalTestCase {
} }
@Test @Test
@SuppressWarnings( {"UnusedAssignment"}) @SuppressWarnings("unused")
public void testCachedJoinedAndJoinFetchedManyToOne() throws Exception { public void testCachedJoinedAndJoinFetchedManyToOne() throws Exception {
Animal a = new Animal(); Animal a = new Animal();
a.setDescription( "an animal" ); a.setDescription( "an animal" );
@ -3469,7 +3468,6 @@ public class ASTParserLoadingTest extends BaseCoreFunctionalTestCase {
} }
@Test @Test
@SuppressWarnings( {"UnusedAssignment", "UnusedDeclaration"})
public void testCachedJoinedAndJoinFetchedOneToMany() throws Exception { public void testCachedJoinedAndJoinFetchedOneToMany() throws Exception {
Animal a = new Animal(); Animal a = new Animal();
a.setDescription( "an animal" ); a.setDescription( "an animal" );

View File

@ -99,7 +99,7 @@ public class MappedSuperclassWithGenericsTest {
private String keyThree; private String keyThree;
} }
@SuppressWarnings( "UnusedDeclaration" ) @SuppressWarnings("unused")
public static class PK implements Serializable { public static class PK implements Serializable {
private String keyOne; private String keyOne;
private String keyTwo; private String keyTwo;

View File

@ -44,7 +44,7 @@ import static org.junit.jupiter.api.Assertions.assertSame;
@BaseUnitTest @BaseUnitTest
public class SimpleNationalizedTest { public class SimpleNationalizedTest {
@SuppressWarnings({ "UnusedDeclaration", "SpellCheckingInspection" }) @SuppressWarnings("unused")
@Entity(name = "NationalizedEntity") @Entity(name = "NationalizedEntity")
public static class NationalizedEntity { public static class NationalizedEntity {
@Id @Id

View File

@ -25,7 +25,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
@SessionFactory @SessionFactory
public class OneToManyTest { public class OneToManyTest {
@SuppressWarnings({ "unchecked", "UnusedAssignment" }) @SuppressWarnings("unchecked")
@Test @Test
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsTemporaryTable.class) @RequiresDialectFeature(feature = DialectFeatureChecks.SupportsTemporaryTable.class)
public void testOneToManyLinkTable(SessionFactoryScope scope) { public void testOneToManyLinkTable(SessionFactoryScope scope) {
@ -49,6 +49,7 @@ public class OneToManyTest {
} }
); );
@SuppressWarnings("unused")
Child merged = scope.fromTransaction( Child merged = scope.fromTransaction(
session -> { session -> {
c.setParent( null ); c.setParent( null );
@ -67,6 +68,7 @@ public class OneToManyTest {
scope.inTransaction( scope.inTransaction(
session -> { session -> {
@SuppressWarnings("unused")
Child child = (Child) session.createQuery( "from Child" ).uniqueResult(); Child child = (Child) session.createQuery( "from Child" ).uniqueResult();
session.createQuery( "from Child c left join fetch c.parent" ).list(); session.createQuery( "from Child c left join fetch c.parent" ).list();
session.createQuery( "from Child c inner join fetch c.parent" ).list(); session.createQuery( "from Child c inner join fetch c.parent" ).list();

View File

@ -310,7 +310,7 @@ public class MergeTest extends AbstractOperationTestCase {
} }
@Test @Test
@SuppressWarnings({ "unchecked", "UnusedAssignment", "UnusedDeclaration" }) @SuppressWarnings({"unchecked", "unused"})
public void testNoExtraUpdatesOnPersistentMergeVersionedWithCollection(SessionFactoryScope scope) { public void testNoExtraUpdatesOnPersistentMergeVersionedWithCollection(SessionFactoryScope scope) {
VersionedEntity parent = new VersionedEntity( "parent", "parent" ); VersionedEntity parent = new VersionedEntity( "parent", "parent" );
VersionedEntity child = new VersionedEntity( "child", "child" ); VersionedEntity child = new VersionedEntity( "child", "child" );
@ -337,7 +337,7 @@ public class MergeTest extends AbstractOperationTestCase {
VersionedEntity persistentChild = (VersionedEntity) persistentParent.getChildren() VersionedEntity persistentChild = (VersionedEntity) persistentParent.getChildren()
.iterator() .iterator()
.next(); .next();
return (VersionedEntity) session.merge( persistentParent ); // <-- This merge leads to failure return session.merge( persistentParent ); // <-- This merge leads to failure
} }
); );

View File

@ -24,7 +24,6 @@ import org.hibernate.Hibernate;
import org.hibernate.QueryException; import org.hibernate.QueryException;
import org.hibernate.Transaction; import org.hibernate.Transaction;
import org.hibernate.cfg.Environment; import org.hibernate.cfg.Environment;
import org.hibernate.dialect.HANADialect;
import org.hibernate.dialect.H2Dialect; import org.hibernate.dialect.H2Dialect;
import org.hibernate.dialect.MySQLDialect; import org.hibernate.dialect.MySQLDialect;
import org.hibernate.orm.test.sql.hand.Dimension; 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" } xmlMappings = { "org/hibernate/orm/test/sql/hand/query/NativeSQLQueries.hbm.xml" }
) )
@SessionFactory @SessionFactory
@SuppressWarnings({"deprecation", "unused", "rawtypes", "unchecked"})
public class NativeSQLQueriesTest { public class NativeSQLQueriesTest {
protected String getOrganizationFetchJoinEmploymentSQL() { protected String getOrganizationFetchJoinEmploymentSQL() {
@ -384,7 +384,6 @@ public class NativeSQLQueriesTest {
} }
@Test @Test
@SuppressWarnings( {"deprecation", "UnusedDeclaration"})
public void testMappedAliasStrategy(SessionFactoryScope scope) { public void testMappedAliasStrategy(SessionFactoryScope scope) {
Organization ifa = new Organization("IFA"); Organization ifa = new Organization("IFA");
Organization jboss = new Organization("JBoss"); Organization jboss = new Organization("JBoss");
@ -466,7 +465,6 @@ public class NativeSQLQueriesTest {
} }
@Test @Test
@SuppressWarnings( {"unchecked"})
@FailureExpected( jiraKey = "unknown" ) @FailureExpected( jiraKey = "unknown" )
public void testCompositeIdJoins(SessionFactoryScope scope) { public void testCompositeIdJoins(SessionFactoryScope scope) {
scope.inTransaction( scope.inTransaction(
@ -535,7 +533,6 @@ public class NativeSQLQueriesTest {
} }
@Test @Test
@SuppressWarnings( {"UnusedDeclaration", "deprecation", "UnusedAssignment"})
public void testAutoDetectAliasing(SessionFactoryScope scope) { public void testAutoDetectAliasing(SessionFactoryScope scope) {
Organization ifa = new Organization("IFA"); Organization ifa = new Organization("IFA");
Organization jboss = new Organization("JBoss"); Organization jboss = new Organization("JBoss");
@ -676,7 +673,6 @@ public class NativeSQLQueriesTest {
} }
@Test @Test
@SuppressWarnings("unused")
public void testExplicitReturnAPI(SessionFactoryScope scope) { public void testExplicitReturnAPI(SessionFactoryScope scope) {
Organization jboss = new Organization( "JBoss" ); Organization jboss = new Organization( "JBoss" );
Person me = new Person( "Steve" ); Person me = new Person( "Steve" );
@ -787,7 +783,6 @@ public class NativeSQLQueriesTest {
} }
@Test @Test
@SuppressWarnings( {"unchecked", "UnusedDeclaration"})
public void testAddJoinForManyToMany(SessionFactoryScope scope) { public void testAddJoinForManyToMany(SessionFactoryScope scope) {
Person gavin = new Person( "Gavin" ); Person gavin = new Person( "Gavin" );
Person max = new Person( "Max" ); Person max = new Person( "Max" );
@ -813,7 +808,7 @@ public class NativeSQLQueriesTest {
session.flush(); session.flush();
session.clear(); session.clear();
// todo : see http://opensource.atlassian.com/projects/hibernate/browse/HHH-3908 // todo : see HHH-3908
// String sqlStr = "SELECT {groupp.*} , {gp.*} " + // 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"; // "FROM GROUPP groupp, GROUP_PERSON gp, PERSON person WHERE groupp.ID = gp.GROUP_ID and person.PERID = gp.PERSON_ID";
// //

View File

@ -36,7 +36,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
public class StatsTest { public class StatsTest {
// @Test // @Test
// @SuppressWarnings( {"UnusedAssignment"}) // @SuppressWarnings("unused")
// public void testCollectionFetchVsLoad() throws Exception { // public void testCollectionFetchVsLoad() throws Exception {
// SessionFactory sf = buildBaseConfiguration() // SessionFactory sf = buildBaseConfiguration()
// .setProperty( AvailableSettings.HBM2DDL_AUTO, "create-drop" ) // .setProperty( AvailableSettings.HBM2DDL_AUTO, "create-drop" )