Beispiel #1
0
  public List<BookType> getAllType() {
    StringBuffer hql = new StringBuffer("FROM BookType bookType");

    List<BookType> result = (List<BookType>) baseDao.findWithHql(hql.toString());
    if (result.isEmpty()) {
      return null;
    }
    return result;
  }
Beispiel #2
0
  public List<Book> getBooksByTypeName(String typeName) {
    StringBuffer hql =
        new StringBuffer("FROM Book book WHERE book.bookType.typeName='" + typeName + "'");

    List<Book> result = (List<Book>) baseDao.findWithHql(hql.toString());
    if (result.isEmpty()) {
      return null;
    }
    return result;
  }
Beispiel #3
0
  public List<Book> getBooksByType(int typeID, Pager pager) {
    StringBuffer hql =
        new StringBuffer("FROM Book book WHERE book.bookType.typeId like '%" + typeID + "'");
    String countHql =
        "SELECT count(book.isbn) FROM Book book WHERE book.bookType.typeId like '%" + typeID + "'";
    Long count = ((List<Long>) baseDao.findWithHql(countHql)).get(0);
    List<Book> result;
    if (pager == null) {
      result = (List<Book>) baseDao.findWithHql(hql.toString());
    } else {
      pager.setTotalSize(count); // 设置总页数
      result = (List<Book>) baseDao.findWithHql(pager, hql.toString());
    }
    if (result.isEmpty()) {
      return null;
    }

    return result;
  }
Beispiel #4
0
  public BookType findByTypeId(Integer typeId) {
    StringBuffer hql =
        new StringBuffer("FROM BookType bookType WHERE bookType.typeId='" + typeId + "'");

    List<BookType> result = (List<BookType>) baseDao.findWithHql(hql.toString());
    if (result.isEmpty()) {
      return null;
    }
    BookType bookType = result.get(0);
    return bookType;
  }
Beispiel #5
0
  public int deleteByTypeName(BookType bookType) {

    baseDao.delete(bookType);
    return 1;
  }
Beispiel #6
0
  public void updateType(BookType bookType) {

    baseDao.update(bookType);
  }
Beispiel #7
0
 public void saveType(String typeName) {
   BookType type = new BookType();
   type.setTypeName(typeName);
   baseDao.save(type);
 }