@Override
  public void updateItem(MaintenancehistoryBean bean)
      throws ObjectNotFoundException, DuplicateException {
    Maintenancehistory dbItem =
        this.maintenancehistoryDAO.findByIdNoAutoCommit(bean.getPojo().getMaintenanceHistoryID());
    if (dbItem == null)
      throw new ObjectNotFoundException(
          "Not found Maintenancehistory " + bean.getPojo().getMaintenanceHistoryID());

    Maintenancehistory pojo = bean.getPojo();
    dbItem.setNoDay(pojo.getNoDay());
    dbItem.setNote(pojo.getNote());
    dbItem.setMaintenanceDate(pojo.getMaintenanceDate());
    this.maintenancehistoryDAO.update(dbItem);
  }
  @Override
  public Object[] search(MaintenancehistoryBean bean) {
    Map<String, Object> properties = new HashMap<String, Object>();
    StringBuffer whereClause = new StringBuffer(" 1 = 1");
    if (bean.getPojo().getMachine() != null && bean.getPojo().getMachine().getMachineID() > 0) {
      properties.put("machine.machineID", bean.getPojo().getMachine().getMachineID());
    }

    if (bean.getPojo().getMachinecomponent() != null
        && bean.getPojo().getMachinecomponent().getMachineComponentID() > 0) {
      properties.put(
          "machinecomponent.machineComponentID",
          bean.getPojo().getMachinecomponent().getMachineComponentID());
    }

    if (bean.getFromDate() != null) {
      whereClause.append(" AND maintenanceDate >= '").append(bean.getFromDate()).append("'");
    }
    if (bean.getToDate() != null) {
      whereClause.append(" AND maintenanceDate <= '").append(bean.getToDate()).append("'");
    }
    return this.maintenancehistoryDAO.searchByProperties(
        properties,
        bean.getFirstItem(),
        bean.getMaxPageItems(),
        bean.getSortExpression(),
        bean.getSortDirection(),
        true,
        whereClause.toString());
  }
 @Override
 public void addNew(MaintenancehistoryBean bean) throws DuplicateException {
   Maintenancehistory pojo = bean.getPojo();
   pojo = this.maintenancehistoryDAO.save(pojo);
   bean.setPojo(pojo);
 }