persistence layer will try to set a "null" if one field has not been
initialized, which leads to an exception. So you shall not try to persist a
primitive type

use Comparable.compare(Comparable o) instead, as nclemeur suggested.

On Wed, Oct 21, 2009 at 6:20 PM, John V Denley
<[email protected]>wrote:

>
> AHHH, that actually explains a lot of other problems I have been
> seeing with "Long" that i wasnt expecting....
>
> so why would anyone use Long rather than long? Im guessing that long
> is actually a  basic datatype.... I suppose I can go look that up
> myself though!
>
> Thanks for your help and input... I wish id figured that out at about
> midnight last night, I could have gone to bed 4 hours earlier!!! LOL
>
> On Oct 21, 3:44 am, nclemeur <[email protected]> wrote:
> > Just use
> >  StoredID.equals(ID)
> >
> > These are objects in Java, so you need to use equals (or
> > StoreID.longValue==ID.longValue)
> >
> > Cheers
> >
> > Nicolas
> >
> > On Oct 21, 12:39 pm, John VDenley<[email protected]> wrote:
> >
> > > OK so Im sending in an ID number (Long) and Im doing a query on the
> > > datastore, getting all the "contacts" in the database, using the
> > > "getID" function to get the "StoredID" and comparing the ID's.
> >
> > > However for some reason the boolean "test" below never becomes true,
> > > despite after stepping through the program there are times when
> > > StoredID=16 and ID=16, but yet (StoredID==ID) does not evaluate to
> > > "true"
> >
> > > anyone got any ideas?
> >
> > >   public String updateContact(Long AdminID, Long ID, String
> > > Name,String Phone, String KnownAs, String Notes) throws
> > > NotLoggedInException {
> >
> > >             Contact ContactToUpdate=null;
> > >             Long StoredID;
> >
> > >             PersistenceManager pm = PMF.get().getPersistenceManager();
> > >             try {
> > >               Query q = pm.newQuery(Contact.class, "AdminID == AID");
> > >               q.declareParameters("Long AID");
> > >               List<Contact> Contacts = (List<Contact>)
> q.execute(AdminID);
> > >               for (Contact contact : Contacts)
> > >               {
> >
> > >                   StoredID=contact.getID();
> > >                   boolean test=(StoredID==ID);
> > >                   if (test)
> > >                   {
> > >                           ContactToUpdate=contact;
> > >                   }
> > >                   else
> > >                   {
> > >                           ContactToUpdate=null;
> > >                   }
> > >              }
> > >          }
> > >          finally
> > >          {
> > >               pm.close();
> > >          }
> > >       }
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to