當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。