Tabnine Logo
Dialect.supportsUpsert
Code IndexAdd Tabnine to your IDE (free)

How to use
supportsUpsert
method
in
org.sonar.db.dialect.Dialect

Best Java code snippets using org.sonar.db.dialect.Dialect.supportsUpsert (Showing top 9 results out of 315)

origin: SonarSource/sonarqube

@Override
public void execute(ComputationStep.Context context) {
 boolean supportUpsert = dbClient.getDatabase().getDialect().supportsUpsert();
 try (DbSession dbSession = dbClient.openSession(supportUpsert)) {
  Component root = treeRootHolder.getRoot();
  MeasureVisitor visitor = new MeasureVisitor(dbSession, supportUpsert);
  new DepthTraversalTypeAwareCrawler(visitor).visit(root);
  context.getStatistics().add("insertsOrUpdates", visitor.insertsOrUpdates);
 }
}
origin: SonarSource/sonarqube

@Test
public void upsert_does_not_update_row_if_values_are_not_changed() {
 if (!db.getDbClient().getDatabase().getDialect().supportsUpsert()) {
  return;
 }
 LiveMeasureDto dto = newLiveMeasure();
 underTest.upsert(db.getSession(), dto);
 // update
 int count = underTest.upsert(db.getSession(), dto);
 assertThat(count).isEqualTo(0);
 verifyPersisted(dto);
 verifyTableSize(1);
}
origin: SonarSource/sonarqube

@Test
public void upsert_updates_row_if_value_is_changed() {
 if (!db.getDbClient().getDatabase().getDialect().supportsUpsert()) {
  return;
 }
 LiveMeasureDto dto = newLiveMeasure().setValue(40.0);
 underTest.upsert(db.getSession(), dto);
 // update
 dto.setValue(50.0);
 int count = underTest.upsert(db.getSession(), dto);
 assertThat(count).isEqualTo(1);
 verifyPersisted(dto);
 verifyTableSize(1);
}
origin: SonarSource/sonarqube

@Test
public void upsert_updates_row_if_variation_is_removed() {
 if (!db.getDbClient().getDatabase().getDialect().supportsUpsert()) {
  return;
 }
 LiveMeasureDto dto = newLiveMeasure().setVariation(40.0);
 underTest.upsert(db.getSession(), dto);
 // update
 dto.setVariation(null);
 int count = underTest.upsert(db.getSession(), dto);
 assertThat(count).isEqualTo(1);
 verifyPersisted(dto);
 verifyTableSize(1);
}
origin: SonarSource/sonarqube

@Test
public void upsert_updates_row_if_variation_is_added() {
 if (!db.getDbClient().getDatabase().getDialect().supportsUpsert()) {
  return;
 }
 LiveMeasureDto dto = newLiveMeasure().setVariation(null);
 underTest.upsert(db.getSession(), dto);
 // update
 dto.setVariation(40.0);
 int count = underTest.upsert(db.getSession(), dto);
 assertThat(count).isEqualTo(1);
 verifyPersisted(dto);
 verifyTableSize(1);
}
origin: SonarSource/sonarqube

@Test
public void upsert_updates_row_if_value_is_added() {
 if (!db.getDbClient().getDatabase().getDialect().supportsUpsert()) {
  return;
 }
 LiveMeasureDto dto = newLiveMeasure().setValue(null);
 underTest.upsert(db.getSession(), dto);
 // update
 dto.setValue(40.0);
 int count = underTest.upsert(db.getSession(), dto);
 assertThat(count).isEqualTo(1);
 verifyPersisted(dto);
 verifyTableSize(1);
}
origin: SonarSource/sonarqube

@Test
public void upsert_updates_row_if_variation_is_changed() {
 if (!db.getDbClient().getDatabase().getDialect().supportsUpsert()) {
  return;
 }
 LiveMeasureDto dto = newLiveMeasure().setVariation(40.0);
 underTest.upsert(db.getSession(), dto);
 // update
 dto.setVariation(50.0);
 int count = underTest.upsert(db.getSession(), dto);
 assertThat(count).isEqualTo(1);
 verifyPersisted(dto);
 verifyTableSize(1);
}
origin: SonarSource/sonarqube

@Test
public void upsert_updates_row_if_value_is_removed() {
 if (!db.getDbClient().getDatabase().getDialect().supportsUpsert()) {
  return;
 }
 LiveMeasureDto dto = newLiveMeasure().setValue(40.0);
 underTest.upsert(db.getSession(), dto);
 // update
 dto.setValue(null);
 int count = underTest.upsert(db.getSession(), dto);
 assertThat(count).isEqualTo(1);
 verifyPersisted(dto);
 verifyTableSize(1);
}
origin: SonarSource/sonarqube

@Test
public void upsert_inserts_or_updates_row() {
 if (!db.getDbClient().getDatabase().getDialect().supportsUpsert()) {
  return;
 }
 // insert
 LiveMeasureDto dto = newLiveMeasure();
 int count = underTest.upsert(db.getSession(), dto);
 verifyPersisted(dto);
 verifyTableSize(1);
 assertThat(count).isEqualTo(1);
 // update
 dto.setValue(dto.getValue() + 1);
 dto.setVariation(dto.getVariation() + 10);
 dto.setData(dto.getDataAsString() + "_new");
 count = underTest.upsert(db.getSession(), dto);
 assertThat(count).isEqualTo(1);
 verifyPersisted(dto);
 verifyTableSize(1);
}
org.sonar.db.dialectDialectsupportsUpsert

Popular methods of Dialect

  • getId
  • getFalseSqlValue
  • getScrollDefaultFetchSize
    Fetch size to be used when scrolling large result sets.
  • getTrueSqlValue
  • getConnectionInitStatements
  • getDefaultDriverClassName
  • getValidationQuery
    Query used to validate the jdbc connection.
  • supportsMigration
    Indicates whether DB migration can be perform on the DB vendor implementation associated with the cu
  • getScrollSingleRowFetchSize
    Fetch size to scroll one row at a time. It sounds strange because obviously value is 1 in most cases
  • init
    This method is called when connecting for the first time to the database.
  • matchesJdbcUrl
    Used to autodetect dialect from connection URL
  • getSqlFromDual
  • matchesJdbcUrl,
  • getSqlFromDual,
  • matchesJdbcURL

Popular in Java

  • Finding current android device location
  • getApplicationContext (Context)
  • getResourceAsStream (ClassLoader)
  • onCreateOptionsMenu (Activity)
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • Table (org.hibernate.mapping)
    A relational table
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now