jooq

postgres 'WITH' clause with jooq

旧时模样 提交于 2020-07-08 19:49:03
问题 Hell, I can't find a way to use the postgres 'WITH' clause with JOOQ. Could you please let me know if it's supported by JOOQ? Thanks 回答1: Common table expressions (the " WITH clause") are currently not supported in jOOQ. There is a pending feature request on the jOOQ road map for CTE's: #454. As of jOOQ 3.0, there are currently no plans of actually supporting it, though. (Your best option to push things a little bit is to discuss this topic on the jOOQ user group) 来源: https://stackoverflow

JOOQ query to JOIN ON WITH clause

风流意气都作罢 提交于 2020-07-07 01:31:29
问题 How can I write a JOOQ query to join on a field from a "with" clause? For example, I've tried: create.with("a").as(select( val(1).as("x"), val("a").as("y") )) .select() .from(tableByName("a") .join(ANOTHER_TABLE) .on(ANOTHER_TABLE.ID.eq(tableByName("a").field("x"))) .fetch(); However, as the compiler doesn't know the type of tableByName("a").field("x") it cannot resolve which eq() method to use. Given that I know the type, is there a way I can provide it explicitly? Or is there another

JOOQ query to JOIN ON WITH clause

痞子三分冷 提交于 2020-07-07 01:29:06
问题 How can I write a JOOQ query to join on a field from a "with" clause? For example, I've tried: create.with("a").as(select( val(1).as("x"), val("a").as("y") )) .select() .from(tableByName("a") .join(ANOTHER_TABLE) .on(ANOTHER_TABLE.ID.eq(tableByName("a").field("x"))) .fetch(); However, as the compiler doesn't know the type of tableByName("a").field("x") it cannot resolve which eq() method to use. Given that I know the type, is there a way I can provide it explicitly? Or is there another

How to apply a <forcedType> to a stored function in jOOQ?

风格不统一 提交于 2020-06-28 05:40:50
问题 A common question among jOOQ users is how a <forcedType> can be applied to a stored function return type in the code generator. The manual specifies that <includeExpression> matches qualified or unqualified identifiers, so given this HSQLDB function: CREATE FUNCTION stored_functions.f_1 (p_i int) RETURNS int BEGIN ATOMIC RETURN p_i; END The parameter of the function can be forced to String using: <forcedType> <userType>java.lang.String</userType> <converter> org.jooq.Converter.ofNullable

UPDATE-FROM clause in jOOQ throws an expecption for CTE field

我只是一个虾纸丫 提交于 2020-06-27 16:39:28
问题 I am trying to convert following PostgreSQL query into jOOQ: UPDATE book SET amount = bat.amount FROM ( VALUES (2, 136),(5, 75) ) AS bat(book_id, amount) WHERE book.book_id = bat.book_id; VALUES inside of FROM-clause are being created from Map<Long, Integer> bookIdsAmountMap parameter and I am trying to perform that this way: class BookUtilHelper { @SuppressWarnings("unchecked") static Table<Record2<Long, Integer>> batTmp(DSLContext dsl, Map<Long, Integer> bookIdAmountMapUpdated) { Row2<Long

UPDATE-FROM clause in jOOQ throws an expecption for comparing data types

蓝咒 提交于 2020-06-17 02:14:46
问题 I have a problem when accessing values in UPDATE-FROM clause in jOOQ. I want to convert following PostgreSQL query: UPDATE book SET amount = bat.amount FROM ( VALUES (2, 136),(5, 75) ) AS bat(book_id, amount) WHERE book.book_id = bat.book_id; VALUES inside of FROM-clause are being created from Map bookIdsAmountMap parameter and I am trying to perform that this way: This is what I have done in my code so far (by Lukas Eder answer suggestion) made in this question: Row2<Long,Integer> array[] =

Use Mapstruct as RecordMapper for JOOQ

≯℡__Kan透↙ 提交于 2020-05-29 07:36:22
问题 I would like to implement my own RecordMapper and use Mapstruct to map the Record to the POJO. I don't quite understand how to accomplish this. I followed this part of the docs: https://www.jooq.org/doc/3.13/manual/sql-execution/fetching/pojos-with-recordmapper-provider/ My mapper looks like this: public class LanguageMapper<R extends Record, E> implements RecordMapper<R, Language> { @Override public Language map(R record) { LanguageRecord languageRecord = (LanguageRecord) record; // this is

How to select unix timestamp as date in Jooq?

江枫思渺然 提交于 2020-05-27 09:26:07
问题 I am working in with a database in which dates are stored as unix time (seconds since 1970). I have the following sql which works as expected: select CONVERT_TZ(FROM_UNIXTIME(creation_date), @@session.time_zone, "Europe/Berlin") from transaction; This is how I tried to do it in Jooq: dsl.select(DSL.date(TRANSACTION.CREATION_DATE) // This does not work .from(TRANSACTION) .fetch(); 回答1: You're using quite a few vendor specific functions there, which are not supported out of the box in jOOQ. As

Datatypes incompatible when using sql custom routine with jooq

廉价感情. 提交于 2020-04-18 06:12:20
问题 While implementing an upsert that uses a custom-defined SQL function, I came across the following error: [ERROR] /home/user/company/ahqjava/sql/src/main/java/com/company/project/sql/daos/ExampleDAO.java:[60,56] no suitable method found for mergeData(org.jooq.TableField<com.company.project.sql.jooq.tables.records.ExampleRecord,java.util.Map<java.lang.String,java.lang.String>>,java.util.Map<java.lang.String,java.lang.String>)[ERROR] method com.company.project.sql.jooq.Routines.mergeData(java

POJO Mapping in JOOQ regardless of parameter order

心不动则不痛 提交于 2020-04-13 10:45:09
问题 When I generate the JOOQ POJOs, the constructor follows the same order for the parameters as the fields in the database table. When querying the table and using fetchInto this works fine, as long as the order of the POJO constructor parameters and the order of the fields in the database table are the same. return create .select() .from(KEY) .fetchInto(Key.class); How can I map the query above into Key.class regardless of the constructor parameter order? E.g. can I use something like mapstruct