jooq

jOOQ does not generate sources

二次信任 提交于 2019-12-02 06:22:50
I am trying to include jOOQ into my code, however no code is being generated. When executing mvn clean generate-sources , no sources are generated. I want it to create a Category class, which is defined in the following schema.sql -file. CREATE TABLE IF NOT EXISTS category ( id INTEGER IDENTITY PRIMARY KEY, name VARCHAR(100), description VARCHAR(2000), age_group VARCHAR(20), created DATETIME, inserted BIGINT ); My pom.xml file looks like this: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM

JOOQ How to convert JSON based on other column value?

落花浮王杯 提交于 2019-12-02 05:24:59
Let's say I have a table customer(int id, type varchar, preferences jsonb) . The type can be REGULAR , PREMIUM etc. Based on the column type value the preferences JSON structure will be different. While loading a customer record from database if type=REGULAR I want to convert it into RegularCustomerPreferences object type, and if type=PREMIUM I want to convert it into PremiumCustomerPreferences object type. I have gone through several tutorials on using JOOQ JSON converters/Bindings..but they are one to one mapping and not conditional based (depending on another column value). What is the

Finding upcoming birthdays with jOOQ

雨燕双飞 提交于 2019-12-02 04:50:42
问题 I'm trying to convert an existing query which looks for upcoming birthdays to use jOOQ. My original query - using MySQL, and a bit simplified - is SELECT COUNT(*) FROM people WHERE DATE_ADD(people_dob, INTERVAL YEAR(CURDATE()) - YEAR(people_dob) YEAR) BETWEEN CURDATE() and DATE_ADD( CURDATE(), INTERVAL 7 DAY) I tried to express it using jOOQ but failed. I got as close as context .selectCount() .from(PEOPLE) .where( PEOPLE_DOB.add(year(currentTimestamp()).minus(year(PEOPLE_DOB))) .between

Jooq LocalDateTime fields use system timezone instead of session timezone

笑着哭i 提交于 2019-12-02 04:28:30
I'm using jooq (v3.11.9) to access a MySQL database that is running in UTC time. I've using generated entities and am using JSR-310 time types. The option I'm using in my config: <javaTimeTypes>true</javaTimeTypes> My understanding is that the MySQL datetime and timestamp types both map to LocalDateTime which makes sense as MySQL doesn't store timezone information with the times. However when I run queries on a machine in a different timezone (in my case EST) the dates are all in my local machine timezone even though the session timezone is UTC . I've confirmed that the session timezone is UTC

mysql select, insert and delete works from java program, but update not working

南楼画角 提交于 2019-12-02 04:24:21
I have a table with primary key id , select, insert and delete queries all work from java program, but update query not working, so as to 'insert on duplicate update'( only works when record doesn't exist, when record exists, the updating won't work). All queries committed, and my mariadb version is 10.1.14. Thanks in advance for any help! All queries works well in mysql-cli. table schema +------------------+----------------------+------+-----+---------------------+-----------------------------+ | Field | Type | Null | Key | Default | Extra | +------------------+----------------------+------+-

Get table/column metadata from JOOQ parser result

最后都变了- 提交于 2019-12-02 04:22:26
问题 Using the JOOQ parser API, I'm able to parse the following query and get the parameters map from the resulting Query object. From this, I can tell that there is one parameter, and it's name is "something". However, I haven't been able to figure out how to determine that the parameter "something" is assigned to a column named "BAZ" and that column is part of the table "BAR". Does the parser API have a way to get the table/column metadata associated to each parameter? String sql = "SELECT A.FOO

ORM frameworks used for insert only / query only apps

▼魔方 西西 提交于 2019-12-02 04:00:40
I've been using Hibernate for years and never have a problem with it, but just realized most of my work involved a CRUD approach, where I needed data to stay persisted and modified at will. The problem with this is that there is people who want to make 2 separate apps, one that bulk inserts and another that performs search on the inserted data. Since the persistence is a bit useless in this case, the team wants to not use Hibernate but to use raw queries on the insert app and maybe something like jOOQ on the query app. Is that the right call? or how could I convince them to use Hibernate,

Finding upcoming birthdays with jOOQ

流过昼夜 提交于 2019-12-02 01:32:12
I'm trying to convert an existing query which looks for upcoming birthdays to use jOOQ. My original query - using MySQL, and a bit simplified - is SELECT COUNT(*) FROM people WHERE DATE_ADD(people_dob, INTERVAL YEAR(CURDATE()) - YEAR(people_dob) YEAR) BETWEEN CURDATE() and DATE_ADD( CURDATE(), INTERVAL 7 DAY) I tried to express it using jOOQ but failed. I got as close as context .selectCount() .from(PEOPLE) .where( PEOPLE_DOB.add(year(currentTimestamp()).minus(year(PEOPLE_DOB))) .between(currentTimestamp()).and(currentTimestamp().add(7))); Unfortunately, that translates to select count(*) from

jOOQ returns offset date time as Z (UTC) even though it's not

时光毁灭记忆、已成空白 提交于 2019-12-02 00:55:59
I have a simple Postgres test table of id, timestamp with timezone. The test and output below should be self explanatory, but to summarize, I insert a row that has a timestamp with a -6 offset. It is properly inserted into the database, then loaded out of the database with the same hour, but the wrong offset, specifically Z instead of -6. I've tried setting my database to UTC, and when I manually select at the command line, it properly shows the time in UTC. Set database to mountain, it shows the expected time with an offset of -6. Forcing the database to various timezones via a statement

Get table/column metadata from JOOQ parser result

孤街醉人 提交于 2019-12-01 23:58:43
Using the JOOQ parser API, I'm able to parse the following query and get the parameters map from the resulting Query object. From this, I can tell that there is one parameter, and it's name is "something". However, I haven't been able to figure out how to determine that the parameter "something" is assigned to a column named "BAZ" and that column is part of the table "BAR". Does the parser API have a way to get the table/column metadata associated to each parameter? String sql = "SELECT A.FOO FROM BAR A WHERE A.BAZ = :something"; DSLContext context = DSL.using... Parser parser = context.parser