Just for the record, because Googling did not brought us far on this.

If you ever have a JPA2/Hibernate table with multiple primary keys and want to add an ElementCollection on that

@ElementCollection
List<Integer> testCases = new ArrayList<>();

Chances that you get the following
error message:

org.hibernate.MappingException: Foreign key (FK_b10frvpxbd5uu483xde8d5qso:testcase_ids [XXX])) must have same number of columns as the referenced primary key (XXX)

The problem is that Hibernate does not automatically add all your primary keys to the created table for the embedded collection.

But it is possible to tell JPA which columns to use:

@CollectionTable(joinColumns={@JoinColumn(name="id", referencedColumnName="id"), @JoinColumn(name="revision", referencedColumnName="revision")})
List<Integer> testCases = new ArrayList<>();

These tells Hibernate to add "id" and "revision" (the both primary keys in my case) to the generated table.