Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#332 - Remove @Data annotation from jpa classes #345

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,24 +1,43 @@
package de.numcodex.feasibility_gui_backend.dse.persistence;

import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.*;
import org.hibernate.proxy.HibernateProxy;

import java.io.Serializable;
import java.util.Objects;

@Entity
@Table(name = "dse_profile", schema = "public")
@Data
@EqualsAndHashCode
@Getter
@Setter
@ToString
@RequiredArgsConstructor
public class DseProfile implements Serializable {
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Id
@Column(name = "id", nullable = false)
private int id;
private Long id;
@Basic
@Column(name = "url", nullable = false, length = -1)
private String url;
@Basic
@Column(name = "entry", columnDefinition = "json", nullable = false)
private String entry;

@Override
public final boolean equals(Object o) {
if (this == o) return true;
if (o == null) return false;
Class<?> oEffectiveClass = o instanceof HibernateProxy ? ((HibernateProxy) o).getHibernateLazyInitializer().getPersistentClass() : o.getClass();
Class<?> thisEffectiveClass = this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass() : this.getClass();
if (thisEffectiveClass != oEffectiveClass) return false;
DseProfile that = (DseProfile) o;

Check warning on line 35 in src/main/java/de/numcodex/feasibility_gui_backend/dse/persistence/DseProfile.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/de/numcodex/feasibility_gui_backend/dse/persistence/DseProfile.java#L35

Added line #L35 was not covered by tests
return getId() != null && Objects.equals(getId(), that.getId());
}

@Override
public final int hashCode() {
return this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass().hashCode() : getClass().hashCode();
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
package de.numcodex.feasibility_gui_backend.query.persistence;

import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.OneToOne;
import jakarta.persistence.*;
import lombok.*;
import org.hibernate.proxy.HibernateProxy;

import java.sql.Timestamp;
import lombok.Data;
import java.util.Objects;

@Data
@Getter
@Setter
@ToString
@RequiredArgsConstructor
@Entity
public class Query {

Expand All @@ -29,8 +26,25 @@

@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
@JoinColumn(referencedColumnName = "id", name = "query_content_id")
@ToString.Exclude
private QueryContent queryContent;

@OneToOne(mappedBy = "query", cascade = CascadeType.ALL)
private SavedQuery savedQuery;

@Override
public final boolean equals(Object o) {
if (this == o) return true;
if (o == null) return false;
Class<?> oEffectiveClass = o instanceof HibernateProxy ? ((HibernateProxy) o).getHibernateLazyInitializer().getPersistentClass() : o.getClass();
Class<?> thisEffectiveClass = this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass() : this.getClass();
if (thisEffectiveClass != oEffectiveClass) return false;
Query query = (Query) o;

Check warning on line 42 in src/main/java/de/numcodex/feasibility_gui_backend/query/persistence/Query.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/de/numcodex/feasibility_gui_backend/query/persistence/Query.java#L42

Added line #L42 was not covered by tests
return getId() != null && Objects.equals(getId(), query.getId());
}

@Override
public final int hashCode() {
return this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass().hashCode() : getClass().hashCode();
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package de.numcodex.feasibility_gui_backend.query.persistence;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Entity
import jakarta.persistence.*;
import lombok.*;
import org.hibernate.proxy.HibernateProxy;

import java.util.Objects;

@Getter
@Setter
@ToString
@NoArgsConstructor
@Entity
public class QueryContent {

@Id
Expand All @@ -26,4 +26,20 @@
public QueryContent(String queryContent) {
this.queryContent = queryContent;
}

@Override
public final boolean equals(Object o) {
if (this == o) return true;
if (o == null) return false;
Class<?> oEffectiveClass = o instanceof HibernateProxy ? ((HibernateProxy) o).getHibernateLazyInitializer().getPersistentClass() : o.getClass();
Class<?> thisEffectiveClass = this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass() : this.getClass();
if (thisEffectiveClass != oEffectiveClass) return false;
QueryContent that = (QueryContent) o;

Check warning on line 37 in src/main/java/de/numcodex/feasibility_gui_backend/query/persistence/QueryContent.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/de/numcodex/feasibility_gui_backend/query/persistence/QueryContent.java#L37

Added line #L37 was not covered by tests
return getId() != null && Objects.equals(getId(), that.getId());
}

@Override
public final int hashCode() {
return this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass().hashCode() : getClass().hashCode();
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
package de.numcodex.feasibility_gui_backend.query.persistence;

import static jakarta.persistence.FetchType.LAZY;
import jakarta.persistence.*;
import lombok.*;
import org.hibernate.proxy.HibernateProxy;

import jakarta.persistence.Column;
import jakarta.persistence.Convert;
import jakarta.persistence.Embeddable;
import jakarta.persistence.EmbeddedId;
import jakarta.persistence.Entity;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.MapsId;
import java.io.Serializable;
import java.sql.Timestamp;
import lombok.Data;
import java.util.Objects;

import static jakarta.persistence.FetchType.LAZY;

@Data
@Getter
@Setter
@ToString
@RequiredArgsConstructor
@Entity
public class QueryDispatch {

Expand All @@ -24,6 +23,7 @@
@MapsId("queryId")
@JoinColumn(referencedColumnName = "id", name = "query_id", nullable = false)
@ManyToOne(fetch = LAZY)
@ToString.Exclude
private Query query;

@Column(name = "dispatched_at", insertable = false, updatable = false)
Expand All @@ -42,4 +42,20 @@
@Column(name = "broker_type")
private BrokerClientType brokerType;
}

@Override
public final boolean equals(Object o) {
if (this == o) return true;
if (o == null) return false;
Class<?> oEffectiveClass = o instanceof HibernateProxy ? ((HibernateProxy) o).getHibernateLazyInitializer().getPersistentClass() : o.getClass();
Class<?> thisEffectiveClass = this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass() : this.getClass();
if (thisEffectiveClass != oEffectiveClass) return false;
QueryDispatch that = (QueryDispatch) o;

Check warning on line 53 in src/main/java/de/numcodex/feasibility_gui_backend/query/persistence/QueryDispatch.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/de/numcodex/feasibility_gui_backend/query/persistence/QueryDispatch.java#L53

Added line #L53 was not covered by tests
return getId() != null && Objects.equals(getId(), that.getId());
}

@Override
public final int hashCode() {
return Objects.hash(id);

Check warning on line 59 in src/main/java/de/numcodex/feasibility_gui_backend/query/persistence/QueryDispatch.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/de/numcodex/feasibility_gui_backend/query/persistence/QueryDispatch.java#L59

Added line #L59 was not covered by tests
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package de.numcodex.feasibility_gui_backend.query.persistence;

import jakarta.persistence.*;
import lombok.*;
import org.hibernate.proxy.HibernateProxy;

import java.sql.Timestamp;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import lombok.Data;

@Data
import java.util.Objects;

@Getter
@Setter
@ToString
@RequiredArgsConstructor
@Entity
public class QueryTemplate {

Expand All @@ -21,6 +20,7 @@

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(referencedColumnName = "id", name = "query_id")
@ToString.Exclude
private Query query;

@Column(name = "label", nullable = false)
Expand All @@ -31,4 +31,20 @@

@Column(name = "last_modified", insertable = false)
private Timestamp lastModified;

@Override
public final boolean equals(Object o) {
if (this == o) return true;
if (o == null) return false;
Class<?> oEffectiveClass = o instanceof HibernateProxy ? ((HibernateProxy) o).getHibernateLazyInitializer().getPersistentClass() : o.getClass();
Class<?> thisEffectiveClass = this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass() : this.getClass();
if (thisEffectiveClass != oEffectiveClass) return false;
QueryTemplate that = (QueryTemplate) o;

Check warning on line 42 in src/main/java/de/numcodex/feasibility_gui_backend/query/persistence/QueryTemplate.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/de/numcodex/feasibility_gui_backend/query/persistence/QueryTemplate.java#L42

Added line #L42 was not covered by tests
return getId() != null && Objects.equals(getId(), that.getId());
}

@Override
public final int hashCode() {
return this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass().hashCode() : getClass().hashCode();
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package de.numcodex.feasibility_gui_backend.query.persistence;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.OneToOne;
import lombok.Data;

@Data
import jakarta.persistence.*;
import lombok.*;
import org.hibernate.proxy.HibernateProxy;

import java.util.Objects;

@Getter
@Setter
@ToString
@RequiredArgsConstructor
@Entity
public class SavedQuery {

Expand All @@ -20,6 +19,7 @@

@JoinColumn(referencedColumnName = "id", name = "query_id", nullable = false)
@OneToOne(fetch = FetchType.LAZY)
@ToString.Exclude
private Query query;

@Column(name = "label", nullable = false)
Expand All @@ -30,4 +30,20 @@

@Column(name = "result_size")
private Long resultSize;

@Override
public final boolean equals(Object o) {
if (this == o) return true;
if (o == null) return false;
Class<?> oEffectiveClass = o instanceof HibernateProxy ? ((HibernateProxy) o).getHibernateLazyInitializer().getPersistentClass() : o.getClass();
Class<?> thisEffectiveClass = this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass() : this.getClass();
if (thisEffectiveClass != oEffectiveClass) return false;
SavedQuery that = (SavedQuery) o;

Check warning on line 41 in src/main/java/de/numcodex/feasibility_gui_backend/query/persistence/SavedQuery.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/de/numcodex/feasibility_gui_backend/query/persistence/SavedQuery.java#L41

Added line #L41 was not covered by tests
return getId() != null && Objects.equals(getId(), that.getId());
}

@Override
public final int hashCode() {
return this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass().hashCode() : getClass().hashCode();
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package de.numcodex.feasibility_gui_backend.query.persistence;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.*;
import lombok.*;
import org.hibernate.proxy.HibernateProxy;

import java.sql.Timestamp;
import lombok.Data;
import java.util.Objects;

@Data
@Getter
@Setter
@ToString
@RequiredArgsConstructor
@Entity
public class UserBlacklist {

Expand All @@ -21,4 +23,20 @@

@Column(name = "blacklisted_at", insertable = false)
private Timestamp blacklistedAt;

@Override
public final boolean equals(Object o) {
if (this == o) return true;
if (o == null) return false;
Class<?> oEffectiveClass = o instanceof HibernateProxy ? ((HibernateProxy) o).getHibernateLazyInitializer().getPersistentClass() : o.getClass();
Class<?> thisEffectiveClass = this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass() : this.getClass();
if (thisEffectiveClass != oEffectiveClass) return false;
UserBlacklist that = (UserBlacklist) o;

Check warning on line 34 in src/main/java/de/numcodex/feasibility_gui_backend/query/persistence/UserBlacklist.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/de/numcodex/feasibility_gui_backend/query/persistence/UserBlacklist.java#L34

Added line #L34 was not covered by tests
return getId() != null && Objects.equals(getId(), that.getId());
}

@Override
public final int hashCode() {
return this instanceof HibernateProxy ? ((HibernateProxy) this).getHibernateLazyInitializer().getPersistentClass().hashCode() : getClass().hashCode();
}
}
Loading
Loading