Basic JPA issue: "Could not determine type for: java.util.Set" -
i'm getting started building jpa schema in play framework web app. have reasonable understanding of sql, i'm jpa newbie, , i'm being tripped @ first hurdle.
from play tutorials i'm assuming create java classes , jpa/play automagically create schema you.
so want create manytomany relationship between 2 model classes, rankable , 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 other 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 keep getting following error:
a jpa error occurred (unable build entitymanagerfactory): not determine type for: java.util.set, @ table: rankable, columns: [org.hibernate.mapping.column(tags)]
what doing wrong?
in our case, reason had annotations on field , on getters. in other words, specific field, annotations should either on field or on getter. combining them on getters solved problem us. seems exception not show real cause of problem. way, used syntax manytomany annotations:
entity:
@manytomany @jointable(name = "join_table", joincolumns = { @joincolumn(name = "leftjoinid") }, inversejoincolumns = { @joincolumn(name = "rightjoinid") })
entity:
@manytomany @jointable(name = "join_table", joincolumns = { @joincolumn(name = "rightjoinid") }, inversejoincolumns = { @joincolumn(name = "leftjoinid") })
Comments
Post a Comment