java - Problems with ElementCollection / MappedSuperclass / AssociationOverride -
i have troubles override association. reading javadoc http://download.oracle.com/javaee/6/api/javax/persistence/collectiontable.html can read "see also: elementcollection, attributeoverride, associationoverride, column" wich gives assume can use it.. don't know how doesn't works
@mappedsuperclass public class abstractuser { [...] public string getlastname() { ...} @elementcollection @collectiontable(joincolumns=@joincolumn(name="user_id")) @column(name="nickname") public set<string> getnicknames() { ... }
implements
@entity @table(name="users") @table(name="user_rfcs") @associationoverride(name = "nicknames", jointable = @jointable(name = "user_nicknames", joincolumns = @joincolumn(name = "user_id")) ) public class user extends abstractuser { [...] } @entity @table(name="user_rfcs") @associationoverride(name = "nicknames", jointable = @jointable(name = "user_rfc_nicknames", joincolumns = @joincolumn(name = "user_id")) ) public class userrfc extends abstractuser { [...] }
@associationoverride
mentioned in "see also" section due following:
if embeddable class contains references other entities, default values columns corresponding references may overridden means of associationoverride and/or associationoverrides annotations.
from other side, @associationoverride
's javadoc says can applied entity relationships, not collections of primitives:
used override mapping entity relationship
so, looks can't @associationoverride
, , have override getnicknames()
method different annotations in subclasses.
Comments
Post a Comment