Refine search
@Override public Void inTransaction(final Handle conn, final TransactionStatus status) throws Exception { conn.execute("insert into dummy2 (dummy_id) values ('" + UUID.randomUUID().toString() + "')"); return null; } });
@Before public void setUp() throws Exception { dbi = new DBI("jdbc:h2:mem:" + UUID.randomUUID()); handle = dbi.open(); handle.execute("create table something (id int primary key, name varchar(100))"); }
@Before public void setUp() throws Exception { dbi = new DBI("jdbc:h2:mem:" + UUID.randomUUID()); handle = dbi.open(); handle.execute("create table something (id int primary key, name varchar(100))"); }
@Override public Void withHandle(final Handle handle) throws Exception { handle.execute("DROP TABLE IF EXISTS invoices;\n" + "CREATE TABLE invoices (\n" + " record_id serial unique,\n" + " id varchar(36) NOT NULL,\n" + " account_id varchar(36) NOT NULL,\n" + " invoice_date date NOT NULL,\n" + " target_date date,\n" + " currency varchar(3) NOT NULL,\n" + " status varchar(15) NOT NULL DEFAULT 'COMMITTED',\n" + " migrated bool NOT NULL,\n" + " parent_invoice bool NOT NULL DEFAULT FALSE,\n" + " created_by varchar(50) NOT NULL,\n" + " created_date datetime NOT NULL,\n" + " account_record_id bigint /*! unsigned */ not null,\n" + " tenant_record_id bigint /*! unsigned */ not null default 0,\n" + " PRIMARY KEY(record_id)\n" + ");"); handle.execute("insert into invoices (id, account_id, invoice_date, target_date, currency, migrated, created_by, created_date, account_record_id) values " + "(?, ?, now(), now(), 'USD', false, 'test', now(), ?)", invoiceId.toString(), UUID.randomUUID().toString(), accountRecordId); return null; } });
private void addColumn(Table table, String schema, String tableName, String columnName, FieldType fieldType) { List<TableColumn> existingColumns = dao.listTableColumns(schema, tableName); TableColumn lastColumn = existingColumns.get(existingColumns.size() - 1); long columnId = lastColumn.getColumnId() + 1; int ordinalPosition = existingColumns.size(); String type = TypeSignature.parseTypeSignature(toSql(fieldType)).toString().toLowerCase(ENGLISH); daoTransaction(dbi, MetadataDao.class, dao -> { dao.insertColumn(table.getTableId(), columnId, columnName, ordinalPosition, type, null, null); dao.updateTableVersion(table.getTableId(), System.currentTimeMillis()); }); String columnType = sqlColumnType(fieldType); if (columnType == null) { return; } String sql = format("ALTER TABLE %s ADD COLUMN (%s %s, %s %s)", shardIndexTable(table.getTableId()), minColumn(columnId), columnType, maxColumn(columnId), columnType); try (Handle handle = dbi.open()) { handle.execute(sql); } catch (DBIException e) { throw metadataError(e); } }
@Before public void setUp() throws Exception { this.dbi = new DBI("jdbc:h2:mem:" + UUID.randomUUID()); this.h = dbi.open(); h.execute("create table something (id int primary key, name varchar)"); }
@Before public void setUp() throws Exception { dbi = new DBI("jdbc:h2:mem:" + UUID.randomUUID()); handle = dbi.open(); handle.execute("create table something( id integer primary key, name varchar(100) )"); }
@Before public void setUp() throws Exception { dbi = new DBI("jdbc:h2:mem:" + UUID.randomUUID()); handle = dbi.open(); handle.execute("create table something (id int primary key, name varchar(100))"); }
@Before public void setUp() throws Exception { dbi = new DBI("jdbc:h2:mem:" + UUID.randomUUID()); handle = dbi.open(); handle.execute("create table something (id int primary key, name varchar(100))"); }
@Before public void setUp() throws Exception { DBI dbi = new DBI("jdbc:h2:mem:" + UUID.randomUUID()); handle = dbi.open(); handle.execute("create table something (id int primary key, name varchar(100))"); }