|
Ah, right. This is the one that is essentially a problem in the JPA spec. So you have not specified a `@JoinTable`, so the defaults are picked up. The defaults, according to JPA, state that the default table name for the many-to-many is the "concatenated names of the two associated primary entity tables, separated by an underscore". In your test at least (this does not hold true for the original description) the problem is that this resolves to the same table name for both associations. So what Hibernate (probably erroneously) does is to map both associations to the same table as you asked using different sets of columns:
This is the crux of the problem. Simply adding explicit `@JoinTable` naming fixed the problem.
I'm not sure there is anything we can do here and still remain JPA compliant. I guess we could relax the `NOT NULL` constraints we place on the columns of the table here, but that seems like the wrong answer too. Emmanuel Bernard, I do not remember specific discussions of this in the EG, do you?
|