javahibernate

@OneToOne or @ManyToOne on Instrument.created references an unknown entity: user.User where User is interface


I have following error:

@OneToOne or @ManyToOne on Instrument.created references an unknown entity: user.User

User class is public interface with abstract methods. The only class which is implementing User is CommonUser which is annotated with @Entity and @Table(name="users").

So yes, error is correct - User is not an entity but I don't want it to be because CommonUser is an entity.

What should be the correct approach here?

Do I need to change code to make Instrument class work on concrete CommonUser, not User?


Solution

  • Yes. You have to work with CommonUser otherwise hibernate don't know how to handle this link.