Right, I don’t know if I’m barking entirely up the wrong tree here – I’m finding JDO and the Google AppEngine a bit tricky to get the hang of. Anyway, here goes.
I have a class that contains another class as one of it’s internal variables (see player1)
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class JDOGame
{
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Long id;
@Persistent
private String map;
@Persistent
private RPCDataPlayer player1;
// getters, setters, constructors etc...
}
The class RPCDataPlayer is Serializable and very basic….
public class RPCDataPlayer implements IsSerializable
{
public String name;
public int id;
// getters & setters & constructors oh my
public int getId() { return id; }
}
So, my question is…how do I create a query where I can get all the JDOGames that contain an RPCDataPlayer with id = x?
I can’t do a query like…
SELECT FROM JDOGame.class.getName() WHERE player1.getId() == x
…so what techniques or suggestions do people have for this to work?
Thanks in advance.
The Google App Engine Database is not a relational database so you can not do joins. You can persist RPCDataPlayer as a table.
And then you can just query this like this.
Once you have and instance of RPCDataPlayer you can get get JDOGame by calling: