DataNucleus JIRA is now in read-only mode. Raise any new issues in GitHub against the plugin that it applies to. DataNucleus JIRA will remain for the foreseeable future but will eventually be discontinued
Issue Details (XML | Word | Printable)

Key: NUCJPA-236
Type: Bug Bug
Status: Closed Closed
Resolution: Cannot Reproduce
Priority: Major Major
Assignee: Unassigned
Reporter: Matthew T. Adams
Votes: 0
Watchers: 0

If you were logged in you would be able to see more operations.
DataNucleus API JPA

NucleusUserException mapping Map of String -> PC

Created: 29/May/13 06:49 PM   Updated: 23/Oct/13 11:56 AM   Resolved: 14/Oct/13 10:18 AM
Component/s: None
Affects Version/s: 3.2.2
Fix Version/s: None

$ 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"

Forum Thread URL:,7533
Datastore: Apache Derby, H2
Severity: Development

 Description  « Hide
Note: Code for this test case is on the "issue" branch at

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.
        at org.datanucleus.api.jpa.NucleusJPAHelper.getJPAExceptionForNucleusException(
        at org.datanucleus.api.jpa.JPAEntityTransaction.commit(
        ... 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:

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

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.

Sort Order: Ascending order - Click to sort in descending order
Andy Jefferson added a comment - 31/May/13 01:01 PM
Simple workaround is put your abstract classes the other way around ... i.e the root one has @Id, and the derived one has the @Version. If there is no supertable then to get the PK will always (currently) look to the top level persistable class for PK fields

Matthew T. Adams added a comment - 05/Jun/13 11:14 PM
Putting the @MappedSuperclass that has the @Id field at the top of the hierarchy does work.

Andy Jefferson added a comment - 14/Oct/13 10:18 AM
Can't reproduce with current SVN