Package org.springframework.jdbc.core.namedparam

Examples of org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate


  public int count() throws IOException {
    return template.queryForInt("SELECT count(*) FROM "+TABLE_NAME);
  }

  public boolean remove(LibraryQC qc) throws IOException {
    NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
    if (qc.isDeletable() &&
           (namedTemplate.update(LIBRARY_QC_DELETE,
                                 new MapSqlParameterSource().addValue("qcId", qc.getId())) == 1)) {
      Library l = qc.getLibrary();
      if (this.cascadeType.equals(CascadeType.PERSIST)) {
        if (l != null) libraryDAO.save(l);
      }
View Full Code Here


      Number newId = insert.executeAndReturnKey(params);
      platform.setPlatformId(newId.longValue());
    }
    else {
      params.addValue("platformId", platform.getPlatformId());
      NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
      namedTemplate.update(PLATFORM_UPDATE, params);
    }
   
    return platform.getPlatformId();
  }
View Full Code Here

          params.addValue("name", name);

          Number newId = insert.executeAndReturnKey(params);
          if (newId.longValue() != study.getId()) {
            log.error("Expected Study ID doesn't match returned value from database insert: rolling back...");
            new NamedParameterJdbcTemplate(template).update(STUDY_DELETE, new MapSqlParameterSource().addValue("studyId", newId.longValue()));
            throw new IOException("Something bad happened. Expected Study ID doesn't match returned value from DB insert");
          }
        }
        else {
          throw new IOException("Cannot save Study - invalid field:" + study.toString());
        }
      }
      catch (MisoNamingException e) {
        throw new IOException("Cannot save Study - issue with naming scheme", e);
      }
      /*
      String name = "STU"+ DbUtils.getAutoIncrement(template, TABLE_NAME);
      params.addValue("name", name);
      Number newId = insert.executeAndReturnKey(params);
      study.setStudyId(newId.longValue());
      study.setName(name);
      */

      Project p = study.getProject();

      SimpleJdbcInsert pInsert = new SimpleJdbcInsert(template)
                            .withTableName("Project_Study");

      MapSqlParameterSource poParams = new MapSqlParameterSource();
      poParams.addValue("Project_projectId", p.getProjectId())
              .addValue("studies_studyId", study.getId());
      try {
        pInsert.execute(poParams);
      }
      catch(DuplicateKeyException dke) {
        //ignore
      }
    }
    else {
      try {
        if (namingScheme.validateField("name", study.getName())) {
          params.addValue("studyId", study.getId())
                .addValue("name", study.getName());
          NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
          namedTemplate.update(STUDY_UPDATE, params);
        }
        else {
          throw new IOException("Cannot save Study - invalid field:" + study.toString());
        }
      }
View Full Code Here

                      @Property(name="includeParameterTypes", value="false")
              }
          )
  )
  public boolean remove(Study study) throws IOException {
    NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
    if (study.isDeletable() &&
           (namedTemplate.update(STUDY_DELETE,
                                 new MapSqlParameterSource().addValue("studyId", study.getId())) == 1)) {
      Project p = study.getProject();
      if (this.cascadeType.equals(CascadeType.PERSIST)) {
        if (p!=null) projectDAO.save(p);
      }
View Full Code Here

      Number newId = insert.executeAndReturnKey(params);
      poolQC.setId(newId.longValue());
    }
    else {
      params.addValue("qcId", poolQC.getId());
      NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
      namedTemplate.update(POOL_QC_UPDATE, params);
    }

    if (this.cascadeType != null) {
      Pool l = poolQC.getPool();
      if (this.cascadeType.equals(CascadeType.PERSIST)) {
View Full Code Here

  public int count() throws IOException {
    return template.queryForInt("SELECT count(*) FROM "+TABLE_NAME);
  }

  public boolean remove(PoolQC qc) throws IOException {
    NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
    if (qc.isDeletable() &&
           (namedTemplate.update(POOL_QC_DELETE,
                                 new MapSqlParameterSource().addValue("qcId", qc.getId())) == 1)) {
      Pool l = qc.getPool();
      if (this.cascadeType.equals(CascadeType.PERSIST)) {
        if (l != null) poolDAO.save(l);
      }
View Full Code Here

        throw new IOException("Cannot save SequencerPartitionContainer - issue with naming scheme", e);
      }
      */

      params.addValue("containerId", sequencerPartitionContainer.getId());
      NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
      namedTemplate.update(SEQUENCER_PARTITION_CONTAINER_UPDATE, params);
    }

    //MapSqlParameterSource delparams = new MapSqlParameterSource();
    //delparams.addValue("container_containerId", sequencerPartitionContainer.getContainerId());
    //NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
View Full Code Here

            params.addValue("identificationBarcode", barcode);

            Number newId = insert.executeAndReturnKey(params);
            if (newId.longValue() != library.getId()) {
              log.error("Expected library ID doesn't match returned value from database insert: rolling back...");
              new NamedParameterJdbcTemplate(template).update(LIBRARY_DELETE, new MapSqlParameterSource().addValue("libraryId", newId.longValue()));
              throw new IOException("Something bad happened. Expected library ID doesn't match returned value from DB insert");
            }
          }
          else {
            throw new IOException("Cannot save library - invalid field:" + library.toString());
          }
        }
        catch (MisoNamingException e) {
          throw new IOException("Cannot save library - issue with naming scheme", e);
        }
      }
    }
    else {
      try {
        if (libraryNamingScheme.validateField("name", library.getName()) && libraryNamingScheme.validateField("alias", library.getAlias())) {
          params.addValue("libraryId", library.getId())
                .addValue("name", library.getName())
                .addValue("identificationBarcode", library.getName() + "::" + library.getAlias());
          NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
          namedTemplate.update(LIBRARY_UPDATE, params);
        }
        else {
          throw new IOException("Cannot save library - invalid field:" + library.toString());
        }
      }
      catch (MisoNamingException e) {
        throw new IOException("Cannot save library - issue with naming scheme", e);
      }
    }

    MapSqlParameterSource libparams = new MapSqlParameterSource();
    libparams.addValue("library_libraryId", library.getId());
    NamedParameterJdbcTemplate libNamedTemplate = new NamedParameterJdbcTemplate(template);
    libNamedTemplate.update(LIBRARY_TAGBARCODE_DELETE_BY_LIBRARY_ID, libparams);

    /*
    if (library.getTagBarcode() != null) {
      SimpleJdbcInsert eInsert = new SimpleJdbcInsert(template)
              .withTableName("Library_TagBarcode");
View Full Code Here

                      @Property(name="includeParameterTypes", value="false")
              }
          )
  )
  public boolean remove(Library library) throws IOException {
    NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
    if (library.isDeletable() &&
           (namedTemplate.update(LIBRARY_DELETE,
                            new MapSqlParameterSource().addValue("libraryId", library.getId())) == 1)) {
      if (this.cascadeType.equals(CascadeType.PERSIST)) {
//        if (!poolDAO.listByLibraryId(library.getId()).isEmpty()) {
          //DbUtils.flushCache(cacheManager, "poolCache");
//        }
View Full Code Here

  public Collection<LibraryDilution> listAllLibraryDilutionsBySearch(String query, PlatformType platformType) {
    String squery = "%" + query + "%";
    MapSqlParameterSource params = new MapSqlParameterSource();
    params.addValue("search", squery);
          //.addValue("platformName", platformType.getKey());
    NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
    return namedTemplate.query(LIBRARY_DILUTION_SELECT_BY_SEARCH, params, new LazyLibraryDilutionMapper());
  }
View Full Code Here

TOP

Related Classes of org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.