/** {@inheritDoc} */
  @Override
  public Field loadByValue(int nIdEntry, String strValue, Plugin plugin) {
    DAOUtil daoUtil = new DAOUtil(SQL_QUERY_FIND_BY_VALUE, plugin);
    daoUtil.setInt(1, nIdEntry);
    daoUtil.setString(2, strValue);
    daoUtil.executeQuery();

    Field field = null;
    IEntry entry = null;

    if (daoUtil.next()) {
      field = new Field();
      field.setIdField(daoUtil.getInt(1));
      // parent entry
      entry = new Entry();
      entry.setIdEntry(daoUtil.getInt(2));
      field.setEntry(entry);
      field.setTitle(daoUtil.getString(3));
      field.setValue(daoUtil.getString(4));
      field.setHeight(daoUtil.getInt(5));
      field.setWidth(daoUtil.getInt(6));
      field.setDefaultValue(daoUtil.getBoolean(7));
      field.setMaxSizeEnter(daoUtil.getInt(8));
      field.setPosition(daoUtil.getInt(9));
      field.setValueTypeDate(daoUtil.getDate(10));
      field.setRoleKey(daoUtil.getString(11));
      field.setWorkgroup(daoUtil.getString(12));
      field.setShownInResultList(daoUtil.getBoolean(13));
      field.setShownInResultRecord(daoUtil.getBoolean(14));
    }

    daoUtil.free();

    return field;
  }
  /** {@inheritDoc} */
  @Override
  public synchronized int insert(Field field, Plugin plugin) {
    field.setIdField(newPrimaryKey(plugin));
    field.setPosition(newPosition(plugin));

    DAOUtil daoUtil = new DAOUtil(SQL_QUERY_INSERT, plugin);
    daoUtil.setInt(1, field.getIdField());
    daoUtil.setInt(2, field.getEntry().getIdEntry());
    daoUtil.setString(3, field.getTitle());
    daoUtil.setString(4, field.getValue());
    daoUtil.setInt(5, field.getHeight());
    daoUtil.setInt(6, field.getWidth());
    daoUtil.setBoolean(7, field.isDefaultValue());
    daoUtil.setInt(8, field.getMaxSizeEnter());
    daoUtil.setInt(9, field.getPosition());
    daoUtil.setDate(
        10,
        (field.getValueTypeDate() == null) ? null : new Date(field.getValueTypeDate().getTime()));

    daoUtil.setString(11, field.getRoleKey());
    daoUtil.setString(12, field.getWorkgroup());
    daoUtil.setBoolean(13, field.isShownInResultList());
    daoUtil.setBoolean(14, field.isShownInResultRecord());

    daoUtil.executeUpdate();
    daoUtil.free();

    return field.getIdField();
  }
  /** {@inheritDoc} */
  @Override
  public List<Field> selectFieldListByIdEntry(int nIdEntry, Plugin plugin) {
    List<Field> fieldList = new ArrayList<Field>();
    DAOUtil daoUtil = new DAOUtil(SQL_QUERY_SELECT_FIELD_BY_ID_ENTRY, plugin);
    daoUtil.setInt(1, nIdEntry);
    daoUtil.executeQuery();

    Field field = null;
    IEntry entry = null;

    while (daoUtil.next()) {
      field = new Field();
      field.setIdField(daoUtil.getInt(1));
      // parent entry
      entry = new Entry();
      entry.setIdEntry(daoUtil.getInt(2));
      field.setEntry(entry);
      field.setTitle(daoUtil.getString(3));
      field.setValue(daoUtil.getString(4));
      field.setHeight(daoUtil.getInt(5));
      field.setWidth(daoUtil.getInt(6));
      field.setDefaultValue(daoUtil.getBoolean(7));
      field.setMaxSizeEnter(daoUtil.getInt(8));
      field.setPosition(daoUtil.getInt(9));
      field.setValueTypeDate(daoUtil.getDate(10));
      field.setRoleKey(daoUtil.getString(11));
      field.setWorkgroup(daoUtil.getString(12));
      field.setShownInResultList(daoUtil.getBoolean(13));
      field.setShownInResultRecord(daoUtil.getBoolean(14));

      fieldList.add(field);
    }

    daoUtil.free();

    return fieldList;
  }