Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation examples on transaction management contains invalid code #23

Closed
carlosmiranda opened this issue Jun 13, 2014 · 10 comments
Closed

Comments

@carlosmiranda
Copy link
Contributor

In our documentation page http://jdbc.jcabi.com/example-transaction.html, we have the following example, which contains some invalid statements:

public class Main {
  public static void main(String[] args) {
    new JdbcSession(source)
      .autocommit(false)
      .sql("START TRANSACTION")
      .update() // Will not compile!
      .sql("DELETE FROM employee WHERE name = ?")
      .set("Jeff Lebowski")
      .update() // Ditto.
      .sql("INSERT INTO employee VALUES (?)")
      .set("Walter Sobchak")
      .insert(Outcome.VOID) // Neither will this.
      .commit();
  }
}

This is wrong because the method update and insert have signatures T update(Outcome<T>) and T insert(Outcome<T>). We should be referring to the execute() method instead, like so:

public class Main {
  public static void main(String[] args) {
    new JdbcSession(source)
      .autocommit(false)
      .sql("START TRANSACTION")
      .execute() // Now this will compile!
      .sql("DELETE FROM employee WHERE name = ?")
      .set("Jeff Lebowski")
      .execute() // Change it here, too
      .sql("INSERT INTO employee VALUES (?)")
      .set("Walter Sobchak")
      .execute() // And here.
      .commit();
  }
}
@yegor256 yegor256 added the bug label Jun 13, 2014
@dmarkov
Copy link

dmarkov commented Jun 13, 2014

this task will get someone's attention soon

@dmarkov
Copy link

dmarkov commented Jun 13, 2014

thanks for reporting! I topped your account for 15 mins, transaction 40726905

@dmarkov
Copy link

dmarkov commented Dec 26, 2014

@darkled the task is for you now, follow these guidelines. Don't hesitate to ask any technical questions right here

Task's budget is 30 mins (see this for explanation)

@asaen
Copy link

asaen commented Jan 9, 2015

@carlosmiranda @dmarkov please, pay your attention, that PR is sent, but it's acceptance is blocked by #33

@yegor256
Copy link
Member

yegor256 commented Jan 9, 2015

@dmarkov we're waiting for #33

@dmarkov
Copy link

dmarkov commented Jan 12, 2015

@dmarkov we're waiting for #33

@yegor256 sure, let's wait for #33

@dmarkov
Copy link

dmarkov commented Jan 19, 2015

I think we can continue, impediment #33 is closed

@asaen
Copy link

asaen commented Jan 19, 2015

@carlosmiranda should be fixed within PR #32, please, check it and close the issue if it is done.

@carlosmiranda
Copy link
Contributor Author

@darkled Indeed it's fixed, thank you. Closing now.

@dmarkov
Copy link

dmarkov commented Jan 21, 2015

@darkled thank you, added 30 mins to your acc, payment num is 50573737... +30 added to your rating, current score is: +285

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants