Reputation: 1
I have user entity which has an embedded entity called address.Within address there is property called city. I want to query all the users in a particular city.
public class User implements Serializable {
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
String id;
...
EmbeddedEntity address;
//Getter ,Setter
}
The data for embedded entity is set as
address.setProperty("Country","India");
address.setProperty("City","Chennai");
Query:
Query q = mgr.newQuery(User.class,"adderess.City == :arg0");
List<User> u = (List<User>) q.execute("Chennai");
It is not querying and throwing error
encountered a variable expression that isn't part of a join. maybe you're referencing a non-existent field of an embedded class.
So how to query and filter by property inside the embedded entity
Upvotes: 0
Views: 224
Reputation: 2887
This class is similar to Entity, but differs in the following ways:
Converting your EmbeddedEntity to an Entity or another serializable object should let you query on the embedded fields.
Upvotes: 0