JDO Google App Engine validates user

I am following a tutorial on the Google engine, and the part explaining JDO is done as part of the guestbook. Therefore, when they request persistence (BigTable, I reckon), they are interested in returning all the results.

I am trying to adapt this to display the results for a specific user, but it seems to be having problems.

UserService userService = UserServiceFactory.getUserService();
User user = userService.getCurrentUser();
if(user != null) {
    PersistenceManager pm = PerManFac.get().getPersistenceManager();
    String query = "select * from " + Team.class.getName();
    List<Team> teamList = (List<Team>) pm.newQuery(query).execute();
    if(teamList.isEmpty()) {

This is part of what I still have, I need to adapt my String request to "where user = user", but every time I get problems.

My team has only a key, user, string and date.

+3
source share
1 answer

JDOQL. , , .

@PersistenceCapable
public class Team {
  @Persistent(mappedBy = "team")
  private List<Employee> employees;
}

@PersistenceCapable
public class Employee {
  @PrimaryKey
  private String user;

  @Persistent
  private Team team;
}

Employee, :

UserService userService = UserServiceFactory.getUserService();
User user = userService.getCurrentUser();

PersistenceManager pm = PMF.get().getPersistenceManager();
Employee employee = pm.getObjectById(Employee.class, user.getEmail());
Team employee.getTeam();

, . , (?), .

, , , User ( ), . User , , , , -, .

+1

Source: https://habr.com/ru/post/1764374/


All Articles