jooq

Generating multiple java Enums from a single table, using JOOQ

我怕爱的太早我们不能终老 提交于 2019-12-07 19:51:30
问题 I have a table in my database schema which contains configuration information for an application that I'm building. I'd like to generate a number of enums based on the contents of the table. I'm currently using JOOQ in my build scripts to generate other, standard JOOQ classes from the same database, and am hoping that I can obtain this new functionality through JOOQ. For example, if the table contained the following data Product Component PresentationOrder HydroProduct Boat 1 HydroProduct

JOOQ fails with PostgreSQL Custom Type as an Array: ERROR: malformed record literal

本小妞迷上赌 提交于 2019-12-07 19:07:50
问题 I have the following custom type on Postgres: CREATE TYPE my_custom_type AS ( field_a VARCHAR, field_b NUMERIC(10,3) ); and the following table: CREATE TABLE my_table ( COL1 VARCHAR(120) NOT NULL, CUSTOM_COLUMN my_custom_type, CUSTOM_COLUMN_ARRAY my_custom_type[] ); Everything works fine when I use my custom type with JOOQ: @Test public void testWithoutArray(){ MyTableRecord record = dsl.newRecord(MyTable.MY_TABLE); record.setCol1("My Col1"); MyCustomType customType = new MyCustomType();

Instantiating a jooq Field<> by name

两盒软妹~` 提交于 2019-12-07 01:30:55
问题 I'm trying to use jOOQ to build SQL queries in some generic code. I'm not interested in using jOOQ to execute those queries or to examine the results. Also, this code is generic so I cannot use jOOQ's code generation. I have managed to figure out this much: List<org.jooq.Field<?>> fields = new ArrayList<org.jooq.Field<?>>(); Field<?> field = Factory.field("somefield"); fields.add(field); field = Factory.field("someotherfield"); fields.add(field); Field<Object> fieldPK = Factory.field(

Heroku DATABASE_URL as a JDBC Url for Maven

China☆狼群 提交于 2019-12-06 11:04:51
问题 My apps on Heroku use a DATABASE_URL. This is simple to parse with Java into a JDBC URL with a user name and password. There's no issue there. However, I have a JOOQ generator and Flyway migrator that have maven plugins and I can't figure out how to get the JDBC URL, User Name, and Password that these plugins require into maven. So currently I do it on app startup which is not ideal. When my app starts I get the DATABASE_URL, parse it, then do the flyway migration and jOOQ code generation.

jOOQ - multi-field for insertion

旧街凉风 提交于 2019-12-06 07:20:07
I would like to express the following INSERT statement: context.insertInto(TABLE A) .set(<FIELD A, FIELD B>, context.select(FIELD A, FIELD B).from(B).where(...)) .set(... other field of table A ...) .set(... other field of table A ...) .set(... other field of table A ...) .returning() .fetch() The sub-select returns one row with two columns ( FIELD A and FIELD B ) which need to be inserted into the target TABLE A . The reason for this is that <FIELD A, FIELD B> is the primary key of TABLE B . TABLE A is refering to TABLE B (foreign key). Is this possible? I'm not sure if this is possible with

jooq-codegen-maven plugin for different db at the same time

只谈情不闲聊 提交于 2019-12-06 06:04:27
问题 I use jOOQ and MySQL DB in my application. For integration tests I use H2 database and there is a problem. Is there some way to run jooq-codegen-maven plugin twice? I found some maven example for this case. However, in two different cases, I must use two different dependencies. Can I somehow to include dependency in execution? 回答1: You can have multiple <execution> elements in any Maven plugin configuration, e.g. <plugin> <groupId>org.jooq</groupId> <artifactId>jooq-codegen-maven</artifactId>

jOOQ addConditions: in SQL question mark appears instead of the value

南楼画角 提交于 2019-12-06 03:45:48
问题 I would like to launch simple code: SelectQuery query = dsl.select(field ("id"), field("title")).from("dict.models").getQuery(); if (modelId > 0) query.addConditions(field("model_id", SQLDataType.INTEGER).equal(modelId)); But infortunately in getSQL() I can only see: select id, title from dict.models where model_id = ? Where is a mistake? Thanks. 回答1: Query.getSQL() generates the SQL statement as it would be generated if you let jOOQ execute a PreparedStatement - with bind variables. The bind

How to construct query in querydsl without domain classes

老子叫甜甜 提交于 2019-12-05 20:08:44
While looking for java libraries to build queries in a database agnostic way I came across many including iciql, querydsl, jooq, joist, hibernate etc. I wanted something that does not require configuration files and can work with dynamic schemas. For my application, I come to know about the database and the schema at runtime so I won't have any configuration files or domain classes for the schema. This seems to be one of the core goals of querydsl but going through the documentation for querydsl I see a lot of examples for building dynamic queries using domain classes but I have not come

Union query with multiple selects post java 8

早过忘川 提交于 2019-12-05 18:48:14
Here is a query that I want to try out in MySQL SELECT A.x FROM A WHERE A.y = 'P' UNION SELECT A.x FROM A WHERE A.y = 'Q' The above is a cut-down, much simpler version of the original query that I am trying. In my original query, each SELECT statement involves multiple tables with INNER JOIN If the possible number of values in 'y' column of table 'A' that I need to query upon is 'n', then my query will involve doing 'n-1' unions on 'n' SELECT statements I know that JOOQ can do union of multiple SELECT statements. But is there a good way to do this post Java 8 style? maybe using Steam.collect()

Java null pointer when executing a PL/SQL function using jOOQ

五迷三道 提交于 2019-12-05 05:19:30
问题 I'm currently attempting to call a PL/SQL Function which accepts multiple in/out arguments. This function contains the following data types: String. Array of Strings. However while the application is setting up the data to send it to the database server, the application is throwing a null pointer exception which is irrelevant to the actual error caused (Note that the actual error is given below as this has been figured out when debugging the application). The application is preparing the