コード例 #1
0
  public ru.agiledays.life.server.domain.Game load(final String name) {
    final Session session = database.openSession();

    Game doGame =
        (Game)
            session
                .createQuery("from Game where name = :gameName")
                .setParameter("gameName", name)
                .uniqueResult();
    if (doGame == null) {
      doGame = new Game();
    }

    return new GameTranslator().reconstitute(doGame);
  }
コード例 #2
0
  public void save(final ru.agiledays.life.server.domain.Game game) {
    final Session session = database.openSession();

    Game doGame =
        (Game)
            session
                .createQuery("from Game where name = :gameName")
                .setParameter("gameName", game.name())
                .uniqueResult();
    if (doGame == null) {
      doGame = new Game();
    }

    new GameTranslator().persist(game, doGame);
    session.saveOrUpdate(doGame);

    session.flush();
  }