by ampatspell
in Code
Gaeds is my tiny AppEngine for Java low-level DatastoreService wrapper. This is fifth post about new features that will form 1.2 final release. The previous posts are: Inheritance, GaedsKey
Gaeds Model attribute to Entity property mapping is done using @Property annotation. By default attribute (class field) names are used also as Entity property names but this can be customized using @Property(name = "differentName"). So lets consider a small example:
@Model public class User { @PrimaryKey private GaedsKey<User> key; @Property(name = "fullName") private String login; @Property private String password; } User user = new User(); user.setLogin("ampatspell"); user.setPassword("zeebaneighba"); sess.put(user);
Entities will have the following properties:
User user = sess.get(user); Entity entity = Gaeds.asModel(user).getEntity(); // accessing Entity directly assertEquals("ampatspell", entity.getProperty("fullName")); assertEquals("zeebaneighba", entity.getProperty("password"));
And now the breaking change: query filters and sort parameters now use attribute names instead of entity property names. This means that to filter by login attribute, the "login" must be used, not "fullName":
User user; // SELECT * from User WHERE fullName = ampatspell user = sess.query().model(User.class).eq("login", "ampatspell").singleResult(); assertNotNull(user); // SELECT * from User WHERE password = zeebaneighba user = sess.query().model(User.class).eq("password", "zeebaneighba").singleResult(); assertNotNull(user);
Please check your DAO’s for queries which filter by custom property names and update them to attribute names.
I’m sorry that I found this bug only now. The behavior could be left as is but I feel this breaking change is needed.