Hi all,

I'm getting a NullPointerException when using SD JPA with DataNucleus over a MongoDB. I have a simple @Entity, app.domain.Profile, that extends a @MappedSuperclass that has a single string @Id field with @GeneratedValue(strategy = GenerationType.AUTO).

After looking into it a bit, here is the code that throws, which is in JpaMetamodelEntityInformation#getId(T):
Code:
    public ID getId(T entity) {


        BeanWrapper entityWrapper = new DirectFieldAccessFallbackBeanWrapper(entity);


        if (idMetadata.hasSimpleId()) {
            return (ID) entityWrapper.getPropertyValue(idMetadata.getSimpleIdAttribute().getName()); // NPE HERE
        }
        // ...
The NPE is getting thrown because it's assuming that idMetadata.getSimpleIdAttribute() will never return null.

Is that a valid assumption? If it is, then it's a bug in DataNucleus (both the latest 3.0.x release & the latest 3.1.x milestone release); if it's not, then it's a bug in Spring Data. Otherwise, it's an ambiguity in the specification. I suppose the question is whether it's up to Spring Data (or any JPA metadata client) to traverse the @Entity's type hierarchy until it finds the @Id field, or whether the JPA implementation should do that.

I have a public repo on github that demonstrates the error at:
https://github.com/matthewadams/spri...ucleus-mongodb

Running mvn clean install will demonstrate.

Spring guys, can you comment?

Thanks,
Matthew