예제 #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 update(DataObject dataObject) throws SQLException {
    checkCache(dataObject, CHECK_UPDATE);
    checkClass(dataObject, NivelHabilidadDO.class, CHECK_UPDATE);

    NivelHabilidadDO nivelHabilidadDO = (NivelHabilidadDO) dataObject;

    StringBuffer strbuf = new StringBuffer();

    strbuf.append("UPDATE ");
    strbuf.append(getTableName());
    strbuf.append(" SET ");

    strbuf.append(NivelHabilidadDO.NIVEL_DE_HABILIDAD);
    strbuf.append(" = ");
    strbuf.append(nivelHabilidadDO.getEfectividad());

    strbuf.append(", ");

    strbuf.append(NivelHabilidadDO.COSTO_DE_ENERGIA);
    strbuf.append(" = ");
    strbuf.append(nivelHabilidadDO.getCostoDeEnergia());

    strbuf.append(", ");

    strbuf.append(NivelHabilidadDO.PROBABILIDAD);
    strbuf.append(" = ");
    strbuf.append(nivelHabilidadDO.getProbabilidad());

    strbuf.append(", ");

    strbuf.append(NivelHabilidadDO.HABILIDAD_ID);
    strbuf.append(" = ");
    Reference<HabilidadDO> refP = nivelHabilidadDO.getHabilidadRef();
    refP.checkUpdate();
    strbuf.append(refP.getIdAsString());

    strbuf.append(", ");

    strbuf.append(" WHERE ");
    strbuf.append(NivelHabilidadDO.ID);
    strbuf.append(" = ");
    strbuf.append(nivelHabilidadDO.getId());

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

    connection.createStatement().execute(strbuf.toString());
  }
예제 #3
0
  @Override
  public void update(DataObject dataObject) throws SQLException {
    checkCache(dataObject, CHECK_UPDATE);
    checkClass(dataObject, ObjetivoDO.class, CHECK_UPDATE);

    ObjetivoDO objetivoDO = (ObjetivoDO) dataObject;

    StringBuffer strbuf = new StringBuffer();

    strbuf.append("UPDATE ");
    strbuf.append(getTableName());
    strbuf.append(" SET ");

    strbuf.append(ObjetivoDO.DESCRIPCION);
    strbuf.append(" = ");
    strbuf.append(singleQuotes(objetivoDO.getDescripcion()));

    strbuf.append(", ");

    strbuf.append(ObjetivoDO.NUMERO_DE_NPC);
    strbuf.append(" = ");
    strbuf.append(objetivoDO.getNumeroDeNpc());

    strbuf.append(", ");

    strbuf.append(ObjetivoDO.PLANETA_ID);
    strbuf.append(" = ");
    Reference<PlanetaDO> refPl = objetivoDO.getPlanetaRef();
    refPl.checkUpdate();
    strbuf.append(refPl.getIdAsString());

    strbuf.append(" WHERE ");
    strbuf.append(ObjetivoDO.ID);
    strbuf.append(" = ");
    strbuf.append(objetivoDO.getId());

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

    connection.createStatement().execute(strbuf.toString());
  }
  @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);
  }