persistence@glassfish.java.net

Re: Fixing issue #383

From: Craig L Russell <Craig.Russell_at_Sun.COM>
Date: Tue, 14 Mar 2006 19:29:06 -0800

Hi Marina,

FWIW, I like to use pattern b if it's a one-shot issue (which this
sounds like). There's no downside to creating a hashtable once. If
you are constantly creating it and testing for an empty hashset, it's
easier to have the hashset defined as null and avoid the construction.

Craig

On Mar 14, 2006, at 6:53 PM, Marina Vatkina wrote:

> Tom,
>
> The NPE is caused by the following code m_session.getProject
> ().getAliasDescriptors().remove("");
>
> When there are no entities in the PU, the alias descriptors
> hashtable is null because it's never created.
>
> There are 2 options to fix it:
> a) change the line above to
> Hashtable d = m_session.getProject().getAliasDescriptors();
> if (d != null)
> d.remove("");
>
> b) Change the Project class to create aliasDescriptors in the
> constructor.
>
> If you don't see a problem with ether fix, I can make the change.
>
> regards,
> -marina

Craig Russell
Architect, Sun Java Enterprise System http://java.sun.com/products/jdo
408 276-5638 mailto:Craig.Russell_at_sun.com
P.S. A good JDO? O, Gasp!