jooq

jOOQ can I fetch a join of two tables into the respective POJOs

孤街浪徒 提交于 2019-11-28 23:38:25
In jOOQ if I want to fetch a row of a table into a jOOQ autogenerated POJOs I do, for instance: dsl.selectFrom(USER) .where(USER.U_EMAIL.equal(email)) .fetchOptionalInto(User.class); Now, suppose that I want to do a join between two tables, e.g. USER and ROLE , how can I fetch the result into the POJOs for these two tables? This is one solution using ResultQuery.fetchGroups(RecordMapper, RecordMapper) Map<UserPojo, List<RolePojo>> result = dsl.select(USER.fields()) .select(ROLE.fields()) .from(USER) .join(USER_TO_ROLE).on(USER.USER_ID.eq(USER_TO_ROLE.USER_ID)) .join(ROLE).on(ROLE.ROLE_ID.eq

Comparing Querydsl, jOOQ, JEQUEL, activejdbc, iciql and other query DSLs

核能气质少年 提交于 2019-11-28 15:25:34
问题 Can someone point me to some resources about the performance comparison among the different Query DSL libraries available for using with Java, like: Querydsl , jOOQ , JEQUEL , activejdbc , iciql and etc... Background: I m using Spring JDBC template, but that still required the queries to be written in plain string format. Although I don't have issues in writing the direct queries, but I m concerned having direct dependency on DB table names. I don't want to use any ORM framework like

How to use toChar function in JOOQ?

老子叫甜甜 提交于 2019-11-28 13:44:27
I have to use toChar() function in JOOQ ? Right now i have used below code TO_CHAR(PaymentDate, 'YYYY-MM-DD') <= TO_CHAR(SYSDATE,'YYYY-MM-DD')"); Which i have to convert into JOOQ . How to use this in JOOQ ? Oracle's TO_CHAR() function is not explicitly supported by jOOQ 3.2. I have added a feature request for this: #2832 . In the mean time, you will have to resort to plain SQL as documented in the manual . For instance, you could write: // Create reusable fields: Field<String> f = DSL.field( "TO_CHAR({0}, 'YYYY-MM-DD')", String.class, T.PaymentDate); // Create reusable conditions: Condition c

jOOQ - support for UPDATE … SET … query with arbitrary degree

隐身守侯 提交于 2019-11-28 11:16:11
问题 I have two functions: one returns a list of fields, the other returns a select query (which selects the corresponding values of the fields). private List<Field<?>> fields() { .... } private Select<?> select() { ... } Note that the degree is determined at runtime, it depends on the user input. Hence List<Field<?>> and Select<?> . It is possible to insert into a table: context.insertInto(table, fields()).select(select())) It is not possible to update a table: context.update(table).set(DSL.row

JOOQ Vs Hibernate behavior

房东的猫 提交于 2019-11-28 10:51:22
问题 As we know Hibernate have a a very good feature SaveOrUpdate when we pass any object to this method it know data would be update or new record will be added in database. Is this feature also available in JOOQ Or in my code i have to handle this? 回答1: jOOQ does the same. If you change the primary key of a record, then it will use INSERT , otherwise, it will use UPDATE . As it is, when you read a record from the database, then calling store() will trigger an UPDATE as you'd expect. If you

Are arrays optimized in jOOQ & PostgreSQL?

♀尐吖头ヾ 提交于 2019-11-28 06:23:19
问题 I have a large list of identifiers which I would like to add to the WHERE clause like this: identifier IN (..., ..., ..., ...) However, that is pretty slow, because it has to bind each value individually. Remember, the list is pretty long (almost 1000 values). In such case, it is better to use: identifier = ANY({..., ..., ..., ...}) Now, we are only binding the array, just once. I tried doing that in jOOQ: Integer[] values = {..., ..., ..., ...} DSL.any(DSL.array(values)) The following SQL is

How to insert a updatable record with JSON column in PostgreSQL using JOOQ?

给你一囗甜甜゛ 提交于 2019-11-28 03:15:39
问题 I followed the answer in Is it possible to write a data type Converter to handle postgres JSON columns? to implement the nodeObject converter. Then I tried to use an updatable record to insert a record, I got "org.jooq.exception.SQLDialectNotSupportedException: Type class org.postgresql.util.PGobject is not supported in dialect POSTGRES" exception." How can I solve this? Following is my code: TableRecord r = create.newRecord(TABLE); ObjectNode node = JsonNodeFactory.instance.objectNode(); r

jOOQ can I fetch a join of two tables into the respective POJOs

大城市里の小女人 提交于 2019-11-27 13:55:12
问题 In jOOQ if I want to fetch a row of a table into a jOOQ autogenerated POJOs I do, for instance: dsl.selectFrom(USER) .where(USER.U_EMAIL.equal(email)) .fetchOptionalInto(User.class); Now, suppose that I want to do a join between two tables, e.g. USER and ROLE , how can I fetch the result into the POJOs for these two tables? 回答1: This is one solution using ResultQuery.fetchGroups(RecordMapper, RecordMapper) Map<UserPojo, List<RolePojo>> result = dsl.select(USER.fields()) .select(ROLE.fields())

java.util.stream with ResultSet

二次信任 提交于 2019-11-26 04:39:09
问题 I have few tables with big amount of data (about 100 million records). So I can\'t store this data in memory but I would like to stream this result set using java.util.stream class and pass this stream to another class. I read about Stream.of and Stream.Builder operators but they are buffered streams in memory. So is there any way to resolve this question? Thanks in advance. UPDATE #1 Okay I googled and found jooq library. I\'m not sure but looks like it could be applicable to my test case.