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


Java DSL.using方法代码示例

本文整理汇总了Java中org.jooq.impl.DSL.using方法的典型用法代码示例。如果您正苦于以下问题:Java DSL.using方法的具体用法?Java DSL.using怎么用?Java DSL.using使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jooq.impl.DSL的用法示例。


在下文中一共展示了DSL.using方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: migrate

import org.jooq.impl.DSL; //导入方法依赖的package包/类
@Override
public void migrate(Connection connection) throws Exception {
    try (Statement stmt = connection.createStatement()) {
        DSLContext create = DSL.using(connection);
        String ddl = create.createTable(table("groups"))
                .column(field("group_id", SQLDataType.BIGINT.identity(true)))
                .column(field("name", SQLDataType.VARCHAR(100).nullable(false)))
                .column(field("description", SQLDataType.VARCHAR(100).nullable(false)))
                .column(field("write_protected", SQLDataType.BOOLEAN.nullable(false)))
                .constraints(
                        constraint().primaryKey(field("group_id")),
                        constraint().unique(field("name"))
                ).getSQL();
        stmt.execute(ddl);
    }
}
 
开发者ID:kawasima,项目名称:bouncr,代码行数:17,代码来源:V2__CreateGroups.java

示例2: migrate

import org.jooq.impl.DSL; //导入方法依赖的package包/类
@Override
public void migrate(Connection connection) throws Exception {
    try (Statement stmt = connection.createStatement()) {
        DSLContext create = DSL.using(connection);
        String ddl = create.createTable(table("permissions"))
                .column(field("permission_id", SQLDataType.BIGINT.identity(true)))
                .column(field("name", SQLDataType.VARCHAR(100).nullable(false)))
                .column(field("description", SQLDataType.VARCHAR(100).nullable(false)))
                .column(field("write_protected", SQLDataType.BOOLEAN.nullable(false)))
                .constraints(
                        constraint().primaryKey(field("permission_id")),
                        constraint().unique(field("name"))
                ).getSQL();
        stmt.execute(ddl);
    }
}
 
开发者ID:kawasima,项目名称:bouncr,代码行数:17,代码来源:V5__CreatePermissions.java

示例3: migrate

import org.jooq.impl.DSL; //导入方法依赖的package包/类
@Override
public void migrate(Connection connection) throws Exception {
    try (Statement stmt = connection.createStatement()) {
        DSLContext create = DSL.using(connection);
        String ddl = create.createTable(table("assignments"))
                .column(field("group_id", SQLDataType.BIGINT.nullable(false)))
                .column(field("role_id", SQLDataType.BIGINT.nullable(false)))
                .column(field("realm_id", SQLDataType.BIGINT.nullable(false)))
                .constraints(
                        constraint().primaryKey(field("group_id"), field("role_id"), field("realm_id")),
                        constraint().foreignKey(field("group_id")).references(table("groups"), field("group_id")),
                        constraint().foreignKey(field("role_id")).references(table("roles"), field("role_id")),
                        constraint().foreignKey(field("realm_id")).references(table("realms"), field("realm_id"))
                ).getSQL();
        stmt.execute(ddl);
    }
}
 
开发者ID:kawasima,项目名称:bouncr,代码行数:18,代码来源:V9__CreateAssinments.java

示例4: migrate

import org.jooq.impl.DSL; //导入方法依赖的package包/类
@Override
public void migrate(Connection connection) throws Exception {
    try (Statement stmt = connection.createStatement()) {
        DSLContext create = DSL.using(connection);
        String ddl = create.createTable(table("realms"))
                .column(field("realm_id", SQLDataType.BIGINT.identity(true)))
                .column(field("name", SQLDataType.VARCHAR(100).nullable(false)))
                .column(field("url", SQLDataType.VARCHAR(100).nullable(false)))
                .column(field("application_id", SQLDataType.BIGINT.nullable(false)))
                .column(field("description", SQLDataType.VARCHAR(100).nullable(false)))
                .column(field("write_protected", SQLDataType.BOOLEAN.nullable(false)))
                .constraints(
                        constraint().primaryKey(field("realm_id")),
                        constraint().unique(field("name")),
                        constraint().foreignKey(field("application_id")).references(table("applications"), field("application_id"))
                ).getSQL();
        stmt.execute(ddl);
    }
}
 
开发者ID:kawasima,项目名称:bouncr,代码行数:20,代码来源:V6__CreateRealms.java

示例5: testFindUsersWithJOOQ

import org.jooq.impl.DSL; //导入方法依赖的package包/类
@Test
public void testFindUsersWithJOOQ() {

    //Query query =     em.createQuery("select u from User u where u.address.country = 'Norway'");
    //Query query = em.createNativeQuery("select * from User where country = 'Norway'");

    DSLContext create = DSL.using(SQLDialect.H2);
    String sql = create
            .select()
            .from(table("User"))
            .where(field("country").eq("Norway"))
            .getSQL(ParamType.INLINED);

    Query query = em.createNativeQuery(sql, User.class);

    List<User> results = query.getResultList();

    assertEquals(3, results.size());

    /*
       JOOQ is a popular, easy to use DSL for writing SQL (not JPQL).
       Besides type-safety and IDE code-completion, one HUGE benefit
       is that the SQL is targeted for the specific dialect of the
       target DB.
     */
}
 
开发者ID:arcuri82,项目名称:testing_security_development_enterprise_systems,代码行数:27,代码来源:UserTest.java

示例6: migrate

import org.jooq.impl.DSL; //导入方法依赖的package包/类
@Override
public void migrate(Connection connection) throws Exception {
    try(Statement stmt = connection.createStatement()) {
        DSLContext create = DSL.using(connection);
        String ddl = create.createTable(table("oidc_users"))
                .column(field("oidc_provider_id", SQLDataType.BIGINT.nullable(false)))
                .column(field("user_id", SQLDataType.BIGINT.nullable(false)))
                .column(field("oidc_sub", SQLDataType.VARCHAR(255).nullable(false)))
                .constraints(
                        constraint().primaryKey(field("oidc_provider_id"), field("user_id")),
                        constraint().foreignKey(field("oidc_provider_id")).references(table("oidc_providers"), field("oidc_provider_id")),
                        constraint().foreignKey(field("user_id")).references(table("users"), field("user_id"))
                ).getSQL();
        stmt.execute(ddl);
    }
}
 
开发者ID:kawasima,项目名称:bouncr,代码行数:17,代码来源:V15__CreateOidcUsers.java

示例7: getDeployments

import org.jooq.impl.DSL; //导入方法依赖的package包/类
private List<Deployment> getDeployments(Connection conn, Environment env) {

        List<Deployment> deployments = new ArrayList<>();
        DSLContext create = DSL.using(conn, SQLDialect.POSTGRES);
        Result<Record> records = create.select().from(DJ_DEPLOYMENT)
                .join(DJ_DEPLOYMENT_STATES).on(DJ_DEPLOYMENT_STATES.STATE_ID.eq(DJ_DEPLOYMENT.STATE_ID))
                .join(NS_NAMESPACES).on(NS_NAMESPACES.NS_ID.eq(DJ_DEPLOYMENT.NS_ID))
                .where(NS_NAMESPACES.NS_PATH.eq(env.getPath()+ "/" + env.getName() + "/bom"))
                .and(DJ_DEPLOYMENT.CREATED_BY.notEqual("oneops-autoreplace"))
                .orderBy(DJ_DEPLOYMENT.CREATED.desc())
                .limit(1)
                .fetch();
        for (Record r : records) {
            Deployment deployment = new Deployment();
            deployment.setCreatedAt(r.getValue(DJ_DEPLOYMENT.CREATED));
            deployment.setCreatedBy(r.getValue(DJ_DEPLOYMENT.CREATED_BY));
            deployment.setState(r.getValue(DJ_DEPLOYMENT_STATES.STATE_NAME));
            deployments.add(deployment);
        }
        return deployments;
    }
 
开发者ID:oneops,项目名称:oneops,代码行数:22,代码来源:CMSCrawler.java

示例8: getOneopsEnvironments

import org.jooq.impl.DSL; //导入方法依赖的package包/类
private List<Environment> getOneopsEnvironments(Connection conn) {
    List<Environment> envs = new ArrayList<>();
    DSLContext create = DSL.using(conn, SQLDialect.POSTGRES);
    log.info("Fetching all environments..");
    Result<Record> envRecords = create.select().from(CM_CI)
            .join(MD_CLASSES).on(CM_CI.CLASS_ID.eq(MD_CLASSES.CLASS_ID))
            .join(NS_NAMESPACES).on(CM_CI.NS_ID.eq(NS_NAMESPACES.NS_ID))
            .where(MD_CLASSES.CLASS_NAME.eq("manifest.Environment"))
            .fetch(); //all the env cis
    log.info("Got all environments");
    for (Record r : envRecords) {
        long envId = r.getValue(CM_CI.CI_ID);
        //now query attributes for this env
        Environment env = new Environment();
        env.setName(r.getValue(CM_CI.CI_NAME));
        env.setId(r.getValue(CM_CI.CI_ID));
        env.setPath(r.getValue(NS_NAMESPACES.NS_PATH));
        env.setNsId(r.getValue(NS_NAMESPACES.NS_ID));
        envs.add(env);
    }
    return envs;
}
 
开发者ID:oneops,项目名称:oneops,代码行数:23,代码来源:CMSCrawler.java

示例9: migrate

import org.jooq.impl.DSL; //导入方法依赖的package包/类
@Override
public void migrate(Connection connection) throws Exception {
    try(Statement stmt = connection.createStatement()) {
        DSLContext create = DSL.using(connection);
        String ddl = create.createTable(table("oidc_providers"))
                .column(field("oidc_provider_id", SQLDataType.BIGINT.identity(true)))
                .column(field("name", SQLDataType.VARCHAR(100).nullable(false)))
                .column(field("api_key", SQLDataType.VARCHAR(100).nullable(false)))
                .column(field("api_secret", SQLDataType.VARCHAR(100).nullable(false)))
                .column(field("scope", SQLDataType.VARCHAR(100)))
                .column(field("response_type", SQLDataType.VARCHAR(100)))
                .column(field("authorization_endpoint", SQLDataType.VARCHAR(100).nullable(false)))
                .column(field("token_endpoint", SQLDataType.VARCHAR(100).nullable(false)))
                .column(field("token_endpoint_auth_method", SQLDataType.VARCHAR(10).nullable(false)))
                .constraints(
                        constraint().primaryKey(field("oidc_provider_id"))
                ).getSQL();
        stmt.execute(ddl);
    }
}
 
开发者ID:kawasima,项目名称:bouncr,代码行数:21,代码来源:V13__CreateOidcProviders.java

示例10: dbContext

import org.jooq.impl.DSL; //导入方法依赖的package包/类
@Provides
@Singleton
static DSLContext dbContext(
    DataSource dataSource, @ForDatabase ListeningExecutorService dbExecutor) {
  Configuration configuration =
      new DefaultConfiguration()
          .set(dbExecutor)
          .set(SQLDialect.MYSQL)
          .set(new Settings().withRenderSchema(false))
          .set(new DataSourceConnectionProvider(dataSource))
          .set(DatabaseUtil.sfmRecordMapperProvider());
  DSLContext ctx = DSL.using(configuration);
  // Eagerly trigger JOOQ classinit for better startup performance.
  ctx.select().from("curio_server_framework_init").getSQL();
  return ctx;
}
 
开发者ID:curioswitch,项目名称:curiostack,代码行数:17,代码来源:DatabaseModule.java

示例11: migrate

import org.jooq.impl.DSL; //导入方法依赖的package包/类
@Override
public void migrate(Connection connection) throws Exception {
    try(Statement stmt = connection.createStatement()) {
        DSLContext create = DSL.using(connection);
        String ddl = create.createTable(table("invitations"))
                .column(field("invitation_id", SQLDataType.BIGINT.identity(true)))
                .column(field("email", SQLDataType.VARCHAR(100)))
                .column(field("code", SQLDataType.VARCHAR(8)))
                .column(field("invited_at", SQLDataType.TIMESTAMP.nullable(false)))
                .constraints(
                        constraint().primaryKey(field("invitation_id")),
                        constraint().unique(field("code"))
                ).getSQL();
        stmt.execute(ddl);

        ddl = create.createTable(table("group_invitations"))
                .column(field("group_invitation_id", SQLDataType.BIGINT.identity(true)))
                .column(field("invitation_id", SQLDataType.BIGINT.nullable(false)))
                .column(field("group_id", SQLDataType.BIGINT.nullable(false)))
                .constraints(
                        constraint().primaryKey(field("group_invitation_id")),
                        constraint().foreignKey(field("invitation_id")).references(table("invitations"), field("invitation_id")),
                        constraint().foreignKey(field("group_id")).references(table("groups"), field("group_id"))
                ).getSQL();
        stmt.execute(ddl);

        ddl = create.createTable(table("oidc_invitations"))
                .column(field("oidc_invitation_id", SQLDataType.BIGINT.identity(true)))
                .column(field("invitation_id", SQLDataType.BIGINT.nullable(false)))
                .column(field("oidc_provider_id", SQLDataType.BIGINT.nullable(false)))
                .column(field("oidc_sub", SQLDataType.VARCHAR(255).nullable(false)))
                .constraints(
                        constraint().primaryKey(field("oidc_invitation_id")),
                        constraint().foreignKey(field("invitation_id")).references(table("invitations"), field("invitation_id")),
                        constraint().foreignKey(field("oidc_provider_id")).references(table("oidc_providers"), field("oidc_provider_id"))
                ).getSQL();
        stmt.execute(ddl);

    }
}
 
开发者ID:kawasima,项目名称:bouncr,代码行数:41,代码来源:V17__CreateInvitations.java

示例12: migrate

import org.jooq.impl.DSL; //导入方法依赖的package包/类
@Override
public void migrate(Connection connection) throws Exception {
    try (Statement stmt = connection.createStatement()) {
        DSLContext create = DSL.using(connection);
        String ddl = create.createTable(table("users"))
                .column(field("user_id", SQLDataType.BIGINT.identity(true)))
                .column(field("account", SQLDataType.VARCHAR(100).nullable(false)))
                .column(field("name", SQLDataType.VARCHAR(100).nullable(false)))
                .column(field("email", SQLDataType.VARCHAR(100).nullable(false)))
                .column(field("write_protected", SQLDataType.BOOLEAN.nullable(false)))
                .constraints(
                        constraint().primaryKey(field("user_id")),
                        constraint().unique(field("account")),
                        constraint().unique(field("email"))
                ).getSQL();
        stmt.execute(ddl);

        stmt.execute(
                create.createIndex(name("idx_users_01"))
                        .on(table("users"), field("account"))
                        .getSQL()
        );
        stmt.execute(
                create.createIndex(name("idx_users_02"))
                        .on(table("users"), field("email"))
                        .getSQL()
        );
    }
}
 
开发者ID:kawasima,项目名称:bouncr,代码行数:30,代码来源:V1__CreateUsers.java

示例13: populateEnv

import org.jooq.impl.DSL; //导入方法依赖的package包/类
private void populateEnv(Environment env, Connection conn) {
    DSLContext create = DSL.using(conn, SQLDialect.POSTGRES);
    Result<Record> envAttributes = create.select().from(CM_CI_ATTRIBUTES)
            .join(MD_CLASS_ATTRIBUTES).on(CM_CI_ATTRIBUTES.ATTRIBUTE_ID.eq(MD_CLASS_ATTRIBUTES.ATTRIBUTE_ID))
            .where(CM_CI_ATTRIBUTES.CI_ID.eq(env.getId()))
            .fetch();
    for (Record attrib : envAttributes) {
        String attributeName = attrib.getValue(MD_CLASS_ATTRIBUTES.ATTRIBUTE_NAME);
        if (attributeName.equalsIgnoreCase("profile")) {
            env.setProfile(attrib.getValue(CM_CI_ATTRIBUTES.DF_ATTRIBUTE_VALUE));
        }
        //add other attributes as and when needed
    }
    //now query all the platforms for this env
    Result<Record> platformRels = create.select().from(CM_CI_RELATIONS)
            .join(MD_RELATIONS).on(MD_RELATIONS.RELATION_ID.eq(CM_CI_RELATIONS.RELATION_ID))
            .join(CM_CI).on(CM_CI.CI_ID.eq(CM_CI_RELATIONS.TO_CI_ID))
            .where(MD_RELATIONS.RELATION_NAME.eq("manifest.ComposedOf"))
            .and(CM_CI_RELATIONS.FROM_CI_ID.eq(env.getId()))
            .fetch();
    for (Record platformRel : platformRels) {
        long platformId = platformRel.getValue(CM_CI_RELATIONS.TO_CI_ID);
        Platform platform = new Platform();
        platform.setId(platformId);
        platform.setName(platformRel.getValue(CM_CI.CI_NAME));
        platform.setPath(env.getPath() + "/" + env.getName() + "/bom/" + platform.getName() + "/1");
        populatePlatform(conn, platform);
        platform.setActiveClouds(getActiveClouds(platform, conn));

        //now calculate total cores of the env - including all platforms
        env.setTotalCores(env.getTotalCores() + platform.getTotalCores());
        env.addPlatform(platform);
    }
}
 
开发者ID:oneops,项目名称:oneops,代码行数:35,代码来源:CMSCrawler.java

示例14: populatePlatform

import org.jooq.impl.DSL; //导入方法依赖的package包/类
private void populatePlatform(Connection conn, Platform platform) {
    DSLContext create = DSL.using(conn, SQLDialect.POSTGRES);
    Result<Record> computes = create.select().from(CM_CI)
            .join(NS_NAMESPACES).on(NS_NAMESPACES.NS_ID.eq(CM_CI.NS_ID))
            .join(CM_CI_ATTRIBUTES).on(CM_CI_ATTRIBUTES.CI_ID.eq(CM_CI.CI_ID))
            .where(NS_NAMESPACES.NS_PATH.eq(platform.getPath())
            .and(CM_CI.CLASS_ID.in(computeClassIds))
            .and(CM_CI_ATTRIBUTES.ATTRIBUTE_ID.in(coresAttributeIds)))
            .fetch();

    platform.setTotalComputes(computes.size());
    int totalCores = 0;
    if (platform.getTotalComputes() > 0) {
        for (Record compute : computes) {
            totalCores += Integer.parseInt(compute.get(CM_CI_ATTRIBUTES.DF_ATTRIBUTE_VALUE));
        }
    }
    platform.setTotalCores(totalCores);

    //Now query platform ci attributes and set to the object
    Result<Record> platformAttributes = create.select().from(CM_CI_ATTRIBUTES)
            .join(MD_CLASS_ATTRIBUTES).on(MD_CLASS_ATTRIBUTES.ATTRIBUTE_ID.eq(CM_CI_ATTRIBUTES.ATTRIBUTE_ID))
            .where(CM_CI_ATTRIBUTES.CI_ID.eq(platform.getId()))
            .fetch();

    for ( Record attribute : platformAttributes ) {
        String attributeName = attribute.getValue(MD_CLASS_ATTRIBUTES.ATTRIBUTE_NAME);
        if (attributeName.equalsIgnoreCase("source")) {
            platform.setSource(attribute.getValue(CM_CI_ATTRIBUTES.DF_ATTRIBUTE_VALUE));
        } else if (attributeName.equalsIgnoreCase("pack")) {
            platform.setPack(attribute.getValue(CM_CI_ATTRIBUTES.DF_ATTRIBUTE_VALUE));
        }
    }
}
 
开发者ID:oneops,项目名称:oneops,代码行数:35,代码来源:CMSCrawler.java

示例15: updateCrawlEntry

import org.jooq.impl.DSL; //导入方法依赖的package包/类
private void updateCrawlEntry(Environment env) {
    if (crawlerDbUserName == null || crawlerDbUrl == null || crawlerDbPassword == null) {
        return;
    }
    try (Connection conn = DriverManager.getConnection(crawlerDbUrl, crawlerDbUserName, crawlerDbPassword)) {
        DSLContext create = DSL.using(conn, SQLDialect.POSTGRES);

        Result<Record> records = create.select().from(CRAWL_ENTITIES)
                .where(CRAWL_ENTITIES.OO_ID.eq(env.getId()))
                .fetch();

        if (records.isNotEmpty()) {
            create.update(CRAWL_ENTITIES)
                    .set(CRAWL_ENTITIES.LAST_CRAWLED_AT, new Timestamp(System.currentTimeMillis()))
                    .where(CRAWL_ENTITIES.OO_ID.eq(env.getId()))
                    .execute();
        } else {
            create.insertInto(CRAWL_ENTITIES)
                    .set(CRAWL_ENTITIES.NS_PATH, env.getPath() + "/" + env.getName())
                    .set(CRAWL_ENTITIES.OO_ID, env.getId())
                    .execute();
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:oneops,项目名称:oneops,代码行数:28,代码来源:CMSCrawler.java


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