From 06212b57fc9f0d1baba28a302c32534085c792d5 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Tue, 20 Aug 2024 14:06:07 +0200 Subject: [PATCH] Polishing. Remove serialVersionUID for types that aren't serializable. See #3584 --- .../data/jpa/domain/AbstractAuditable.java | 12 +++++------- .../data/jpa/domain/sample/Account.java | 3 --- .../data/jpa/domain/sample/AuditableRole.java | 2 -- .../data/jpa/domain/sample/AuditableUser.java | 8 +++----- .../jpa/domain/sample/CustomAbstractPersistable.java | 1 - .../data/jpa/domain/sample/Parent.java | 8 +++----- .../jpa/domain/sample/PersistableWithIdClass.java | 2 -- .../domain/sample/PersistableWithSingleIdClass.java | 2 -- 8 files changed, 11 insertions(+), 27 deletions(-) diff --git a/spring-data-jpa/src/main/java/org/springframework/data/jpa/domain/AbstractAuditable.java b/spring-data-jpa/src/main/java/org/springframework/data/jpa/domain/AbstractAuditable.java index 46384cb1bd..6cc365619f 100644 --- a/spring-data-jpa/src/main/java/org/springframework/data/jpa/domain/AbstractAuditable.java +++ b/spring-data-jpa/src/main/java/org/springframework/data/jpa/domain/AbstractAuditable.java @@ -15,17 +15,17 @@ */ package org.springframework.data.jpa.domain; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.MappedSuperclass; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; + import java.io.Serializable; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.Date; import java.util.Optional; -import jakarta.persistence.ManyToOne; -import jakarta.persistence.MappedSuperclass; -import jakarta.persistence.Temporal; -import jakarta.persistence.TemporalType; - import org.springframework.data.domain.Auditable; import org.springframework.lang.Nullable; @@ -42,8 +42,6 @@ public abstract class AbstractAuditable extends AbstractPersistable implements Auditable { - private static final long serialVersionUID = 141481953116476081L; - @ManyToOne // private @Nullable U createdBy; diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/sample/Account.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/sample/Account.java index e297d3ab5b..856611e95f 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/sample/Account.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/sample/Account.java @@ -15,8 +15,6 @@ */ package org.springframework.data.jpa.domain.sample; -import java.io.Serial; - import jakarta.persistence.Entity; import org.springframework.data.jpa.domain.AbstractPersistable; @@ -27,5 +25,4 @@ @Entity public class Account extends AbstractPersistable { - private static final long serialVersionUID = -5719129808165758887L; } diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/sample/AuditableRole.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/sample/AuditableRole.java index 855b0ded60..9fa9442b30 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/sample/AuditableRole.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/sample/AuditableRole.java @@ -27,8 +27,6 @@ @Entity public class AuditableRole extends AbstractAuditable { - private static final long serialVersionUID = 5997359055260303863L; - private String name; public void setName(String name) { diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/sample/AuditableUser.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/sample/AuditableUser.java index 794b2cd899..e69864c553 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/sample/AuditableUser.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/sample/AuditableUser.java @@ -15,14 +15,14 @@ */ package org.springframework.data.jpa.domain.sample; -import java.util.HashSet; -import java.util.Set; - import jakarta.persistence.CascadeType; import jakarta.persistence.Entity; import jakarta.persistence.ManyToMany; import jakarta.persistence.NamedQuery; +import java.util.HashSet; +import java.util.Set; + import org.springframework.data.jpa.domain.AbstractAuditable; import org.springframework.lang.Nullable; @@ -37,8 +37,6 @@ @NamedQuery(name = "AuditableUser.findByFirstname", query = "SELECT u FROM AuditableUser u WHERE u.firstname = ?1") public class AuditableUser extends AbstractAuditable { - private static final long serialVersionUID = 7409344446795693011L; - private String firstname; @ManyToMany( diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/sample/CustomAbstractPersistable.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/sample/CustomAbstractPersistable.java index 7209fa41fc..aa136318aa 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/sample/CustomAbstractPersistable.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/sample/CustomAbstractPersistable.java @@ -27,5 +27,4 @@ @Table(name = "customAbstractPersistable") public class CustomAbstractPersistable extends AbstractPersistable { - private static final long serialVersionUID = 1L; } diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/sample/Parent.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/sample/Parent.java index ed392f102e..b0a00f0ace 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/sample/Parent.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/sample/Parent.java @@ -15,15 +15,15 @@ */ package org.springframework.data.jpa.domain.sample; -import java.util.HashSet; -import java.util.Set; - import jakarta.persistence.CascadeType; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; import jakarta.persistence.Id; import jakarta.persistence.ManyToMany; +import java.util.HashSet; +import java.util.Set; + @Entity public class Parent { @@ -31,8 +31,6 @@ public class Parent { @GeneratedValue Long id; - static final long serialVersionUID = -89717120680485957L; - @ManyToMany(cascade = CascadeType.ALL) Set children = new HashSet<>(); diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/sample/PersistableWithIdClass.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/sample/PersistableWithIdClass.java index 6ccab3d688..5b6d1277d9 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/sample/PersistableWithIdClass.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/sample/PersistableWithIdClass.java @@ -30,8 +30,6 @@ @IdClass(PersistableWithIdClassPK.class) public class PersistableWithIdClass implements Persistable { - private static final long serialVersionUID = 1L; - @Id private Long first; diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/sample/PersistableWithSingleIdClass.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/sample/PersistableWithSingleIdClass.java index 9abf2d8a68..38305b4b90 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/sample/PersistableWithSingleIdClass.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/domain/sample/PersistableWithSingleIdClass.java @@ -28,8 +28,6 @@ @IdClass(PersistableWithSingleIdClassPK.class) public class PersistableWithSingleIdClass { - private static final long serialVersionUID = 1L; - @Id private Long first; protected PersistableWithSingleIdClass() {