From: Costantino C. (JIRA) <web...@jp...> - 2009-06-07 18:00:51
|
[ http://www.datanucleus.org/servlet/jira/browse/NUCDBFO-41?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Costantino Cerbo updated NUCDBFO-41: ------------------------------------ Attachment: Main.java Attached simple testcase > PersistenceManager#getObjectById(Class<T>, Object) returns an empty object instead of throwing a JDOObjectNotFoundException when no object wasf found > ----------------------------------------------------------------------------------------------------------------------------------------------------- > > Key: NUCDBFO-41 > URL: http://www.datanucleus.org/servlet/jira/browse/NUCDBFO-41 > Project: DataNucleus DB4O > Issue Type: Bug > Components: Persistence > Affects Versions: 1.1.2 > Reporter: Costantino Cerbo > Attachments: Main.java > > > We have this persistable class: > @PersistenceCapable(identityType = IdentityType.APPLICATION) > public class Address > { > @PrimaryKey > private Long id; > private String street; > private String streetNr; > ... > } > and then we try to get the Address with id 20, that doesn't exist. > No JDOObjectNotFoundException is thrown but an instance of Address where id=20 and the remaining instance variables are null. > I think, the reason is that in DB4OPersistenceHandler#findObject(ObjectManager, Object) line 618 instead of: > if (objectSet.size() == 0) > { > return null; > } > we should do so: > if (!objectSet.hasNext()) > { > throw new NucleusObjectNotFoundException(LOCALISER.msg("DB4O.Object.NotFound", StringUtils.toJVMIDString(pc), id)); > } > Also in the comment for that method stands that: > "If an implementation believes that an object with the given ID should exist, but in fact does not exist, > then the implementation should throw a RuntimeException. It should not silently return null in this case." -- 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 |