NucleusUserException mapping Map of String -> PC
Project: DataNucleus API JPA
Issue Type: Bug
Affects Versions: 3.2.2
Environment: $ mvn -version
Apache Maven 3.0.4 (r1232337; 2012-01-17 02:44:56-0600)
Maven home: /Applications/springsource/apache-maven-3.0.4
Java version: 1.7.0_17, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_17.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.8.3", arch: "x86_64", family: "mac"
Reporter: Matthew T. Adams
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.
This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators: http://issues.datanucleus.org/secure/Administrators.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira