mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-15 04:02:53 +00:00
[AB-161] fixed composite foreign keys for multiple tables
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package dev.sheldan.abstracto.utility.models.database;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.ServerSpecificId;
|
||||
import dev.sheldan.abstracto.core.models.database.AChannel;
|
||||
import dev.sheldan.abstracto.core.models.database.AServer;
|
||||
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
|
||||
@@ -10,7 +11,6 @@ import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.time.Instant;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name="suggestion")
|
||||
@@ -25,9 +25,9 @@ import java.util.Objects;
|
||||
public class Suggestion implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Getter
|
||||
private Long id;
|
||||
@EmbeddedId
|
||||
private ServerSpecificId suggestionId;
|
||||
|
||||
@Getter
|
||||
@ManyToOne
|
||||
@@ -43,9 +43,9 @@ public class Suggestion implements Serializable {
|
||||
@JoinColumn(name = "channelId")
|
||||
private AChannel channel;
|
||||
|
||||
@Getter
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "serverId")
|
||||
@ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
|
||||
@MapsId("serverId")
|
||||
@JoinColumn(name = "server_id", referencedColumnName = "id", nullable = false)
|
||||
private AServer server;
|
||||
|
||||
@Getter
|
||||
@@ -71,22 +71,4 @@ public class Suggestion implements Serializable {
|
||||
this.updated = Instant.now();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Suggestion that = (Suggestion) o;
|
||||
return Objects.equals(id, that.id) &&
|
||||
Objects.equals(suggester, that.suggester) &&
|
||||
Objects.equals(messageId, that.messageId) &&
|
||||
Objects.equals(channel, that.channel) &&
|
||||
Objects.equals(server, that.server) &&
|
||||
Objects.equals(suggestionDate, that.suggestionDate) &&
|
||||
state == that.state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id, suggester, messageId, channel, server, suggestionDate, state);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user