users@jersey.java.net

Re: [Jersey] I don't know if this is a bug or not.

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 20 Jan 2009 17:49:31 +0100

Hi Eric,

I forwarded your email to the NetBeans guys who developed the
convertor generator code.

Paul.

On Jan 20, 2009, at 5:35 PM, Marsh Eric wrote:

> 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);
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>