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


Java DSL类代码示例

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


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

示例1: createNTrueCondition

import org.jooq.impl.DSL; //导入依赖的package包/类
private static Condition createNTrueCondition(final int n) {
    if (n < 1)
        throw new IllegalArgumentException("Cannot have n < 1");
    Condition condition = null;
    for (int i = 0; i < n; i++) {
        if (condition == null)
            condition = DSL.trueCondition();
        else
            condition = condition.and(DSL.trueCondition());
    }
    return condition;
}
 
开发者ID:Blackdread,项目名称:filter-sort-jooq-api,代码行数:13,代码来源:FilteringJooqTest.java

示例2: saveTaxCodes

import org.jooq.impl.DSL; //导入依赖的package包/类
@Override
public void saveTaxCodes(final Iterable<EasyTaxTaxCode> taxCodes) throws SQLException {
    final DateTime now = new DateTime();
    execute(dataSource.getConnection(), new WithConnectionCallback<Void>() {
        @Override
        public Void withConnection(final Connection conn) throws SQLException {
            DSL.using(conn, dialect, settings).transaction(new TransactionalRunnable() {
                @Override
                public void run(final Configuration configuration) throws Exception {
                    final DSLContext dslContext = DSL.using(configuration);
                    for (EasyTaxTaxCode taxCode : taxCodes) {
                        DateTime date = taxCode.getCreatedDate() != null
                                ? taxCode.getCreatedDate()
                                : now;
                        saveTaxCodeInternal(taxCode, date, dslContext);
                    }
                }
            });
            return null;
        }
    });
}
 
开发者ID:SolarNetwork,项目名称:killbill-easytax-plugin,代码行数:23,代码来源:JooqEasyTaxDao.java

示例3: getLastId

import org.jooq.impl.DSL; //导入依赖的package包/类
/**
 * Returns the greatest news id.
 * Can be used to get the auto incremented value after a {@link News} was inserted.
 */
private long getLastId() {
	final Record1<Long> result = DSL.using(jooqConfig).
			select(TABLE_CONTENT.ID).
			from(TABLE_CONTENT).
			orderBy(TABLE_CONTENT.ID.desc()).
			limit(0, 1).
			fetchOne();

	return result == null ? 0 : result.getValue(TABLE_CONTENT.ID);
}
 
开发者ID:XMBomb,项目名称:InComb,代码行数:15,代码来源:NewsDao.java

示例4: setUp

import org.jooq.impl.DSL; //导入依赖的package包/类
public void setUp() throws Exception {
  connection = DriverManager.getConnection("jdbc:hsqldb:mem:myDb");
  context = DSL.using(connection, SQLDialect.HSQLDB, new Settings().withRenderNameStyle(
      RenderNameStyle.AS_IS));

  final List<Field<String>> fields = getFields();

  context.createTable(relationName)
      .columns(fields)
      .execute();

  try (InputStream in = resourceClass.getResourceAsStream(csvPath)) {
    final Loader<Record> loader = context.loadInto(table(name(relationName)))
        .loadCSV(in)
        .fields(fields)
        .execute();

    assertThat(loader.errors()).isEmpty();
  }
}
 
开发者ID:HPI-Information-Systems,项目名称:AdvancedDataProfilingSeminar,代码行数:21,代码来源:TestDatabase.java

示例5: init

import org.jooq.impl.DSL; //导入依赖的package包/类
private void init(Connection conn) {
    DSLContext create = DSL.using(conn, SQLDialect.POSTGRES);
    Result<Record> coresAttributes = create.select().from(MD_CLASS_ATTRIBUTES)
    .join(MD_CLASSES).on(MD_CLASS_ATTRIBUTES.CLASS_ID.eq(MD_CLASSES.CLASS_ID))
    .where(MD_CLASSES.CLASS_NAME.like("bom%Compute"))
    .and(MD_CLASS_ATTRIBUTES.ATTRIBUTE_NAME.eq("cores")).fetch();

    for (Record coresAttribute : coresAttributes) {
        coresAttributeIds.add(coresAttribute.getValue(MD_CLASS_ATTRIBUTES.ATTRIBUTE_ID));
    }

    create = DSL.using(conn, SQLDialect.POSTGRES);
    Result<Record> computeClasses = create.select().from(MD_CLASSES)
            .where(MD_CLASSES.CLASS_NAME.like("bom%Compute")).fetch();
    for (Record computeClass : computeClasses) {
        computeClassIds.add(computeClass.get(MD_CLASSES.CLASS_ID));
    }
    log.info("cached compute class ids: " + computeClassIds);
    log.info("cached compute cores attribute ids: " + coresAttributeIds);
}
 
开发者ID:oneops,项目名称:oneops,代码行数:21,代码来源:CMSCrawler.java

示例6: 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

示例7: addTaxation

import org.jooq.impl.DSL; //导入依赖的package包/类
@Override
public void addTaxation(final EasyTaxTaxation taxation) throws SQLException {
    final String invoiceItemIdTaxMappingJson = encodeInvoiceItemIdTaxMapping(
            taxation.getKbInvoiceId(), taxation.getInvoiceItemIds());
    execute(dataSource.getConnection(), new WithConnectionCallback<Void>() {
        @Override
        public Void withConnection(final Connection conn) throws SQLException {
            DSL.using(conn, dialect, settings)
                    .insertInto(EASYTAX_TAXATIONS, EASYTAX_TAXATIONS.KB_TENANT_ID,
                            EASYTAX_TAXATIONS.KB_ACCOUNT_ID, EASYTAX_TAXATIONS.KB_INVOICE_ID,
                            EASYTAX_TAXATIONS.KB_INVOICE_ITEM_IDS, EASYTAX_TAXATIONS.TOTAL_TAX,
                            EASYTAX_TAXATIONS.CREATED_DATE)
                    .values(taxation.getKbTenantId().toString(),
                            taxation.getKbAccountId().toString(),
                            taxation.getKbInvoiceId().toString(), invoiceItemIdTaxMappingJson,
                            taxation.getTotalTax(), taxation.getCreatedDate())
                    .execute();
            return null;
        }
    });
}
 
开发者ID:SolarNetwork,项目名称:killbill-easytax-plugin,代码行数:22,代码来源:JooqEasyTaxDao.java

示例8: getVoteAmount

import org.jooq.impl.DSL; //导入依赖的package包/类
/**
 * Returns the amount of ins or combs for the given condition.
 * in == true returns all "ins" / false all "combs"
 */
private int getVoteAmount(final Condition cond) {
	return DSL.using(jooqConfig).
			select(DSL.count()).
			from(VOTE_TABLE).
			where(cond).fetchOne(DSL.count());
}
 
开发者ID:XMBomb,项目名称:InComb,代码行数:11,代码来源:ContentVoteDao.java

示例9: getContentVotes

import org.jooq.impl.DSL; //导入依赖的package包/类
/**
 * Returns all content-votes for the given news article.
 */
private List<ContentVote> getContentVotes(final long contentId, final boolean up) {
	return DSL.using(jooqConfig).
			select().
			from(VOTE_TABLE).
			where(VOTE_TABLE.CONTENT_ID.eq(contentId)).
			and(VOTE_TABLE.UP.eq(up)).fetchInto(ContentVote.class);
}
 
开发者ID:XMBomb,项目名称:InComb,代码行数:11,代码来源:ContentVoteDao.java

示例10: getIdForUsername

import org.jooq.impl.DSL; //导入依赖的package包/类
/**
 * Returns the user id for the given username.
 * @param username the username to find the {@link User}.
 * @return the id of the {@link User}.
 */
private long getIdForUsername(final String username) {
	final Record1<Long> idRecord = DSL.using(jooqConfig).
			select(TABLE.ID).
			from(TABLE).
			where(TABLE.USERNAME.eq(username)).
			fetchOne();

	if(idRecord == null) {
		return 0;
	}

	return idRecord.getValue(TABLE.ID);
}
 
开发者ID:XMBomb,项目名称:InComb,代码行数:19,代码来源:UserDao.java

示例11: getNews

import org.jooq.impl.DSL; //导入依赖的package包/类
/**
 * Returns the {@link News} from the database.
 * The result isn't sorted. This method can be used for reindexing.
 * @param start start index of the results
 * @param amount the amount of {@link News}s to return after the start index.
 * @return {@link List} containing {@link News}
 */
public List<News> getNews(final int start, final int amount) {
	return DSL.using(jooqConfig).
			select().
			from(TABLE_CONTENT.join(TABLE_NEWS, JoinType.JOIN).
					on(TABLE_CONTENT.ID.eq(TABLE_NEWS.CONTENT_ID))).
			limit(start, amount).
			fetchInto(News.class);
}
 
开发者ID:XMBomb,项目名称:InComb,代码行数:16,代码来源:NewsDao.java

示例12: getDefaultsForNews

import org.jooq.impl.DSL; //导入依赖的package包/类
/**
	 * Checks if a {@link News} already exists for the given link. If one exists
	 * then the {@link Defaults} of this are returned. If not then <code>null</code>
	 * will be returned.
	 *
	 * @param news the {@link News} to find a {@link News} with the same link or name.
	 * @return {@link Defaults} or <code>null</code>
	 */
	private Defaults getDefaultsForNews(final News news) {
		final Defaults result = DSL.using(jooqConfig).
				select(TABLE_CONTENT.ID, TABLE_CONTENT.PUBLISH_DATE, TABLE_NEWS.NEWS_GROUP_ID,
						TABLE_CONTENT.TITLE, TABLE_CONTENT.TEXT, TABLE_NEWS.IMAGE_URL,
						TABLE_NEWS.IMAGE_WIDTH, TABLE_NEWS.IMAGE_HEIGHT, TABLE_NEWS.LINK).
				from(TABLE_CONTENT.join(TABLE_NEWS, JoinType.JOIN).
						on(TABLE_CONTENT.ID.eq(TABLE_NEWS.CONTENT_ID))).
				where(TABLE_NEWS.LINK.eq(news.getLink())).
					or(TABLE_CONTENT.TITLE.eq(news.getTitle()).
						and(TABLE_CONTENT.PROVIDER_ID.eq(news.getProviderId())).
						and(TABLE_CONTENT.PUBLISH_DATE.between(getDate(news, PUBLISHDATE_DELTA),
								getDate(news, -PUBLISHDATE_DELTA)))).
				fetchOneInto(Defaults.class);

		// no news found -> exit with null.
/*		if(result == null) {
			return null;
		}

		final Defaults defaults = new Defaults();
		defaults.setId(id); = result.getValue(TABLE_NEWS.CONTENT_ID);
		defaults.publishDate = result.getValue(TABLE_CONTENT.PUBLISH_DATE);
		defaults.newsGroupId = result.getValue(TABLE_NEWS.NEWS_GROUP_ID);
*/
		return result;
	}
 
开发者ID:XMBomb,项目名称:InComb,代码行数:35,代码来源:NewsDao.java

示例13: incompleteMapOfFilterMultipleKeys

import org.jooq.impl.DSL; //导入依赖的package包/类
static Stream<Arguments> incompleteMapOfFilterMultipleKeys() {
    return Stream.of(
        Arguments.of(
            ImmutableMap.of("key1", "value1", "key2", "12:25:30", "key3", "2017-05-17T12:25:30"),
            Arrays.asList(Filter.of("key1", "missingKey", v1 -> "val1", v2 -> "val2", (val1, val2) -> DSL.trueCondition()), Filter.of("key3", DSL::trueCondition)))
    );
}
 
开发者ID:Blackdread,项目名称:filter-sort-jooq-api,代码行数:8,代码来源:FilteringJooqTest.java

示例14: getWithFlyingsOf

import org.jooq.impl.DSL; //导入依赖的package包/类
/**
 * Returns all {@link User}s who are flying with the given {@link User}.
 */
public List<User> getWithFlyingsOf(final long userId) {
	return DSL.using(jooqConfig).
		select(USER_TABLE.fields()).
		from(USER_TABLE).
		join(FLY_WITH_TABLE).
			on(USER_TABLE.ID.eq(FLY_WITH_TABLE.USER_ID)).
		where(FLY_WITH_TABLE.FLY_WITH_ID.eq(userId)).
		fetchInto(User.class);
}
 
开发者ID:XMBomb,项目名称:InComb,代码行数:13,代码来源:FlyWithDao.java

示例15: getFlyWiths

import org.jooq.impl.DSL; //导入依赖的package包/类
/**
 * Returns all {@link User} which the given {@link User} is flying with.
 */
public List<User> getFlyWiths(final long userId) {
	return DSL.using(jooqConfig).
			select(USER_TABLE.fields()).
			from(USER_TABLE).
			join(FLY_WITH_TABLE).
				on(USER_TABLE.ID.eq(FLY_WITH_TABLE.FLY_WITH_ID)).
			where(FLY_WITH_TABLE.USER_ID.eq(userId)).
			fetchInto(User.class);
}
 
开发者ID:XMBomb,项目名称:InComb,代码行数:13,代码来源:FlyWithDao.java


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