This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create a Get operation | |
Get get = | |
Get.newBuilder() | |
.namespace("ns") | |
.table("tbl") | |
.partitionKey(Key.ofInt("c1", 10)) | |
.clusteringKey(Key.of("c2", "aaa", "c3", 100L)) | |
.projections("c1", "c2", "c3", "c4") | |
.build(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"customer.customers": { | |
"transaction": true, | |
"partition-key": [ | |
"customer_id" | |
], | |
"columns": { | |
"customer_id": "INT", | |
"name": "TEXT", | |
"credit_limit": "INT", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scalar.db.storage=multi-storage | |
scalar.db.multi_storage.storages=cassandra,mysql | |
scalar.db.multi_storage.storages.cassandra.storage=cassandra | |
scalar.db.multi_storage.storages.cassandra.contact_points=localhost | |
scalar.db.multi_storage.storages.cassandra.username=cassandra | |
scalar.db.multi_storage.storages.cassandra.password=cassandra | |
scalar.db.multi_storage.storages.mysql.storage=jdbc | |
scalar.db.multi_storage.storages.mysql.contact_points=jdbc:mysql://localhost:3306/ | |
scalar.db.multi_storage.storages.mysql.username=root | |
scalar.db.multi_storage.storages.mysql.password=mysql |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void repayment(int customerId, int amount) throws TransactionException { | |
DistributedTransaction transaction = null; | |
try { | |
// トランザクションを開始 | |
transaction = manager.start(); | |
// 顧客情報をcustomersテーブルから取得 | |
Optional<Result> customer = | |
transaction.get( | |
Get.newBuilder() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String placeOrder(int customerId, int[] itemIds, int[] itemCounts) | |
throws TransactionException { | |
assert itemIds.length == itemCounts.length; | |
DistributedTransaction transaction = null; | |
try { | |
String orderId = UUID.randomUUID().toString(); | |
// トランザクションを開始 | |
transaction = manager.start(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String getCustomerInfo(int customerId) throws TransactionException { | |
DistributedTransaction transaction = null; | |
try { | |
// トランザクションを開始 | |
transaction = manager.start(); | |
// customers テーブルから指定された顧客IDの顧客情報を取得 | |
Optional<Result> customer = | |
transaction.get( | |
Get.newBuilder() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void repayment(int customerId, int amount) throws TransactionException { | |
DistributedTransaction transaction = null; | |
try { | |
// Start a transaction | |
transaction = manager.start(); | |
// Retrieve the customer info for the specified customer ID from the customers table | |
Optional<Result> customer = | |
transaction.get( | |
Get.newBuilder() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String placeOrder(int customerId, int[] itemIds, int[] itemCounts) | |
throws TransactionException { | |
assert itemIds.length == itemCounts.length; | |
DistributedTransaction transaction = null; | |
try { | |
String orderId = UUID.randomUUID().toString(); | |
// Start a transaction | |
transaction = manager.start(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String getCustomerInfo(int customerId) throws TransactionException { | |
DistributedTransaction transaction = null; | |
try { | |
// Start a transaction | |
transaction = manager.start(); | |
// Retrieve the customer info for the specified customer ID from the customers table | |
Optional<Result> customer = | |
transaction.get( | |
Get.newBuilder() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TransactionFactory factory = TransactionFactory.create("database.properties"); | |
DistributedTransactionManager manager = factory.getTransactionManager(); |