| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1047,26 +1047,26 @@ public Void run(TransactionContext transaction) throws Exception { | |||
| 1047 | 1047 | // Transfer marketing budget from one album to another. We do it in a transaction to | |
| 1048 | 1048 | // ensure that the transfer is atomic. | |
| 1049 | 1049 | String sql1 = | |
| 1050 | - "SELECT MarketingBudget from Albums WHERE SingerId = 1 and AlbumId = 1"; | ||
| 1050 | + "SELECT MarketingBudget from Albums WHERE SingerId = 2 and AlbumId = 2"; | ||
| 1051 | 1051 | ResultSet resultSet = transaction.executeQuery(Statement.of(sql1)); | |
| 1052 | - long album1Budget = 0; | ||
| 1052 | + long album2Budget = 0; | ||
| 1053 | 1053 | while (resultSet.next()) { | |
| 1054 | - album1Budget = resultSet.getLong("MarketingBudget"); | ||
| 1054 | + album2Budget = resultSet.getLong("MarketingBudget"); | ||
| 1055 | 1055 | } | |
| 1056 | 1056 | // Transaction will only be committed if this condition still holds at the time of | |
| 1057 | 1057 | // commit. Otherwise it will be aborted and the callable will be rerun by the | |
| 1058 | 1058 | // client library. | |
| 1059 | - if (album1Budget >= 300000) { | ||
| 1059 | + if (album2Budget >= 300000) { | ||
| 1060 | 1060 | String sql2 = | |
| 1061 | - "SELECT MarketingBudget from Albums WHERE SingerId = 2 and AlbumId = 2"; | ||
| 1061 | + "SELECT MarketingBudget from Albums WHERE SingerId = 1 and AlbumId = 1"; | ||
| 1062 | 1062 | ResultSet resultSet2 = transaction.executeQuery(Statement.of(sql2)); | |
| 1063 | - long album2Budget = 0; | ||
| 1064 | - while (resultSet.next()) { | ||
| 1065 | - album2Budget = resultSet2.getLong("MarketingBudget"); | ||
| 1063 | + long album1Budget = 0; | ||
| 1064 | + while (resultSet2.next()) { | ||
| 1065 | + album1Budget = resultSet2.getLong("MarketingBudget"); | ||
| 1066 | 1066 | } | |
| 1067 | 1067 | long transfer = 200000; | |
| 1068 | - album2Budget += transfer; | ||
| 1069 | - album1Budget -= transfer; | ||
| 1068 | + album2Budget -= transfer; | ||
| 1069 | + album1Budget += transfer; | ||
| 1070 | 1070 | Statement updateStatement = | |
| 1071 | 1071 | Statement.newBuilder( | |
| 1072 | 1072 | "UPDATE Albums " | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -186,12 +186,12 @@ public void testSample() throws Exception { | |||
| 186 | 186 | ||
| 187 | 187 | runSample("writewithtransactionusingdml"); | |
| 188 | 188 | out = runSample("querymarketingbudget"); | |
| 189 | - assertThat(out).contains("1 1 1800000"); | ||
| 190 | - assertThat(out).contains("2 2 200000"); | ||
| 189 | + assertThat(out).contains("1 1 2200000"); | ||
| 190 | + assertThat(out).contains("2 2 550000"); | ||
| 191 | 191 | ||
| 192 | 192 | runSample("updateusingpartitioneddml"); | |
| 193 | 193 | out = runSample("querymarketingbudget"); | |
| 194 | - assertThat(out).contains("1 1 1800000"); | ||
| 194 | + assertThat(out).contains("1 1 2200000"); | ||
| 195 | 195 | assertThat(out).contains("2 2 100000"); | |
| 196 | 196 | ||
| 197 | 197 | runSample("deleteusingpartitioneddml"); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments