Package org.sonar.core.persistence

Examples of org.sonar.core.persistence.DbSession


  public void insert(DbSession session, IssueChangeDto change) {
    session.getMapper(IssueChangeMapper.class).insert(change);
  }

  public boolean delete(String key) {
    DbSession session = mybatis.openSession(false);
    try {
      IssueChangeMapper mapper = session.getMapper(IssueChangeMapper.class);
      int count = mapper.delete(key);
      session.commit();
      return count == 1;

    } finally {
      MyBatis.closeQuietly(session);
    }
View Full Code Here


      MyBatis.closeQuietly(session);
    }
  }

  public boolean update(IssueChangeDto change) {
    DbSession session = mybatis.openSession(false);
    try {
      IssueChangeMapper mapper = session.getMapper(IssueChangeMapper.class);
      int count = mapper.update(change);
      session.commit();
      return count == 1;

    } finally {
      MyBatis.closeQuietly(session);
    }
View Full Code Here

  /**
   * This method is reentrant. It can be executed even if the project is already indexed.
   */
  public ResourceIndexerDao indexProject(final int rootProjectId) {
    DbSession session = mybatis.openSession(true);
    try {
      indexProject(rootProjectId, session);
      session.commit();
      return this;

    } finally {
      MyBatis.closeQuietly(session);
    }
View Full Code Here

  /**
   * This method is reentrant. It can be executed even if some projects are already indexed.
   */
  public ResourceIndexerDao indexProjects() {
    final DbSession session = mybatis.openSession(true);
    try {
      final ResourceIndexerMapper mapper = session.getMapper(ResourceIndexerMapper.class);
      session.select("org.sonar.core.resource.ResourceIndexerMapper.selectRootProjectIds", /* workaround to get booleans */ResourceIndexerQuery.create(), new ResultHandler() {
        @Override
        public void handleResult(ResultContext context) {
          Integer rootProjectId = (Integer) context.getResultObject();
          doIndexProject(rootProjectId, session, mapper);
          session.commit();
        }
      });
      return this;

    } finally {
View Full Code Here

    this.profiler = profiler;
    this.system2 = system2;
  }

  public PurgeDao purge(PurgeConfiguration conf) {
    DbSession session = mybatis.openSession(true);
    try {
      purge(session, conf);
      session.commit();
    } finally {
      MyBatis.closeQuietly(session);
    }
    return this;
  }
View Full Code Here

    });
    session.commit();
  }

  public List<PurgeableSnapshotDto> selectPurgeableSnapshots(long resourceId) {
    DbSession session = mybatis.openSession(true);
    try {
      return selectPurgeableSnapshots(resourceId, session);
    } finally {
      MyBatis.closeQuietly(session);
    }
View Full Code Here

    Collections.sort(result);
    return result;
  }

  public PurgeDao deleteResourceTree(long rootProjectId) {
    final DbSession session = mybatis.openSession(true);
    final PurgeMapper mapper = session.getMapper(PurgeMapper.class);
    try {
      deleteProject(rootProjectId, mapper, new PurgeCommands(session, profiler));
      return this;
    } finally {
      MyBatis.closeQuietly(session);
View Full Code Here

    mapper.disableResource(resourceId);
    mapper.resolveResourceIssuesNotAlreadyResolved(resourceId, new Date(system2.now()));
  }

  public PurgeDao deleteSnapshots(PurgeSnapshotQuery query) {
    final DbSession session = mybatis.openSession(true);
    try {
      return deleteSnapshots(query, session);

    } finally {
      MyBatis.closeQuietly(session);
View Full Code Here

  @Test
  public void select_comments_by_issues() {
    setupData("shared");

    DbSession session = getMyBatis().openSession(false);
    List<DefaultIssueComment> comments = dao.selectCommentsByIssues(session, Arrays.asList("1000"));
    MyBatis.closeQuietly(session);
    assertThat(comments).hasSize(2);

    // chronological order
View Full Code Here

  @Test
  public void select_comments_by_issues_on_huge_number_of_issues() {
    setupData("shared");

    DbSession session = getMyBatis().openSession(false);
    List<String> hugeNbOfIssues = newArrayList();
    for (int i=0; i<4500; i++) {
      hugeNbOfIssues.add("ABCD"+i);
    }
    List<DefaultIssueComment> comments = dao.selectCommentsByIssues(session, hugeNbOfIssues);
View Full Code Here

TOP

Related Classes of org.sonar.core.persistence.DbSession

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.