jooq

How to use jOOQ RecordUnmapper?

ぐ巨炮叔叔 提交于 2019-12-11 14:55:20
问题 I'm trying to implement a jOOQ RecordUnmapper to adjust a record that I will later insert/update. My attempt below, problem is that the Record class cannot be instantiated. How to create the Record object? Also, how to use the unmapper in insert/update? public class TableUnmapper implements RecordUnmapper<Table, Record> { @Override public Record unmap(Table t) throws MappingException { Record r = new Record(); // <-- this line does not compile r.from(t); r.set(TABLES.TITLE_FONT_FAMILY, t

Keep type information of aliased fields in jOOQ

帅比萌擦擦* 提交于 2019-12-11 13:21:45
问题 I'm doing a join query with jOOQ, in which I have to alias the columns from both tables to keep the column-names unique. Is there a way to circumvent the information loss that occurs when I do aliasing to columns? Or a better way to achieve the goal of columns name clashes following jOOQ's style? When I do alias all the Fields, all type information is lost: List<Field<?>> columns = factory.select().from(t1j).limit(0).fetch().getFields(); List<Field<?>> aliases = new LinkedList<Field<?>>();

How to use Scala's String Interpolation in jOOQ?

霸气de小男生 提交于 2019-12-11 12:29:48
问题 I would like to use the string interpolation feature of jOOQ in Scala, for example resultQuery"SELECT * FROM objects" : // setup connection val con = DriverManager.getConnection(url, userName, password) // create DSLContext val dsl = DSL.using(con, SQLDialect.POSTGRES_9_4) // normal use of DSLContext dsl.resultQuery("SELECT * FROM objects") // intented use of string interpolation val q = resultQuery"SELECT * FROM objects" val result = q.fetch() println(result) Running this code (without any

PostgreSQL/JooQ bulk insertion performance issues when loading from CSV; how do I improve the process?

我的未来我决定 提交于 2019-12-11 12:02:52
问题 For this project, I intend to make a web version and am right now working on making a PostgreSQL (9.x) backend from which the webapp will query. Right now, what happens is that the tracer generates a zip file with two CSVs in it, load it into an H2 database at runtime whose schema is this (and yes, I'm aware that the SQL could be written a little better): create table matchers ( id integer not null, class_name varchar(255) not null, matcher_type varchar(30) not null, name varchar(1024) not

jOOQ: convert Field in select statement from type1 to type2

风格不统一 提交于 2019-12-11 11:57:47
问题 I have a statement like this: SelectSelectStep<Record14< String, String, String, Timestamp, String, String, String, Integer, Timestamp, String, String, String, Integer, DayToSecond>> select = create.select( TECHNICAL_WORK.NUMBER, TECHNICAL_CODE.CODE, TECHNICAL_CODE.DESCRIPTION, twLog.START_TIME, twStartLog.CODE, twStartLog.FIRST_NAME, twStartLog.LAST_NAME, twStartLog.CATEGORY, twLog.STOP_TIME, twEndLog.CODE, twEndLog.FIRST_NAME, twEndLog.LAST_NAME, twEndLog.CATEGORY, DSL.timestampDiff(twLog

JOOQ Cast String to Enum with Converter

早过忘川 提交于 2019-12-11 10:56:45
问题 While looking for a way to cast my String field into an Enum i stubled across the .cast() Method. When called it throws an SQLDialectNotSupportedException . Dialect has been Set to SQLSERVER2014 in the Context DSLContext create = DSL.using(conn, SQLDialect.SQLSERVER2014); . The corresponding line: create.select( ... lecture.DAY_OF_WEEK.cast(DayOfWeek.class), ... ); The full Error: org.jooq.exception.SQLDialectNotSupportedException: Type class java.time.DayOfWeek is not supported in dialect

Dynamic runtime PostgreSQL schema selection in jOOQ

天大地大妈咪最大 提交于 2019-12-11 09:56:54
问题 Alice and Bob want Dave to develop an application. They both want to work with identical data types, but they both want to keep their data separate and secure. So Dave goes off to build a DEV schema. CREATE TABLE foo (id INT PRIMARY KEY); CREATE FUNCTION bar(_id INT) RETURNS INT AS $$ INSERT INTO foo (id) VALUES (_id) RETURNING id; $$ LANGUAGE SQL; Dave uses Flyway to initialize schemas for Alice and Bob, so they both have the foo table and bar function. Dave uses jOOQ to generate a java api

jOOQ fetch vs fetchResultSet and close connection in Kotlin

霸气de小男生 提交于 2019-12-11 09:48:10
问题 I'm using Kotlin with HikariCP and jOOQ to query my database. I've come to realize that this code works as expected, fetching the rows and closing the connection afterwards: class CountriesService(private val datasource: DataSource) { private val countries = Countries() fun getCountries(): List<String> { DSL.using(datasource, SQLDialect.POSTGRES_10) .use { ctx -> ctx.select(countries.CO_NAME) .from(countries) .orderBy(countries.CO_NAME) .fetch() return emptyList() } } } whereas if I use

Performance degradation when reusing DSLContext in jooq

非 Y 不嫁゛ 提交于 2019-12-11 08:29:06
问题 Recently we encountered a performance degradation and in some cases even partial results, once we have transitioned from recreating the DSLContext on every call to creating it once and reusing it. Practically we transitioned from this - //Method call try (Connection c = dataSource.getConnection()) { DSLContext dsl = DSL.using(c); return dsl.select().from(view).where(condition).fetchSize(1000).fetchLazy(); } to this - //Ctor this.dsl = DSL.using(dataSource, SQLDialect.DEFAULT); //Method call

How to get a Row representation of a generated table?

╄→гoц情女王★ 提交于 2019-12-11 07:58:02
问题 I want to get Row[N]<...> representation of a generated JOOQ table type. I want to use it in this context: val p = PROJECTS.`as`("p") val pmu = PROJECTMEMBERUSERS.`as`("pmu") val query = db .select(p.asterisk(), DSL.arrayAgg(DSL.rowField(<-- insert Row[N]<...> here -->))) .from(p.join(pmu).on(p.ID.eq(pmu.PROJECTID))) .groupBy(p.ID) I already tried inserting pmu.fieldsRow() , but DSL.rowField(...) expects another parameter type. Error:(39, 58) Kotlin: None of the following functions can be