ManyToOne column in embeddable class

2.2k views Asked by At

I have two entities who embed (@Embedded) the Adress embeddable. In the Adress class there is a property who points to an entity Location. In the Adress class I put @ManyToOne and @JoinColumn(...) annotations above it. Now I get this error:

Exception Description: The table [persons] is not present in this descriptor. Descriptor: RelationalDescriptor(com.wordpress.aiids.voeder.model.Location --> [DatabaseTable(locations)])

It's the @JoinColumn annotation that causes the trouble:

@ManyToOne
//@JoinColumn(name = "gemeente", referencedColumnName = "gemeente", nullable = false)
private Gemeente gemeente;

Here's the full code of the embbedable class.

http://aiids.pastebin.com/G1sijNBL

Do I do something wrong by putting those annotations there or what's the cause of this error?

SOLUTION!

The solution is that the referencedColumnName must point to the Primary Key of the Entity Gemeente which was "postcode" and not "gemeente".

0

There are 0 answers