3

I am receiving an error when my JPA code is invoked and the EntityManagerFactory is being retrieved:

Caused by: org.datanucleus.metadata.InvalidClassMetaDataException: Class com.analytics.jpa.model.Providers has application-identity and no objectid-class specified yet has 0 primary key fields. Unable to use SingleFieldIdentity.
    at org.datanucleus.metadata.AbstractClassMetaData.determineObjectIdClass(AbstractClassMetaData.java:1415)
    at org.datanucleus.metadata.ClassMetaData.populate(ClassMetaData.java:209)
    at org.datanucleus.metadata.MetaDataManager$1.run(MetaDataManager.java:2806)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.datanucleus.metadata.MetaDataManager.populateAbstractClassMetaData(MetaDataManager.java:2800)
    at org.datanucleus.metadata.MetaDataManager.populateFileMetaData(MetaDataManager.java:2623)
    at org.datanucleus.metadata.MetaDataManager.initialiseFileMetaDataForUse(MetaDataManager.java:1183)
    at org.datanucleus.metadata.MetaDataManager.loadPersistenceUnit(MetaDataManager.java:1046)
    at org.datanucleus.api.jpa.JPAEntityManagerFactory.initialiseNucleusContext(JPAEntityManagerFactory.java:855)
    at org.datanucleus.api.jpa.JPAEntityManagerFactory.initialise(JPAEntityManagerFactory.java:470)
    at org.datanucleus.api.jpa.JPAEntityManagerFactory.<init>(JPAEntityManagerFactory.java:428)
    at org.datanucleus.api.jpa.PersistenceProviderImpl.createEntityManagerFactory(PersistenceProviderImpl.java:116)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:152)

My model class looks like this:

@Entity
@Table(name = "PROVIDERS")
@SequenceGenerator(name = "PROVIDERS_SEQ", sequenceName = "PROVIDERS_SEQ", allocationSize = 1)
public class Providers {

     @Id
     @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "PROVIDERS_SEQ")
     @Column(name = "PROVIDER_ID")
     private Long providerId;

     @Column(name = "PROVIDER_NAME", nullable = false, length = 1000)
     private String providerName;

     @OneToOne(optional = false, orphanRemoval = true, cascade = CascadeType.ALL,
             fetch = FetchType.EAGER, mappedBy = "provider", targetEntity = Maps.class)
     private Maps map;

     // ... Getters and Setters ...
 }

The research that I've done says this error occurs if you do not have a Primary Key field specified, however, my code does. What else am I missing?

EDIT

A few additional items from the DataNucleus.MetaData logs on DEBUG:

Class "com.analytics.jpa.model.Providers" has been specified with JPA annotations so using those.

Ignoring metadata for field com.analytics.jpa.model.Providers.providerId since we already have MetaData for the property com.analytics.jpa.model.Providers.providerId

Populating all MetaData ...

Class "com.analytics.jpa.model.Providers" : Populating Meta-Data

Class com.analytics.jpa.model.Providers has application-identity and no objectid-class specified yet has 0 primary key fields. Unable to use SingleFieldIdentity.

EDIT 2

I am using the following versions of Data Nucleus libraries:

  • datanulceus-core: 3.2.5 4.0.0-release
  • datanucleus-api-jpa: 3.2.4 4.0.0-release
  • datanucleus-rdbms: 3.2.4 4.0.0-release

This is running in Jetty 7.6.7 on JDK 1.7.0_25 on Windows 7

Community
  • 1
  • 1
lamarvannoy
  • 475
  • 1
  • 7
  • 15
  • perhaps (some of) your annotations are not javax.persistence. Look at the log which tells you way more – Neil Stockton Jul 16 '14 at 08:45
  • Thanks for the response Neil. I did check the imports and they are all javax.persistence. The logs didn't give me much more information. I'll add it to the question, though, in case it helps. – lamarvannoy Jul 16 '14 at 12:47
  • Does Maps entity have an @Id? – Jorge Campos Jul 16 '14 at 12:58
  • Yes, Maps entity does have javax.persistence.Id on its primary key as well. It is defined the same as Providers above. – lamarvannoy Jul 16 '14 at 13:09
  • perhaps use 4.x? it seems to have more logging/error traps etc, and is a year+ later than what you use there – Neil Stockton Jul 16 '14 at 17:56
  • I upgraded to 4.0.0-release and still have the same error and no additional logging – lamarvannoy Jul 17 '14 at 15:46
  • So generate a testcase using their templates http://www.datanucleus.org/documentation/problem_reporting.html There is nothing else that can be answered here with the superficial info that a forum provides – Neil Stockton Jul 18 '14 at 03:08

0 Answers0