Jason
Jason

Reputation: 4145

Mapping an Interface As A Primary Key Via Hibernate

I have a class with it's own @Embeddable id class, let's call it ICompanyId. There are 2+ classes that implement ICompanyId. Classes that implement ICompanyId are the embedded id's for classes that implement ICompany (which there are 2+ implementing classes).

So, what I would like to do is this:

@EmbeddedId
public ICompanyId getId() { /* blah blah */ }

How do I tell Hibernate which implementing class to use? With a @ManyToOne or @OneToMany, all I would have to do is to specify a value in the targetEntity, but @EmbeddedId offers no such options. Can anyone help?

Jason

Upvotes: 2

Views: 196

Answers (1)

DannyMo
DannyMo

Reputation: 11984

Have you tried @Target(CompanyIdImpl.class) (see: @Target)? Keep in mind that this is a Hibernate-specific solution.

Upvotes: 1

Related Questions