Hi Jason, I have looked into this somewhat, and I think there is a "bug" (or at least a naive assumption) in MetaDataValidator.validatePrimaryKey() around line: 331
private AbstractMemberMetaData validatePrimaryKey() { int[] pkPositions = acmd.getPKMemberPositions(); if (pkPositions == null) { throw new DatastoreMetaDataException(acmd, "No primary key defined."); } if (pkPositions.length != 1) { throw new DatastoreMetaDataException(acmd, "More than one primary key field."); } int pkPos = pkPositions[0]; AbstractMemberMetaData pkMemberMetaData = acmd.getMetaDataForManagedMemberAtAbsolutePosition(pkPos); Class<?> pkType = pkMemberMetaData.getType(); if (pkType.equals(Long.class)) { noParentAllowed = true; } else if (pkType.equals(String.class)) { if (!DatastoreManager.isEncodedPKField(acmd, pkPos)) { noParentAllowed = true; } else { // encoded string pk if (hasIdentityStrategy(IdentityStrategy.SEQUENCE, pkMemberMetaData)) { throw new DatastoreMetaDataException( acmd, pkMemberMetaData, "IdentityStrategy SEQUENCE is not supported on encoded String primary keys."); } } } else if (pkType.equals(Key.class)) { if (hasIdentityStrategy(IdentityStrategy.SEQUENCE, pkMemberMetaData)) { throw new DatastoreMetaDataException( acmd, pkMemberMetaData, "IdentityStrategy SEQUENCE is not supported on primary keys of type " + Key.class.getName()); } } else { throw new DatastoreMetaDataException( acmd, pkMemberMetaData, "Unsupported primary key type: " + pkType.getName()); } return pkMemberMetaData; } this method assumes that there is a single PK field: if (pkPositions.length != 1) ... I think that what should really happen here is that each pk field should be validated/matched against the key objject id key class? let me know, I can file a bug, and perhaps even supply a fix ... On Oct 14, 2:53 pm, "Jason (Google)" <apija...@google.com> wrote: > Can you go into more of what you're seeing? That definitely doesn't sound > right. > You have a kind which uses a String (or String-encoded key?) as its primary > key, but you're not able to query for it? By "runtime fails," does that mean > you're seeing a stack trace? If so, can you share it? Is this fairly > reproducible? How much time do you have to wait before it works and then > stops working? > > - Jason > > > > On Wed, Oct 14, 2009 at 2:40 PM, Larry Cable <larry.ca...@gmail.com> wrote: > > > Thanks Jason, > > I eventually discovered that by chance, that the PK class > > would work (mostly) with String types ... > > > although I am now seeing even less explicable behavior where it > > appears that the runtime fails the 1st time > > I call it to query the PK class enabled entity but works subsequent > > times ... go figure! > > > On Oct 14, 12:39 pm, "Jason (Google)" <apija...@google.com> wrote: > > > App Engine's datastore, which is built on Bigtable, has a very particular > > > format for keys -- the datastore is not a traditional RDBMS. As > > documented, > > > Long, Key, and String are supported, and other objects will fail. > > > >http://code.google.com/appengine/docs/java/datastore/creatinggettinga... > > > > - Jason > > > > On Mon, Oct 12, 2009 at 10:06 PM, datanucleus <andy_jeffer...@yahoo.com > > >wrote: > > > > > JDO allows you to have multiple PK fields, as does DataNucleus. GAE/J > > > > overrides this and prevents it.- Hide quoted text - > > > > - Show quoted text -- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ 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 google-appengine-java@googlegroups.com To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en -~----------~----~----~----~------~----~------~--~---