Hi Erik,

On Sep 12, 2010, at 4:14 AM, Erik Bengtson wrote:

Hi,

I was wondering the behaviour of getObjectsById operatiob upon
different argument values.

1st) getObjectsById(Collections.EMPTY_SET),  the user has not done any
invalid operation on the interface, thus it should just return another
empty collection. Currently, Datanucleus raises an exception.

Should return Collections.EMPTY_SET

2nd) when getObjectsById(null) is invoked, it raises a JDOUserException.

Good. A null instance is not an empty collection.

3rd) getObjectsById(Object... oids) where oids == null, it raises a
JDOUserException.

Good. A null array is not an instance of Object[0].

4th) getObjectsById(Object... oids) where one of the id elements is
null, it raises a JDOUserException.

This is consistent with 12.6.5 which states "If the PersistenceManager is unable to resolve the oid parameter to an ObjectId instance, then it throws a JDOUserException. "

The issue that isn't documented is how to tell the user which of the elements is bad. If we use 17.1 as a model,

"Methods are provided to retrieve the nested exception array and failed object. If there are multiple nested exceptions, then each might contain one failed object. This will be the case where an operation requires multiple instances, such as commit, makePersistentAll, etc."

then there should be an exception thrown that contains multiple nested exceptions, each of which describes the problem with one of the object ids.

or
getObjectsById(Collections.EMPTY_SET), where one of the id elements is
null, it raises a JDOUserException.

Collections.EMPTY_SET is already discussed above. If you mean a collection (List) one or more of whose elements are null, then a JDOUserException should be raised, similar to above.

Craig



Any thoughts?

Erik

Craig L Russell
Architect, Oracle
http://db.apache.org/jdo
408 276-5638 mailto:[email protected]
P.S. A good JDO? O, Gasp!

Reply via email to