1

How can I use JDOQL to get a specific entry from a HashMap from the following structure:

class User {
    String username;
    Map<String, String> projects; //project name serves as the key
}

user.setUsername("John");
user.getProjects().add("Test Project", "Content");

I now want to look for the user "John" and fetch content (HasMaph.value) of the project named "Test Project".

The following will select the User itself. Can I rewrite the query so that the specific project content is directly fetched without retrieving the user?

Query q = pm.newQuery("SELECT UNIQUE path.to.User WHERE username == :username" AND projects.contains(project)");
User user = (User) q.execute("John", "Test Project");
user.get("Test Project);
Utsav
  • 1,593
  • 4
  • 22
  • 46
membersound
  • 81,582
  • 193
  • 585
  • 1,120

0 Answers0