Esempio n. 1
0
  public void doStuff() {
    Session session = Db.getSession();
    session.beginTransaction();

    User user = new User(new Person("Pascal", "Mazars"), "pma", "cacaprout");
    System.out.println("Hello " + user);
    ID<User> id = user.save();
    System.out.println("Persisted with id " + id);
    System.out.println(
        "Persisted with id " + new User(new Person("Daddy", "Longleg"), "dlg", "cacaprout").save());

    //        User foundUser = UserFinder.getInstance().findUnique("from app.core.User where
    // person.firstName = 'Pascal'");
    //        System.out.println("Found unique with firstName = 'Pascal': " + foundUser.toString());

    //        User foundUser2 = new IDFinder<User>().get(id);
    //        System.out.println("Found with id " + id + ": " + foundUser2.toString());

    // foundUser2.getPerson().setDateOfBirth(new Date());

    //        User foundUser3 = foundUser2.getPerson().getUser();
    //        System.out.println("Found with getPerson().getUser(): " + foundUser3.toString());

    List<User> userList = User.findAll(); // find("from app.core.User");
    System.out.println("List<app.core.User>: \n" + ORMUtils.toResultString(userList));

    System.out.println("Db dump: " + Db.dump());

    session.flush();
    throw ApplicationError.somethingWentTerriblyWrong();
  }
Esempio n. 2
0
 public static Class parseEntityClassFromNamedQuery(String queryName) {
   //        return parseEntityClass(Db.getSession().getNamedQuery(queryName).getQueryString());
   return Db.getSession().getNamedQuery(queryName).getReturnTypes()[0].getReturnedClass();
 }