hibernate - JPA @OneToMany relationship to @Embedded class used as @Id -
i have problem (and i'm not sure if possible) whit association , embedded id using jpa...
i have person
class it's id:
@entity public class person{ @embeddedid private personcode personcode; private string name; @embeddable public static class personcode{ private string code; } }
and create class company
association:
@entity public class company{ private string name; @onetomany private list<personcode> employees; }
but have exception:
caused by: org.hibernate.annotationexception: use of @onetomany or @manytomany targeting unmapped class: example.domain.company.employees[example.domain.person$personcode]
an association must between 2 entities. company should have list<person>
.
btw, make harder necessary. use
@entity public class person{ @id private string code; private string name; }
there's no reason wrap single field embeddable class.
Comments
Post a Comment