Working with the converter files generated in netbeans I noticed that
null exceptions were being fired from the resolveEntity methods. The
code as generated was attempting to get a collection but if the
database didn't hold any values it would return a null and the
exception was fired. I wrapped the for loop that referenced the
collection with a test for null and things started working again.
from:
public Mylocation resolveEntity(EntityManager em) {
Collection<People> peopleCollection =
entity.getPeopleCollection();
Collection<People> newpeopleCollection = new
java.util.ArrayList<People>();
for (People item : peopleCollection) {
newpeopleCollection.add(em.getReference(People.class,
item.getPk()));
}
entity.setPeopleCollection(newpeopleCollection);
to:
public Mylocation resolveEntity(EntityManager em) {
Collection<People> peopleCollection =
entity.getPeopleCollection();
Collection<People> newpeopleCollection = new
java.util.ArrayList<People>();
if (peopleCollection != null) {
for (People item : peopleCollection) {
newpeopleCollection.add(em.getReference(People.class,
item.getPk()));
}
}
entity.setPeopleCollection(newpeopleCollection);