impetus-opensource/Kundera — Issue #43: 2.0.5 - MongoDB - Multiple mappings in object results in NullPointerException when persisted
Author: bthor
Created: 2012-03-02 18:20:11+00:00
State: open

When an object has multiple mappings in it

eg:

public class Person {

@Id
@Column(name="personId")
private String personId;

@ManyToOne(cascade=CascadeType.ALL, fetch=FetchType.LAZY)
@JoinColumn(name="addressId")
private Address address;

@OneToOne(cascade=CascadeType.ALL, fetch=FetchType.LAZY)
@JoinColumn(name="blaId")
private Bla bla;
... }

The call to persist the person object will result in a
java.lang.NullPointerException
at com.impetus.kundera.persistence.AbstractEntityReader.computeGraph(AbstractEntityReader.java:115)
at com.impetus.kundera.persistence.PersistenceDelegator.find(PersistenceDelegator.java:755)
at com.impetus.kundera.persistence.EntityManagerImpl.find(EntityManagerImpl.java:106)

If we comment out either the Address or Bla then the call to persist will work fine.