int sc_id = GENERATOR.nextInt(1000) + 1;
int i_id = GENERATOR.nextInt(10000) + 1;
// Does this shopping cart exist?
mw.executeQuery(transactionUuid, new QueryFuture() {
public void onResult(String[][] result) {
// System.out.println("the first result:");
// System.out.println(result);
}
}, "SELECT * FROM shopping_cart WHERE sc_id = " + sc_id);
// Here you get sometimes an abort, since two workers try to insert the same shopping_cart
// if (res.length == 0)
// {
UpdateFuture uf = new UpdateFuture();
mw.executeUpdate(transactionUuid, uf, "INSERT INTO shopping_cart (sc_id, sc_c_id, sc_total) VALUES ("
+ sc_id + "," + GENERATOR.nextInt(20000) + ", 0)");
// }
mw.executeQuery(transactionUuid, new QueryFuture() {
public void onResult(String[][] result) {
}
}, "SELECT scl_qty FROM shopping_cart_line WHERE scl_sc_id = "
+ sc_id + " AND scl_i_id =" + i_id);