Fixed "Getters of lazy classes cannot be final"

This commit is contained in:
neviyn 2021-04-04 15:05:37 +01:00
parent b11e273d7e
commit db6282eec6

View File

@ -16,10 +16,10 @@ import javax.persistence.OneToMany
@Entity @Entity
open class User( open class User(
var username: String = "INVALID", open var username: String = "INVALID",
var email: String = "INVALID", open var email: String = "INVALID",
@JsonIgnore @JsonIgnore
var password: String = "INVALID", open var password: String = "INVALID",
@ManyToMany(cascade = [CascadeType.ALL]) @ManyToMany(cascade = [CascadeType.ALL])
@JsonIgnore @JsonIgnore
@JoinTable( @JoinTable(
@ -27,22 +27,22 @@ open class User(
joinColumns = [JoinColumn(name = "user_id", referencedColumnName = "id")], joinColumns = [JoinColumn(name = "user_id", referencedColumnName = "id")],
inverseJoinColumns = [JoinColumn(name = "project_id", referencedColumnName = "id")] inverseJoinColumns = [JoinColumn(name = "project_id", referencedColumnName = "id")]
) )
var projects: MutableSet<Project> = mutableSetOf(), open var projects: MutableSet<Project> = mutableSetOf(),
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) var id: Long? = null @Id @GeneratedValue(strategy = GenerationType.IDENTITY) open var id: Long? = null
) )
@Entity @Entity
class Project( open class Project(
var title: String = "INVALID", open var title: String = "INVALID",
@ManyToMany(mappedBy = "projects") @ManyToMany(mappedBy = "projects")
@JsonIgnore @JsonIgnore
var members: MutableSet<User> = mutableSetOf(), open var members: MutableSet<User> = mutableSetOf(),
@OneToMany(mappedBy = "project") @OneToMany(mappedBy = "project")
@JsonIgnore @JsonIgnore
var events: MutableSet<Event> = mutableSetOf(), open var events: MutableSet<Event> = mutableSetOf(),
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) var id: Long? = null @Id @GeneratedValue(strategy = GenerationType.IDENTITY) open var id: Long? = null
) { ) {
fun addMember(member: User){ fun addMember(member: User) {
members.add(member) members.add(member)
member.projects.add(this) member.projects.add(this)
} }
@ -54,46 +54,46 @@ class Project(
} }
@Entity @Entity
class Event( open class Event(
var title: String = "INVALID", open var title: String = "INVALID",
var description: String = "INVALID", open var description: String = "INVALID",
@Column(name = "start_time") @Column(name = "start_time")
var start: Instant = Instant.MIN, open var start: Instant = Instant.MIN,
@Column(name = "end_time") @Column(name = "end_time")
var end: Instant = Instant.MIN, open var end: Instant = Instant.MIN,
@ManyToOne @ManyToOne
@JoinColumn(name = "project_id") @JoinColumn(name = "project_id")
@JsonIgnore @JsonIgnore
var project: Project? = null, open var project: Project? = null,
@ManyToMany(mappedBy = "events") @ManyToMany(mappedBy = "events")
@JsonIgnore @JsonIgnore
var tags: MutableSet<Tag> = mutableSetOf(), open var tags: MutableSet<Tag> = mutableSetOf(),
@OneToMany(mappedBy = "event") @OneToMany(mappedBy = "event")
var comments: MutableList<Comment> = mutableListOf(), open var comments: MutableList<Comment> = mutableListOf(),
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) var id: Long? = null @Id @GeneratedValue(strategy = GenerationType.IDENTITY) open var id: Long? = null
) )
@Entity @Entity
class Comment( open class Comment(
@ManyToOne @ManyToOne
@JoinColumn(name = "user_id") @JoinColumn(name = "user_id")
var user: User? = null, open var user: User? = null,
@ManyToOne @ManyToOne
@JoinColumn(name = "event_id") @JoinColumn(name = "event_id")
@JsonIgnore @JsonIgnore
var event: Event? = null, open var event: Event? = null,
@ManyToMany(mappedBy = "comments") @ManyToMany(mappedBy = "comments")
var tags: MutableSet<Tag> = mutableSetOf(), open var tags: MutableSet<Tag> = mutableSetOf(),
var created: Instant = Instant.MIN, open var created: Instant = Instant.MIN,
var comment: String = "INVALID", open var comment: String = "INVALID",
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) var id: Long? = null @Id @GeneratedValue(strategy = GenerationType.IDENTITY) open var id: Long? = null
) { ) {
fun toFlatComment(): FlatComment = FlatComment(created, comment, user!!.username) fun toFlatComment(): FlatComment = FlatComment(created, comment, user!!.username)
} }
@Entity @Entity
class Tag( open class Tag(
var tag: String = "INVALID", open var tag: String = "INVALID",
@ManyToMany @ManyToMany
@JoinTable( @JoinTable(
name = "comment_tags", name = "comment_tags",
@ -101,7 +101,7 @@ class Tag(
inverseJoinColumns = [JoinColumn(name = "comment_id", referencedColumnName = "id")] inverseJoinColumns = [JoinColumn(name = "comment_id", referencedColumnName = "id")]
) )
@JsonIgnore @JsonIgnore
var comments: MutableSet<Comment> = mutableSetOf(), open var comments: MutableSet<Comment> = mutableSetOf(),
@ManyToMany @ManyToMany
@JoinTable( @JoinTable(
name = "event_tags", name = "event_tags",
@ -109,6 +109,6 @@ class Tag(
inverseJoinColumns = [JoinColumn(name = "event_id", referencedColumnName = "id")] inverseJoinColumns = [JoinColumn(name = "event_id", referencedColumnName = "id")]
) )
@JsonIgnore @JsonIgnore
var events: MutableSet<Event> = mutableSetOf(), open var events: MutableSet<Event> = mutableSetOf(),
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) var id: Long? = null @Id @GeneratedValue(strategy = GenerationType.IDENTITY) open var id: Long? = null
) )