Skip to content

Commit

Permalink
Polishing.
Browse files Browse the repository at this point in the history
Remove serialVersionUID for types that aren't serializable.

See spring-projects#3584
  • Loading branch information
mp911de committed Aug 20, 2024
1 parent 55a3112 commit 06212b5
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -42,8 +42,6 @@
public abstract class AbstractAuditable<U, PK extends Serializable> extends AbstractPersistable<PK>
implements Auditable<U, PK, LocalDateTime> {

private static final long serialVersionUID = 141481953116476081L;

@ManyToOne //
private @Nullable U createdBy;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -27,5 +25,4 @@
@Entity
public class Account extends AbstractPersistable<Long> {

private static final long serialVersionUID = -5719129808165758887L;
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
@Entity
public class AuditableRole extends AbstractAuditable<AuditableUser, Long> {

private static final long serialVersionUID = 5997359055260303863L;

private String name;

public void setName(String name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -37,8 +37,6 @@
@NamedQuery(name = "AuditableUser.findByFirstname", query = "SELECT u FROM AuditableUser u WHERE u.firstname = ?1")
public class AuditableUser extends AbstractAuditable<AuditableUser, Integer> {

private static final long serialVersionUID = 7409344446795693011L;

private String firstname;

@ManyToMany(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,4 @@
@Table(name = "customAbstractPersistable")
public class CustomAbstractPersistable extends AbstractPersistable<Long> {

private static final long serialVersionUID = 1L;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,22 @@
*/
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 {

@Id
@GeneratedValue
Long id;

static final long serialVersionUID = -89717120680485957L;

@ManyToMany(cascade = CascadeType.ALL)
Set<Child> children = new HashSet<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
@IdClass(PersistableWithIdClassPK.class)
public class PersistableWithIdClass implements Persistable<PersistableWithIdClassPK> {

private static final long serialVersionUID = 1L;

@Id
private
Long first;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
@IdClass(PersistableWithSingleIdClassPK.class)
public class PersistableWithSingleIdClass {

private static final long serialVersionUID = 1L;

@Id private Long first;

protected PersistableWithSingleIdClass() {
Expand Down

0 comments on commit 06212b5

Please sign in to comment.