/** Creates a new discrepancy note */
  public EntityBean create(EntityBean eb) {
    DiscrepancyNoteBean sb = (DiscrepancyNoteBean) eb;
    HashMap variables = new HashMap();
    HashMap nullVars = new HashMap();
    // INSERT INTO discrepancy_note
    // (description, discrepancy_note_type_id ,
    // resolution_status_id , detailed_notes , date_created,
    // owner_id, parent_dn_id)
    // VALUES (?,?,?,?,now(),?,?)
    variables.put(new Integer(1), sb.getDescription());
    variables.put(new Integer(2), new Integer(sb.getDiscrepancyNoteTypeId()));
    variables.put(new Integer(3), new Integer(sb.getResolutionStatusId()));
    variables.put(new Integer(4), sb.getDetailedNotes());

    variables.put(new Integer(5), new Integer(sb.getOwner().getId()));
    if (sb.getParentDnId() == 0) {
      nullVars.put(new Integer(6), new Integer(Types.INTEGER));
      variables.put(new Integer(6), null);
    } else {
      variables.put(new Integer(6), new Integer(sb.getParentDnId()));
    }
    variables.put(new Integer(7), sb.getEntityType());
    variables.put(new Integer(8), new Integer(sb.getStudyId()));

    this.executeWithPK(digester.getQuery("create"), variables, nullVars);
    if (isQuerySuccessful()) {
      sb.setId(getLatestPK());
    }

    return sb;
  }
  /** getEntityFromHashMap, the method that gets the object from the database query. */
  public Object getEntityFromHashMap(HashMap hm) {
    DiscrepancyNoteBean eb = new DiscrepancyNoteBean();
    Date dateCreated = (Date) hm.get("date_created");
    Integer ownerId = (Integer) hm.get("owner_id");
    eb.setCreatedDate(dateCreated);
    eb.setOwnerId(ownerId.intValue());

    // discrepancy_note_id serial NOT NULL,
    // description varchar(255),
    // discrepancy_note_type_id numeric,
    // resolution_status_id numeric,

    // detailed_notes varchar(1000),
    // date_created date,
    // owner_id numeric,
    // parent_dn_id numeric,
    eb.setId(selectInt(hm, "discrepancy_note_id"));
    eb.setDescription((String) hm.get("description"));
    eb.setDiscrepancyNoteTypeId(((Integer) hm.get("discrepancy_note_type_id")).intValue());
    eb.setResolutionStatusId(((Integer) hm.get("resolution_status_id")).intValue());
    eb.setParentDnId(((Integer) hm.get("parent_dn_id")).intValue());
    eb.setDetailedNotes((String) hm.get("detailed_notes"));
    eb.setEntityType((String) hm.get("entity_type"));
    eb.setDisType(DiscrepancyNoteType.get(eb.getDiscrepancyNoteTypeId()));
    eb.setResStatus(ResolutionStatus.get(eb.getResolutionStatusId()));
    eb.setStudyId(selectInt(hm, "study_id"));
    return eb;
  }