Note: Code for this test case is on the "issue" branch at https://github.com/matthewadams/test-jpa
I've got two classes, Person & Address. I'm getting the following error:
Caused by: org.datanucleus.exceptions.NucleusUserException: Columns "Columns [person_id] " have been defined with 1 columns, yet there are only 0 to map to!
Address is nothing special:
private String line1;
private String line2;
private String city;
private String state;
private String postalCode;
Person has a Map<String,Address>:
@OneToMany(cascade = CascadeType.ALL)
@JoinTable(name = "PERSON_ADDRESSES", joinColumns = @JoinColumn(name = "person_id", referencedColumnName = "id"), inverseJoinColumns = @JoinColumn(referencedColumnName = "id", name = "address_id"))
@MapKeyColumn(name = "address_name")
private Map<String, Address> addresses = new HashMap<String, Address>();
Both classes are @Entitys and inherit fields @Id String id & @Version long version from a @MappedSuperclass.
If I comment all arguments to the @JoinTable annotation above, I get the following SQL syntax error. Note the missing column names in the foreign key specification of the alter table statement:
Caused by: javax.persistence.PersistenceException: Error(s) were found while auto-creating/validating the datastore for classes. The errors are printed in the log, and are attached to this exception.
... 30 more
Caused by: org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement "ALTER TABLE PERSON_SURNAMES ADD CONSTRAINT PERSON_SURNAMES_FK1 FOREIGN KEY ()
REFERENCES PERSON () "; expected "identifier"; SQL statement:
ALTER TABLE PERSON_SURNAMES ADD CONSTRAINT PERSON_SURNAMES_FK1 FOREIGN KEY () REFERENCES PERSON () [42001-168]
This is being generated as a result of this field in the Person class:
@CollectionTable(name = "PERSON_SURNAMES")
@Column(name = "surname")
private List<String> surnames = new ArrayList<String>();
Funny thing is, these mappings work ok when using Hibernate, and they're basically the same as the example given at http://www.datanucleus.org/products/accesspla...y_map.html#join_simple_pc
Note also that this appears to be independent of the database in use, as the test-jpa repo is using H2 and I'm also seeing the error against Derby.