jooq

Issue with JOOQ json binding

那年仲夏 提交于 2019-12-24 08:59:12
问题 I have an issue with converting postgresql jsonb I created Binding as was explained in tutorial : jooq tutorial Also please note I am not using codegen In my repo I have the following code Binding binding = new PostgresJSONGsonBinding(); Field<JsonElement> gsonObj = DSL.field("gsonObj",SQLDataType.OTHER.asConvertedDataType(binding)); And getting an error in to and from methods com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Unterminated array at line 1

Build nested condition with SelectQuery object

非 Y 不嫁゛ 提交于 2019-12-24 04:48:08
问题 Can I build nested conditions using the SelectQuery object? I want to get: select * from car where ((car.color = 'blue' or car.model = 'Genesis') or (car.manufactor = 'ford' and car.color = 'blue')) 回答1: If you inline all conditions / predicates... ... then you can supply them just like that to your SelectQuery object: SelectQuery query = ... query.addConditions( ( CAR.COLOR.eq("blue") .or ( CAR.MODEL.eq("Genesis") ) ) .or ( CAR.MANUFACTOR.eq("ford") .and ( CAR.COLOR.eq("blue") ) ) ) I've

How do SQL dialects actually work internally in frameworks like hibernate and JOOQ

自闭症网瘾萝莉.ら 提交于 2019-12-24 04:24:08
问题 As we have seen that after you get a data source. We need to configure SQL dialects based on the database we use. After we select a particular dialect, How would that be used to make SQL queries specific to DB. Do frameworks like hibernate and JOOQ construct SQL queries in string based on the selected dialect ? If so which would be the most optimal way to support this in a framework of our own ? 回答1: Do frameworks like hibernate and JOOQ construct SQL queries in string based on the selected

Updating rows in jOOQ with joins

折月煮酒 提交于 2019-12-24 03:25:25
问题 I believe joins aren't supported with updates in jOOQ, so I've been exploring how to work around it... My first attempt was to use where in, but the problem is that MySQL doesn't support target tables in the FROM clause: create .update(USER) .set(USER.name, concat(USER.NAME, "some text")) .where(USER.ID.in( create .select(USER.ID) .from(USER) .join(TEAM) .on(USER.TEAM_ID.eq(TEAM.ID)) .where(TEAM.STATE.equal("test")) )) .execute(); My second attempt was to use a temporary table for USER

Using UUID PK or FK in Firebird with Jooq

…衆ロ難τιáo~ 提交于 2019-12-24 00:03:59
问题 I have a table in Firebird with a PK column CREATE TABLE TEST ( ID CHAR(16) CHARACTER SET OCTETS NOT NULL, CONSTRAINT PK_TEST PRIMARY KEY (ID) ); OCTETS encoding are treated as bytes. I create a converter public class UUIDConverter implements Converter<byte[], UUID>{ @Override public Class<byte[]> fromType() { return byte[].class; } @Override public Class<UUID> toType() { return UUID.class; } @Override public UUID from(byte[] bytes) { if (bytes == null) return null; ByteBuffer bb = ByteBuffer

jOOQ: Allowed-Character constraints?

醉酒当歌 提交于 2019-12-23 23:24:35
问题 I am considering moving from Hibernate to jOOQ but I can't find e.g. how to have Pattern-Constraints on a String like this in Hibernate: @NotEmpty(message = "Firstname cannot be empty") @Pattern(regexp = "^[a-zA-Z0-9_]*$", message = "First Name can only contain characters.") private String firstname; How would I do that in jOOQ? 回答1: The "jOOQ way" The "jOOQ way" to do such validation would be to create either: A CHECK constraint in the database. A trigger in the database. A domain in the

Jooq casting String to BigDecimal

人走茶凉 提交于 2019-12-23 22:29:17
问题 Is there a way to cast a String to a BigDecimal in a jooq-query without losing precision? When i do endResER.VALUE.cast(BigDecimal.class) where VALUE is a field with a String-value in the database it returns a BigDecimal without any fraction digits. I need to compare two amounts that are saved as Strings in the DB. 回答1: You can cast your value to a SQLDataType like this: endResER.VALUE.cast(SQLDataType.DECIMAL.precision(10, 5)) Beware though, that there is a known issue for jOOQ 3.1: #2708.

jOOQ - Concisely Representing Both Columns and Aggregate/Window Functions in a Query

别说谁变了你拦得住时间么 提交于 2019-12-23 15:26:29
问题 This post comes as a result of a comment I left on a similar question: https://stackoverflow.com/a/19860271/2308858 I'm using PostgreSQL and jOOQ 3.4 and trying to represent the following SQL query in jOOQ: SELECT *, COUNT(*) OVER() FROM table1 t1 JOIN table2 t2 ON (t1.id = t2.id) JOIN table3 t3 ON (t1.otherId = t3.otherId) I like how Postgres lets me concisely represent "all columns plus the count column" with nothing more than SELECT *, COUNT(*) OVER() . But when I try to represent this

Does Jooq support Joda-Time?

人走茶凉 提交于 2019-12-23 14:55:08
问题 We are looking for date time support for different timezones. It seems Hibernate supports Joda time, any idea does JOOQ supports the same? 回答1: jOOQ by itself does not support Joda-Time, nor any other third-party data type. But you can easily configure the jOOQ code generator to rewrite data types through custom converters. This is documented here: http://www.jooq.org/doc/latest/manual/sql-execution/fetching/data-type-conversion/ http://www.jooq.org/doc/latest/manual/code-generation/custom

INSERT..RETURNING is not working in JOOQ

天大地大妈咪最大 提交于 2019-12-23 12:13:30
问题 I have a MariaDB database and I'm trying to insert a row in my table users . It has a generated id and I want to get it after insert. I have seen this but it's not working for me: public Integer addNewUser(String name) { Record record = context.insertInto(table("users"), field("name")) .values(name) .returning(field("id")) .fetchOne(); return record.into(Integer.class); } New row is inserted but record is always null . I'm not using JOOQ code generation. 回答1: This is a known limitation in