jooq

JOOQ with Logback

浪尽此生 提交于 2020-03-01 04:45:46
问题 I use springBoot with JOOQ and would like to log generated SQL's. I added slf4J to my maven dependency and log4j.xml like in JOOQ documenation (http://www.jooq.org/doc/latest/manual/sql-execution/logging/). But when jooq executes some queries, I can not see any log in my console. I also search for this issue in google, but I couldn't find anything. SpringBoot uses logBack, so I have logBack and slf4J in my path. Is it possible to use logBack for JOOQ ? I didnt any instruction on JOOQ Site

修改jOOQ codegen默认生成类策略

时光怂恿深爱的人放手 提交于 2020-02-29 09:29:21
使用默认生成类策略 项目中采用了jOOQ作为ORM框架,并使用jOOQ codegen生成Table,Record和PO。 codegen使用说明请见 这里 。codegen的gradle配置请见 这里 。 表结构: CREATE TABLE `user` ( `id` int(11) NOT NULL AUTO_INCREMENT, `user_name` varchar(20) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; gradle配置: import groovy.xml.MarkupBuilder import org.jooq.util.GenerationTool import javax.xml.bind.JAXB buildscript { ext { springBootVersion = '1.5.4.RELEASE' } repositories { mavenCentral() } dependencies { classpath('mysql:mysql-connector-java:5.1.39') classpath('org.jooq:jooq-codegen:3.9.1') classpath("org.springframework.boot

三、jOOQ 系列教程

浪尽此生 提交于 2020-02-26 18:30:49
完整教程: https://jooq.diamondfsd.com POJO是一个简单的Java对象,主要是包含一些属性和 getter/setter 方法,在业务中常用到的是用于传输数据以及作为参数传递。 在Web应用的场景中,也通常用来和前端做数据交互 jOOQ的代码生成器能够帮我们根据表结构生成对应的POJO,能很大程度上减少我们自己创建POJO的工作量,当然,此功能也是大部分ORM框架的必备功能。本章主要讲解各种方式将数据结果转换为我们想要的格式 Fetch 系列 API 查询操作通常以fetch API 作为结束API,例如常用的有,所有的读取类方法都差不多,掌握一个就能很快的举一反三 读取多条 fetch 读取集合 fetchSet 读取并返回一个Set集合,常用于去重 fetchArray 读取并返回一个数组 读取单条 fetchOne 读取单条记录,如果记录超过一条会报错 fetchAny 读取单条记录,如果有多条,会取第一条数据 fetchSingle 读取单条记录,如果记录为空或者记录超过一条会报错 读取并返回Map fetchMap 读取并返回一个Map fetchGroups 读取并返回一个分组Map fetch 作为一个常用的读取多条记录的API,其他几个读取多条的方法和这个方法类似,只是返回值不同 fetchSet, fetchArray 方法和

十、jOOQ 系列教程

我的未来我决定 提交于 2020-02-26 18:14:11
完整教程: https://jooq.diamondfsd.com/ 由 jOOQ 生成的 POJO 是针对单个表的字段进行生成。在关联查询中,通常我们要将多个表的数据存放在一个类里。这种情况下,我们可以自行创建一个类,去添加我们需要的多表字段成员变量 对于这种比较常见的情况来说,手动创建类显得很繁琐,我们可以在生成 POJO 的同时,创建一个空白的并且继承原有POJO的类,需要添加字段的时候,直接在我们生成的类上添加想要的其他表字段 要想达到以上效果,我们还是需要自定义代码生成器,添加针对这些继承类(这里先称之为 Entity)的创建代码逻辑。通过之前的需求分析,这些代码创建后需要由我们自行修改的,所以只能生成一次, 文件存在的时候就不能再进行覆盖或者被代码生成器删除 所有生成的 Entity 我们需要放在 jOOQ 配置的目标包平行的父级包内。这样 jOOQ 在生成代码前清空指定目录的包内容时,我们自己的包不会被波及到。并且在生成逻辑中,需要判断目标 Entity 文件是否已存在,如果存在就忽略 通过这些逻辑,在我们为 Entity 添加关联表的成员变量的时候,就不会被 jOOQ 的代码生成器所覆盖或删除。可以安全的去增加代码,实现我们想要的逻辑 Entity 生成 一个初始的 Entity 很简单,只需要继承 jOOQ 生成的 POJO 即可 package com

Qualifying a temporary table column name in jOOQ

风格不统一 提交于 2020-02-15 10:18:05
问题 I am using jOOQ with a temporary table: Table<Record> TMP = DSL.table("tmp"); Field<String> TYPE = DSL.field("type", String.class); Field<String> TOKEN = DSL.field("token", String.class); This allows me to write simple queries: DSL.select(TYPE, TOKEN).from(TMP)... However, when I try to join against another table, it creates ambiguities because the column names TYPE and TOKEN are not qualified with a table name (i.e. I need the generated code to look like SELECT tmp.type, tmp.token ... ). Is

Qualifying a temporary table column name in jOOQ

给你一囗甜甜゛ 提交于 2020-02-15 10:14:49
问题 I am using jOOQ with a temporary table: Table<Record> TMP = DSL.table("tmp"); Field<String> TYPE = DSL.field("type", String.class); Field<String> TOKEN = DSL.field("token", String.class); This allows me to write simple queries: DSL.select(TYPE, TOKEN).from(TMP)... However, when I try to join against another table, it creates ambiguities because the column names TYPE and TOKEN are not qualified with a table name (i.e. I need the generated code to look like SELECT tmp.type, tmp.token ... ). Is

Stream fetched from Postgres with jOOQ not returning results from class

廉价感情. 提交于 2020-02-05 03:48:05
问题 Issue I am attempting to stream results from a postgres query to a frontend application, rather than eagerly fetching all results. The problem is that I can only see streamed results only in my terminal (i.e. first in "org.jooq.tools.LoggerListener : Record fetched: ..." and then with a stream.get().forEach(s -> debug) ), and the class which references this stream only produces null values when called upon to view the ResultSet in the frontend. This data may be used for other tasks as well (e

java.lang.ClassNotFoundException: org.jooq.util.JavaGenerator

泪湿孤枕 提交于 2020-02-03 08:17:01
问题 I'm encountering the following exception after upgrading from jOOQ 3.10 to 3.11: Caused by: java.lang.ClassNotFoundException: org.jooq.util.JavaGenerator at java.net.URLClassLoader.findClass (URLClassLoader.java:381) at java.lang.ClassLoader.loadClass (ClassLoader.java:424) at java.lang.ClassLoader.loadClass (ClassLoader.java:357) at org.jooq.codegen.GenerationTool.loadClass (GenerationTool.java:819) at org.jooq.codegen.GenerationTool.run (GenerationTool.java:329) at org.jooq.codegen

java.lang.ClassNotFoundException: org.jooq.util.JavaGenerator

半城伤御伤魂 提交于 2020-02-03 08:14:09
问题 I'm encountering the following exception after upgrading from jOOQ 3.10 to 3.11: Caused by: java.lang.ClassNotFoundException: org.jooq.util.JavaGenerator at java.net.URLClassLoader.findClass (URLClassLoader.java:381) at java.lang.ClassLoader.loadClass (ClassLoader.java:424) at java.lang.ClassLoader.loadClass (ClassLoader.java:357) at org.jooq.codegen.GenerationTool.loadClass (GenerationTool.java:819) at org.jooq.codegen.GenerationTool.run (GenerationTool.java:329) at org.jooq.codegen

How to prevent Mysql Connector/J from converting DATE and TIME timezone?

旧时模样 提交于 2020-01-30 11:01:07
问题 I am connecting to a mysql server using the following DSN: jdbc:mysql://localhost/my_database?useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC . The problem I'm getting is that the java.sql.Date instance is getting timezone converted to UTC from my local timezone. My application treats dates as timezone agnostic and this is causing a few problems. For instance, I'm in IST (UTC+05:30), when I set some date field to say '2020-01-22' in code, it gets sent to the server as '2020-01-21'.