示例#1
0
  @Override
  public Book updateBook(Book book) {
    Document original = __wrapper.getDocument();
    Document doc = __wrapper.getDocument();

    try {
      Map<String, String> values = new HashMap<String, String>();
      values.put("isbn", book.getIsbn());
      values.put("publisher", book.getPublisher());
      values.put("title", book.getTitle());
      values.put("year", book.getYear() + "");
      values.put("authorIds", Utility.getInstance().join(",", book.getAuthorIds()));

      doc = __wrapper.updateEntry(doc, values, "isbn", book.getIsbn());
      __wrapper.commit(doc);
    } catch (Exception e) {
      e.printStackTrace();
      __wrapper.rollback(original);
      return null;
    }
    return book;
  }