예제 #1
0
  @Override
  public void insert(DataObject dataObject) throws SQLException {
    checkCache(dataObject, CHECK_INSERT);
    checkClass(dataObject, ObjetivoDO.class, CHECK_INSERT);

    ObjetivoDO objetivoDO = (ObjetivoDO) dataObject;

    objetivoDO.setId(getNextId());

    StringBuffer strbuf = new StringBuffer();

    strbuf.append("INSERT INTO ");
    strbuf.append(getTableName());
    strbuf.append(" VALUES (");
    strbuf.append(objetivoDO.getId());
    strbuf.append(", ");
    strbuf.append(singleQuotes(objetivoDO.getDescripcion()));
    strbuf.append(", ");
    strbuf.append(objetivoDO.getNumeroDeNpc());
    strbuf.append(", ");
    Reference<PlanetaDO> refPl = objetivoDO.getPlanetaRef();
    refPl.checkInsert();
    strbuf.append(refPl.getIdAsString());
    strbuf.append(")");

    System.err.println(strbuf.toString());

    connection.createStatement().execute(strbuf.toString());

    dtaSession.add(dataObject);
  }
  @Override
  public void insert(DataObject dataObject) throws SQLException {
    checkCache(dataObject, CHECK_INSERT);
    checkClass(dataObject, NivelHabilidadDO.class, CHECK_INSERT);

    NivelHabilidadDO nivelHabilidadDO = (NivelHabilidadDO) dataObject;

    nivelHabilidadDO.setId(getNextId());

    StringBuffer strbuf = new StringBuffer();

    strbuf.append("INSERT INTO ");
    strbuf.append(getTableName());
    strbuf.append(" VALUES (");
    strbuf.append(nivelHabilidadDO.getId()); // INSTANCIA
    strbuf.append(", ");
    strbuf.append(nivelHabilidadDO.getNivelDeHabilidad());
    strbuf.append(", ");
    strbuf.append(nivelHabilidadDO.getEfectividad());
    strbuf.append(", ");
    strbuf.append(nivelHabilidadDO.getCostoDeEnergia());
    strbuf.append(", ");
    strbuf.append(nivelHabilidadDO.getProbabilidad());
    strbuf.append(", ");

    Reference<HabilidadDO> refU = nivelHabilidadDO.getHabilidadRef();
    refU.checkInsert();
    strbuf.append(refU.getIdAsString());

    strbuf.append(")");

    System.err.println(strbuf.toString());

    connection.createStatement().execute(strbuf.toString());

    dtaSession.add(dataObject);
  }