From: Andy J. (JIRA) <web...@jp...> - 2009-05-31 11:44:58
|
[ http://www.datanucleus.org/servlet/jira/browse/NUCDBFO-39?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16703#action_16703 ] Andy Jefferson commented on NUCDBFO-39: --------------------------------------- And please use current SVN trunk of core since that has a change > Make the exception, that is thrown when an ID of wrong type is put in PersistenceManager#getObjectById(Class, Object), more self-explanatory. > --------------------------------------------------------------------------------------------------------------------------------------------- > > Key: NUCDBFO-39 > URL: http://www.datanucleus.org/servlet/jira/browse/NUCDBFO-39 > Project: DataNucleus DB4O > Issue Type: Improvement > Components: Queries > Affects Versions: 1.1.0.release > Reporter: Costantino Cerbo > Priority: Minor > Attachments: id_is_exception_test.zip > > > When you want to get an object by id using PersistenceManager#getObjectById(Class, Object) and you use a wrong type (for example, your ID is Long and you put a String) the following exception occurs: > Exception in thread "main" java.lang.NullPointerException > at org.datanucleus.store.db4o.DB4OPersistenceHandler.findObject(DB4OPersistenceHandler.java:603) > at org.datanucleus.ObjectManagerImpl.findObject(ObjectManagerImpl.java:2330) > at org.datanucleus.jdo.JDOPersistenceManager.getObjectById(JDOPersistenceManager.java:1675) > at org.datanucleus.jdo.JDOPersistenceManager.getObjectById(JDOPersistenceManager.java:1771) > at org.datanucleus.test.Main.main(Main.java:45) > That happens because in DB4OPersistenceHandler#findObject(ObjectManager, Object) a JDOFatalInternalException is propagated through the object "id". > The JDOFatalInternalException said: > The key value passed to construct a SingleFieldIdentity of type "javax.jdo.identity.LongIdentity" for class "org.datanucleus.test.Person" is of an incorrect type ("java.lang.String") - should be "Long". > It think it would be better to thrown the JDOFatalInternalException because the NullPointerException is not very self-explanatory. > -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://www.datanucleus.org/servlet/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |