Last active
July 4, 2020 10:59
-
-
Save Tonel/d0174f79df2ae4fc4f826e2800bb50ac to your computer and use it in GitHub Desktop.
This file contains 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 = "post") | |
data class Post( | |
@get:Id | |
@get:GeneratedValue | |
@get:Column(name = "id") | |
val id: Long, | |
@get:Column(name = "title") | |
val title: String, | |
@get:ManyToMany | |
@get:JoinTable( | |
name = "post_tag", | |
joinColumns = [JoinColumn(name = "post_id")], | |
inverseJoinColumns = [JoinColumn(name = "tag_id")] | |
) | |
val tags: Set<Tag> = HashSet() | |
) |
This file contains 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 = "tag") | |
data class Tag( | |
@get:Id | |
@get:GeneratedValue | |
@get:Column(name = "id") | |
val id: Long, | |
@get:Column(name = "name") | |
val name: String, | |
@get:ManyToMany(mappedBy = "tags") | |
val posts: Set<Post> = HashSet() | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment