private HashMap<String, HashMap<String, Object>> updateProc(
     HashMap<String, Object> params, HttpServletRequest request, Session session, Login login)
     throws Exception {
   @SuppressWarnings("unused")
   String screen = request.getParameter("screen");
   Map<String, Object> updateInput = preProc(params);
   UserTable upd = null;
   try {
     upd = BeanUtil.copyMapToNewBean(updateInput, UserTable.class);
   } catch (Exception e) {
     ServiceUtil.mapToNewBeanExceptionAnalyze(e);
   }
   UserTable dbUserTable = em.find(UserTable.class, upd.getId());
   if (dbUserTable == null) {
     throw new SystemException("id:" + upd.getId().toString() + " が見つかりません");
   }
   if (!(upd.getTableName().equals(dbUserTable.getTableName())
           && upd.getKey1().equals(dbUserTable.getKey1())
           && upd.getKey2().equals(dbUserTable.getKey2()))
       && userTableCodeDupCheck(upd)) {
     return DBFluteUtil.setErrorMessage("このDataは既に使用されています。", params);
   }
   BeanUtil.copyBeanToBean(upd, dbUserTable, CopyOptionsUtil.excludeNull());
   em.merge(dbUserTable);
   Map<String, Object> map = null;
   map = entityToMap(upd);
   return DBFluteUtil.setFetchResult(map, params);
 }
  private boolean userTableCodeDupCheck(UserTable newEntity) {

    List<UserTable> sysTableList =
        em.createQuery(
                "From UserTable where key1 = :key1 and key2 = :key2 and tableName = :tableName and delFlag = :delFlag",
                UserTable.class)
            .setParameter("key1", newEntity.getKey1()) // enableEmptyStringQuery FIXME
            .setParameter("key2", newEntity.getKey2()) // enableEmptyStringQuery
            .setParameter("tableName", newEntity.getTableName())
            .setParameter("delFlag", 0)
            .getResultList();

    return (sysTableList.size() > 0);
  }
  private int getDelFlagMaxValue(final UserTable del) {
    Integer delFlagMax =
        em.createQuery(
                "select max(delFlag) From UserTable where tableName = :tableName and key1 = :key1 and key2 = :key2",
                Integer.class)
            .setParameter("tableName", del.getTableName())
            .setParameter("key1", del.getKey1())
            .setParameter("key2", del.getKey2())
            .getSingleResult();

    if (delFlagMax != null) {
      return delFlagMax;
    }
    return 1;
  }