Saturday, 23 May 2015

Tags

The tags are hooked up. Please find a video of the end result below:



Each blog post can have n many tags. Tags are embedded into the 'Post' class.
    @ElementCollection
    @CollectionTable(name="POST_TAGS", joinColumns = @JoinColumn(name="POST_ID"))
    @Column(name="TAGS")
    private List<tag> tags = new ArrayList<>();

I experimented with tags as entities in order to query them in a more JPA way. However, after several hours of making it complicated I decided to go with embedding them. After all: Why complicate the entities for the sake of a JPQL query?

No comments:

Post a Comment