本文整理匯總了Java中org.seasar.doma.jdbc.dialect.PostgresDialect類的典型用法代碼示例。如果您正苦於以下問題:Java PostgresDialect類的具體用法?Java PostgresDialect怎麽用?Java PostgresDialect使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
PostgresDialect類屬於org.seasar.doma.jdbc.dialect包,在下文中一共展示了PostgresDialect類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: test
import org.seasar.doma.jdbc.dialect.PostgresDialect; //導入依賴的package包/類
public void test() throws Exception {
MockConfig config = new MockConfig();
config.setDialect(new PostgresDialect());
MockResultSet resultSet = config.dataSource.connection.preparedStatement.resultSet;
resultSet.rows.add(new RowData(11L));
BuiltinSequenceIdGenerator idGenerator = new BuiltinSequenceIdGenerator();
idGenerator.setQualifiedSequenceName("aaa");
idGenerator.setInitialValue(1);
idGenerator.setAllocationSize(1);
IdGenerationConfig idGenerationConfig = new IdGenerationConfig(config,
_IdGeneratedEmp.getSingletonInternal());
Long value = idGenerator.generatePreInsert(idGenerationConfig);
assertEquals(new Long(11), value);
assertEquals("select nextval('aaa')",
config.dataSource.connection.preparedStatement.sql);
}
示例2: test_identitySelectSql
import org.seasar.doma.jdbc.dialect.PostgresDialect; //導入依賴的package包/類
public void test_identitySelectSql() throws Exception {
MockConfig config = new MockConfig();
config.setDialect(new PostgresDialect());
MockResultSet resultSet = config.dataSource.connection.preparedStatement.resultSet;
resultSet.rows.add(new RowData(11L));
BuiltinIdentityIdGenerator identityIdGenerator = new BuiltinIdentityIdGenerator();
IdGenerationConfig idGenerationConfig = new IdGenerationConfig(config,
_IdGeneratedEmp.getSingletonInternal());
Long value = identityIdGenerator.generatePostInsert(idGenerationConfig,
config.dataSource.connection.preparedStatement);
assertEquals(new Long(11), value);
assertEquals("select currval(pg_catalog.pg_get_serial_sequence('\"CATA\".\"EMP\"', 'id'))",
config.dataSource.connection.preparedStatement.sql);
}
示例3: test_identityReservationSql
import org.seasar.doma.jdbc.dialect.PostgresDialect; //導入依賴的package包/類
public void test_identityReservationSql() throws Exception {
MockConfig config = new MockConfig();
config.setDialect(new PostgresDialect());
MockResultSet resultSet = config.dataSource.connection.preparedStatement.resultSet;
resultSet.rows.add(new RowData(11L));
resultSet.rows.add(new RowData(12L));
resultSet.rows.add(new RowData(13L));
EntityType<IdGeneratedEmp> entityType = _IdGeneratedEmp
.getSingletonInternal();
BuiltinIdentityIdGenerator identityIdGenerator = new BuiltinIdentityIdGenerator();
IdGenerationConfig idGenerationConfig = new IdGenerationConfig(config,
entityType, new ReservedIdProvider(config, entityType, 3));
Long value = identityIdGenerator.generatePreInsert(idGenerationConfig);
assertEquals(new Long(11), value);
assertEquals(
"select nextval(pg_catalog.pg_get_serial_sequence('\"CATA\".\"EMP\"', 'id')) from generate_series(1, 3)",
config.dataSource.connection.preparedStatement.sql);
value = identityIdGenerator.generatePreInsert(idGenerationConfig);
assertEquals(new Long(12), value);
value = identityIdGenerator.generatePreInsert(idGenerationConfig);
assertEquals(new Long(13), value);
try {
identityIdGenerator.generatePreInsert(idGenerationConfig);
fail();
} catch (IllegalStateException ignored) {
System.out.println(ignored);
}
}
示例4: test
import org.seasar.doma.jdbc.dialect.PostgresDialect; //導入依賴的package包/類
public void test() throws Exception {
MockConfig config = new MockConfig();
config.setDialect(new PostgresDialect());
MockConnection connection = new MockConnection();
MockConnection connection2 = new MockConnection();
MockResultSet resultSet2 = connection2.preparedStatement.resultSet;
resultSet2.rows.add(new RowData(11L));
final LinkedList<MockConnection> connections = new LinkedList<MockConnection>();
connections.add(connection);
connections.add(connection2);
config.dataSource = new MockDataSource() {
@Override
public Connection getConnection() throws SQLException {
return connections.pop();
}
};
BuiltinTableIdGenerator idGenerator = new BuiltinTableIdGenerator();
idGenerator.setQualifiedTableName("aaa");
idGenerator.setPkColumnName("PK");
idGenerator.setPkColumnValue("EMP_ID");
idGenerator.setValueColumnName("VALUE");
idGenerator.setInitialValue(1);
idGenerator.setAllocationSize(1);
idGenerator.initialize();
IdGenerationConfig idGenerationConfig = new IdGenerationConfig(config,
_IdGeneratedEmp.getSingletonInternal());
Long value = idGenerator.generatePreInsert(idGenerationConfig);
assertEquals(new Long(10), value);
assertEquals("update aaa set VALUE = VALUE + ? where PK = ?",
connection.preparedStatement.sql);
assertEquals(2, connection.preparedStatement.bindValues.size());
assertEquals("select VALUE from aaa where PK = ?",
connection2.preparedStatement.sql);
assertEquals(1, connection2.preparedStatement.bindValues.size());
}
示例5: testGetSqlFile_postgres
import org.seasar.doma.jdbc.dialect.PostgresDialect; //導入依賴的package包/類
public void testGetSqlFile_postgres() throws Exception {
PostgresDialect dialect = new PostgresDialect();
String path = "META-INF/" + getClass().getName().replace(".", "/")
+ ".sql";
GreedyCacheSqlFileRepository repository = new GreedyCacheSqlFileRepository();
SqlFile sqlFile = repository.getSqlFile(method, path, dialect);
assertEquals(path, sqlFile.getPath());
}
示例6: dialect
import org.seasar.doma.jdbc.dialect.PostgresDialect; //導入依賴的package包/類
@Bean
public Dialect dialect() {
return new PostgresDialect();
}