You seem to be making the assumption that the following line of code will actually find a shared instance of the UserByID dictionary class:
Code: Select all
userDict:=UserByID.firstInstance();
Simply defining a dictionary doesn't mean any instances of that dictionary will exist. Also, it is very, very unusual to use a shared persistent dictionary instance rather than having a property of that type on another object.
For example, in a simple system you may have a 'Root' singleton which has a Root::allUsersByID reference, of type UserByID dict, inversed to a User::myRoot reference. In this setup, when you create an instance of User and set the User::myRoot reference to your Root singleton instance, it will automatically add that user into the exclusive subObject instance of the UserByID dictionary class that represents the Root::allUsersByID reference. This concept of automatically maintained references is one of the more powerful features of the JADE Object Manager (JOM).
With this setup, after the following line of code executes, the userDict local variable will still be null, as there is no shared instance of the UserByID dictionary class. This will still be the case even if you have created your Root object singleton, several User objects, and set the User::myRoot reference appropriately. There will be an exclusive subObject instance of type UserByID dictionary, but you'll never be able to access that using the following line of code:
Code: Select all
userDict:=UserByID.firstInstance();
In the scenario described above, your code could be rewritten as follows, although it would be more normal to have a 'myRoot' reference to your Root singleton on your application subclass, so you can set this up during application initialise and then simply code app.myRoot when you need to dereference your Root singleton. The following code 'accesses' the exclusive subObject instance of UserByID dict by way of the property on the owning instance of the Root singleton.
Code: Select all
iter := Root.firstInstance.allUsersByID.createIterator();
while iter.next(user) do
if (user.identification = id or user.email=id) and (user.password=password) then
return true;
endif;
endwhile;
return false;
Cheers,
BeeJay.