Issue Details (XML | Word | Printable)

Key: NUCMONGODB-35
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Christian Ernst
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
DataNucleus Store MongoDB

java.lang.NullPointerException in makePersistent when persisting array field

Created: 10/May/11 02:43 PM   Updated: 14/Jun/11 12:24 PM   Resolved: 10/May/11 03:39 PM
Component/s: None
Affects Version/s: 3.0.0.m4
Fix Version/s: 3.0.0.m5

File Attachments: 1. Zip Archive MongoDBProvideFieldNPE.zip (16 kB)


Datastore: Other


 Description  « Hide
It seems that on a certain model with an array attribute a NullPointerException is thrown on makePersistent
----------------------
Exception in thread "main" java.lang.NullPointerException
at org.datanucleus.store.mongodb.fieldmanager.StoreFieldManager.storeObjectField(StoreFieldManager.java:295)
at org.datanucleus.state.AbstractStateManager.providedObjectField(AbstractStateManager.java:1428)
at model.B.jdoProvideField(B.java)
at model.B.jdoProvideFields(B.java)
at org.datanucleus.state.AbstractStateManager.provideFields(AbstractStateManager.java:1481)
at org.datanucleus.store.mongodb.fieldmanager.StoreFieldManager.storeObjectField(StoreFieldManager.java:287)
at org.datanucleus.state.AbstractStateManager.providedObjectField(AbstractStateManager.java:1428)
at model.A.jdoProvideField(A.java)
at model.A.jdoProvideFields(A.java)
at org.datanucleus.state.AbstractStateManager.provideFields(AbstractStateManager.java:1481)
at org.datanucleus.store.mongodb.MongoDBPersistenceHandler.getDBObjectForObjectProviderToInsert(MongoDBPersistenceHandler.java:377)
at org.datanucleus.store.mongodb.MongoDBPersistenceHandler.insertObject(MongoDBPersistenceHandler.java:223)
at org.datanucleus.state.JDOStateManagerImpl.internalMakePersistent(JDOStateManagerImpl.java:2405)
at org.datanucleus.state.JDOStateManagerImpl.makePersistent(JDOStateManagerImpl.java:2381)
at org.datanucleus.ObjectManagerImpl.persistObjectInternal(ObjectManagerImpl.java:1608)
at org.datanucleus.ObjectManagerImpl.persistObject(ObjectManagerImpl.java:1430)
at org.datanucleus.api.jdo.JDOPersistenceManager.jdoMakePersistent(JDOPersistenceManager.java:724)
at org.datanucleus.api.jdo.JDOPersistenceManager.makePersistent(JDOPersistenceManager.java:749)
at test.Test.main(Test.java:40)
------------------
public class A {
private List<B> list = new ArrayList<B>();
public List<B> getList() {return list;}
public void setList(List<B> list) {this.list = list;}
public void add(B aB){list.add(aB);}
}

public class B {
private C[] array = new C[] {};
public C[] getArray() {return array;}
public void setArray(C[] array) {this.array = array;}
}

public class C {
}
-------------------
<jdo>
  <package name="model">
   <class name="A">
            <field name="list" embedded="true">
         <collection element-type="B"/>
         </field>
        </class>
        <class name="B">
<field name="array" embedded="false">
        <array element-type="C"/>
        </field>
        </class>
    <class name="C"/>
  </package>
</jdo>
-----------------------
PersistenceManager pm = pmf.getPersistenceManager();
Transaction txn = pm.currentTransaction();
txn.begin();
A p = new A();
B p1 = new B();
p.add(p1);
pm.makePersistent(p);
txn.commit();
----------------------




















Christian Ernst made changes - 10/May/11 02:44 PM
Field Original Value New Value
Attachment MongoDBProvideFieldNPE.zip [ 11442 ]
Christian Ernst added a comment - 10/May/11 02:57 PM
seems to have something todo with the embedded flag

Andy Jefferson added a comment - 10/May/11 03:39 PM
Copy-paste error

Andy Jefferson made changes - 10/May/11 03:39 PM
Status Open [ 1 ] Resolved [ 5 ]
Fix Version/s 3.0.0.m5 [ 11246 ]
Resolution Fixed [ 1 ]
Andy Jefferson made changes - 17/May/11 09:52 AM
Summary java.lang.NullPointerException in makePersistent java.lang.NullPointerException in makePersistent when persisting array field
Andy Jefferson made changes - 14/Jun/11 12:24 PM
Status Resolved [ 5 ] Closed [ 6 ]