本文整理汇总了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();
}