Examples of Table and TableConnection
code:java
// Creates an entry point
Sorm sorm = Sorm.create("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;");
// Create a table access object.
BasicH2Table<Customer> customerTable = new BasicH2Table<>(sorm, Customer.class);
// Create the table based on Customer.class
customerTable.createTableIfNotExists();
// Open TableConnection. It will be closed with try-with-resources block.
try (TableConnection<Customer> conn = customerTable.open()) {
// Print table definition.
System.out.println(conn.getTableMetaData());
// Insert objects.
conn.insert(Customer.ALICE, Customer.BOB, Customer.CAROL, Customer.DAVE);
// Print all rows on the customer table.
System.out.println(conn.selectAll());
} catch (Exception e) {
e.printStackTrace();
}