We are trying to manually retreive Records (entity) from a specific User. We are using exclusively JPA with unowned relationship. We noticed that the primaryKey isn't in the same format as the FK (user) in the datastore viewer.
This is our code of the Record: @PrimaryKey @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY) private Key key; @Persistent private Key user; @Persistent private double value; // Constructors which is generated this way in the appengine: | Key |ID/Name | user | value | +------------------------------------------------------------------------------------- +--------------+----------------------+--------------+ | aglub19hcHBfaWRyEwsSDU1lZGljYWxSZWNvcmQYBAw | 4 | User(2) | 0.54 | | aglub19hcHBfaWRyEwsSDU1lZGljYWxSZWNvcmQYBgw | 6 | User(2) | 0.51 | We tried to retreive the records this way but it doesn't work because the (Key)Record.user=User(2) is not encoded while (Key)User.key=aglub19hcHBfaWRyCgsSBFVzZXIYAQw is indeed encoded. ---CODE--- public List<MedicalRecord> getAll(User user) { PersistenceManager pm = PMF.get().getPersistenceManager(); Query query = pm.newQuery(MedicalRecord.class); query.setFilter("user == userParam"); query.declareParameters(Key.class.getName() + "userParam"); Transaction transaction = pm.currentTransaction(); try{ transaction.begin(); List<MedicalRecord> results = (List<MedicalRecord>) query.execute(user.getKey()); transaction.commit(); return results; } catch (Exception e) { transaction.rollback(); return null; } finally{ pm.close(); } } ---CODE--- What is the right way of query unowned relationship in JPA? Your help is very much appreciated. -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appengine@googlegroups.com. To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.