I am just starting to build my JPA scheme in the Play Framework web application. I have a reasonable understanding of SQL, but I'm new to JPA, and I'm getting off the first hurdle.
From the Play tutorials, I assume that you just create your Java classes, and JPA / Play will automatically create a schema for you.
So, I want to create ManyToMany relationships between two model classes: Rankable and Tag:
@Entity @Inheritance(strategy = InheritanceType.JOINED) public class Rankable extends Model { public String name; private Set<Tag> tags; @ManyToMany() @JoinTable(name = "RANKABLE_TAGS") public Set<Tag> getTags() { return tags; } @ManyToMany() @JoinTable(name = "RANKABLE_TAGS") public void setTags(final Set<Tag> tags) { this.tags = tags; } }
And another class:
@Entity public class Tag extends Model { public String name; public String description; private Set<Rankable> rankables; @ManyToMany(mappedBy = "tags") public Set<Rankable> getRankables() { return rankables; } @ManyToMany(mappedBy = "tags") public void setRankables(final Set<Rankable> r) { rankables = r; } }
But I keep getting the following error:
JPA error occurred (EntityManagerFactory cannot be built): Could not determine type for: java.util.Set, at table: Rankable, for columns: [Org.hibernate.mapping.Column (tags)]
What am I doing wrong?
sanity
source share