Created
July 26, 2020 13:50
-
-
Save Tonel/a375f14c2c1211d89c2dd5b4e8337765 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Entity | |
| @Table(name = "book") | |
| open class Book { | |
| @get:Id | |
| @get:GeneratedValue(strategy = GenerationType.IDENTITY, generator = "native") | |
| @get:Column(name = "id", unique = true, nullable = false) | |
| open var id: Int? = null | |
| @get:Basic | |
| @get:Column(name = "title", nullable = false, length = 50) | |
| open var title: String? = null | |
| @get:Basic | |
| @get:Column(name = "releaseDate", nullable = true) | |
| @get:Temporal(TemporalType.DATE) | |
| open var releaseDate: Date? = null | |
| @get:ManyToMany( | |
| fetch = FetchType.LAZY, | |
| mappedBy = "books" | |
| ) | |
| open var authors: MutableSet<Author> = HashSet() | |
| override fun equals(other: Any?): Boolean { | |
| if (this === other) return true | |
| if (javaClass != other?.javaClass) return false | |
| other as Book | |
| if (id != other.id) return false | |
| return true | |
| } | |
| override fun hashCode(): Int { | |
| if (id == null) | |
| return 0 | |
| return id!! | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment