Package org.springframework.jdbc.core.namedparam

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


                      @Property(name="includeParameterTypes", value="false")
              }
          )
  )
  public boolean remove(Experiment experiment) throws IOException {
    NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
    if (experiment.isDeletable() &&
           (namedTemplate.update(EXPERIMENT_DELETE,
                            new MapSqlParameterSource().addValue("experimentId", experiment.getId())) == 1)) {
      Study s = experiment.getStudy();
      if (this.cascadeType.equals(CascadeType.PERSIST)) {
        if (s!=null) studyDAO.save(s);
        if (experiment.getPool() != null) {
View Full Code Here


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

    return sequencerReference.getId();
  }
View Full Code Here

  public Collection<SequencerReference> listByPlatformType(PlatformType platformType) throws IOException {
    return template.query(SEQUENCER_REFERENCE_SELECT_BY_PLATFORM, new Object[]{platformType.getKey()}, new SequencerReferenceMapper());
 

  public boolean remove(SequencerReference r) throws IOException {
    NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
    return (r.isDeletable() &&
           (namedTemplate.update(SEQUENCER_REFERENCE_DELETE,
                                 new MapSqlParameterSource().addValue("referenceId", r.getId())) == 1));
  }
View Full Code Here

//  }

  public boolean removeWatchedEntity(Watchable watchable) throws IOException {
    MapSqlParameterSource eParams = new MapSqlParameterSource();
    eParams.addValue("entityName", watchable.getWatchableIdentifier());
    NamedParameterJdbcTemplate eNamedTemplate = new NamedParameterJdbcTemplate(template);
    return eNamedTemplate.update(WATCHER_DELETE, eParams) == 1;
  }
View Full Code Here

      eParams.addValue("entityName", watchable.getWatchableIdentifier());
      eParams.addValue("userId", user.getUserId());

      log.debug("DAO removal of " + user.getUserId() + " from " + watchable.getWatchableIdentifier());

      NamedParameterJdbcTemplate eNamedTemplate = new NamedParameterJdbcTemplate(template);
      return eNamedTemplate.update(WATCHER_DELETE_BY_USER_ID, eParams) == 1;
    }
    return false;
  }
View Full Code Here

          params.addValue("name", name);

          Number newId = insert.executeAndReturnKey(params);
          if (newId.longValue() != project.getId()) {
            log.error("Expected Project ID ('"+project.getId()+"') doesn't match returned value ('"+newId.longValue()+"') from database insert: rolling back...");
            new NamedParameterJdbcTemplate(template).update(PROJECT_DELETE, new MapSqlParameterSource().addValue("projectId", newId.longValue()));
            throw new IOException("Something bad happened. Expected Project ID doesn't match returned value from DB insert");
          }
        }
        else {
          throw new IOException("Cannot save Project - invalid field:" + project.toString());
        }
      }
      catch (MisoNamingException e) {
        throw new IOException("Cannot save Project - issue with naming scheme", e);
      }
      /*
      String name = "PRO" + DbUtils.getAutoIncrement(template, TABLE_NAME);
      params.addValue("name", name);
      Number newId = insert.executeAndReturnKey(params);
      project.setProjectId(newId.longValue());
      project.setName(name);
      */
    }
    else {
      try {
        if (namingScheme.validateField("name", project.getName())) {
          params.addValue("projectId", project.getId())
                .addValue("name", project.getName());
          NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
          namedTemplate.update(PROJECT_UPDATE, params);
        }
        else {
          throw new IOException("Cannot save Project - invalid field:" + project.toString());
        }
      }
      catch (MisoNamingException e) {
        throw new IOException("Cannot save Project - issue with naming scheme", e);
      }
      /*
      params.addValue("projectId", project.getProjectId());
      params.addValue("name", project.getName());
      NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
      namedTemplate.update(PROJECT_UPDATE, params);
      */
    }

    if (this.cascadeType != null) {
      if (this.cascadeType.equals(CascadeType.PERSIST)) {
        MapSqlParameterSource eParams = new MapSqlParameterSource();
        eParams.addValue("project_projectId", project.getProjectId());
        NamedParameterJdbcTemplate eNamedTemplate = new NamedParameterJdbcTemplate(template);
        eNamedTemplate.update(PROJECT_ISSUES_DELETE_BY_PROJECT_ID, eParams);

        if (project.getIssueKeys() != null && !project.getIssueKeys().isEmpty()) {
          for (String s : project.getIssueKeys()) {
            SimpleJdbcInsert fInsert = new SimpleJdbcInsert(template).withTableName("Project_Issues");
            MapSqlParameterSource fcParams = new MapSqlParameterSource();
View Full Code Here

        log.warn("This Project/Overview combination already exists - not inserting: " + dke.getMessage());
      }
    }
    else {
      params.addValue("overviewId", overview.getOverviewId());
      NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
      namedTemplate.update(OVERVIEW_UPDATE, params);
    }

    if (this.cascadeType != null && this.cascadeType.equals(CascadeType.PERSIST)) {
      if (!overview.getNotes().isEmpty()) {
        for (Note n : overview.getNotes()) {
View Full Code Here

                          @Property(name = "includeParameterTypes", value = "false")
                  }
          )
  )
  public boolean remove(Project project) throws IOException {
    NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
    boolean ok = true;
    if (project.isDeletable() &&
        (namedTemplate.update(PROJECT_DELETE,
                              new MapSqlParameterSource().addValue("projectId", project.getProjectId())) == 1)) {
      if (!project.getSamples().isEmpty()) {
        for (Sample s : project.getSamples()) {
          ok = sampleDAO.remove(s);
        }
View Full Code Here

    }
    return false;
  }

  public boolean removeOverview(ProjectOverview overview) throws IOException {
    NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template);
    return (overview.isDeletable() &&
           (namedTemplate.update(OVERVIEW_DELETE,
                                 new MapSqlParameterSource().addValue("overviewId", overview.getOverviewId())) == 1));
  }
View Full Code Here

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

    if (this.cascadeType != null) {
      Library l = libraryQC.getLibrary();
      if (this.cascadeType.equals(CascadeType.PERSIST)) {
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.