当前位置: 首页>>代码示例>>Java>>正文


Java PostgresDialect类代码示例

本文整理汇总了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);
}
 
开发者ID:domaframework,项目名称:doma,代码行数:18,代码来源:BuiltinSequenceIdGeneratorTest.java

示例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);
}
 
开发者ID:domaframework,项目名称:doma,代码行数:16,代码来源:BuiltinIdentityIdGeneratorTest.java

示例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);
    }
}
 
开发者ID:domaframework,项目名称:doma,代码行数:31,代码来源:BuiltinIdentityIdGeneratorTest.java

示例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());
}
 
开发者ID:domaframework,项目名称:doma,代码行数:38,代码来源:BuiltinTableIdGeneratorTest.java

示例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());
}
 
开发者ID:domaframework,项目名称:doma,代码行数:9,代码来源:GreedyCacheSqlFileRepositoryTest.java

示例6: dialect

import org.seasar.doma.jdbc.dialect.PostgresDialect; //导入依赖的package包/类
@Bean
public Dialect dialect() {
    return new PostgresDialect();
}
 
开发者ID:matsumana,项目名称:spring-doma-junit4-dbunit-sample,代码行数:5,代码来源:AppConfig.java


注:本文中的org.seasar.doma.jdbc.dialect.PostgresDialect类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。