jooq

jooq使用示例

非 Y 不嫁゛ 提交于 2020-01-26 08:23:04
一.说明   最近使用的项目,采用了jooq。   通过学习api文档和自我调试,写了一些代码,在此处进行记录。 二.代码   一切尽在代码中……   参考文档: http://www.jooq.org/doc/3.11/manual-single-page/ package com.transsnet.sims.business; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.commons.lang3.StringUtils; import org.jooq.Condition; import org.jooq.DSLContext; import org.jooq.Record; import org.jooq.Record1; import org.jooq.Record2; import org.jooq.Result; import org.jooq.SelectJoinStep; import org.jooq.UpdateSetFirstStep; import org.jooq.UpdateSetMoreStep; import org.springframework.beans

The difference in ordering of enum type literals between PostgreSQL 9.0 and 9.1

六月ゝ 毕业季﹏ 提交于 2020-01-24 09:29:48
问题 There has been some curious update in the way enum types work between PostgreSQL 9.0 and 9.1. The pg_catalog.pg_enum table has a new column enumsortorder in PostgreSQL 9.1. This order seems to override the previous enum ordering based on OIDs. PostgreSQL 9.0 Documentation The OIDs for a particular enum type are guaranteed to be ordered in the way the type should sort, but there is no guarantee about the ordering of OIDs of unrelated enum types. PostgreSQL 9.1 Documentation The OIDs for pg

The difference in ordering of enum type literals between PostgreSQL 9.0 and 9.1

≡放荡痞女 提交于 2020-01-24 09:29:46
问题 There has been some curious update in the way enum types work between PostgreSQL 9.0 and 9.1. The pg_catalog.pg_enum table has a new column enumsortorder in PostgreSQL 9.1. This order seems to override the previous enum ordering based on OIDs. PostgreSQL 9.0 Documentation The OIDs for a particular enum type are guaranteed to be ordered in the way the type should sort, but there is no guarantee about the ordering of OIDs of unrelated enum types. PostgreSQL 9.1 Documentation The OIDs for pg

Springboot + 持久层框架JOOQ

做~自己de王妃 提交于 2020-01-21 17:01:31
简介 官网链接 JOOQ是一套持久层框架,主要特点是: 逆向工程,自动根据数据库结构生成对应的类 流式的API,像写SQL一样 提供类型安全的SQL查询,JOOQ的主要优势,可以帮助我们在写SQL时就做检查 支持几乎所有DDL,DML 可以内部避免SQL注入安全问题 支持SQL渲染,打印,绑定 使用非常轻便灵活 可以用JPA做大部分简单的查询,用JOOQ写复杂的 可以只用JOOQ作为SQL执行器 可以只用来生成SQL语句(类型安全) 可以只用来处理SQL执行结果 支持Flyway,JAX-RS,JavaFX,Kotlin,Nashorn,Scala,Groovy,NoSQL 支持XML,CSV,JSON,HTML导入导出 支持事物回滚 Springboot+JOOQ初体验 持久层框架很多,这里参考官网和其他博客用Springboot迅速搭建一个简单demo看看是否好用 配置依赖 pom.xml <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jooq</artifactId> </dependency> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId>

Casting org.jooq.TableField<Long> to org.jooq.TableField<BigDecimal>

牧云@^-^@ 提交于 2020-01-17 06:40:18
问题 I was wondering if anybody can help me with casting the table object type from Long to BigDecimal? In sql, the code is like this: AND table_nameA.row_name = table_nameB.row_name In jooq is just simple as: and(table_nameA.row_name.eq( table_nameB.row_name)) I tried to cast it with Select <? extends Record1<BigDecimal> but I received a ClassCastException org.jooq.immpl.TableFieldImpl cannot be cast to org.jooq.Select . And when I tried to cast it with (BigDecimal) , I received a

how to use jOOQ (or something else) in such condition

我的未来我决定 提交于 2020-01-16 04:35:06
问题 jOOQ runs on generated classes (from database schema). In my apps, there are many tables created while excuting . Then how can I query them using jOOQ? Or can I use something else to do this? We just use jOOQ to generate SQL, not doing any CRUD operation. 回答1: While being the main use case for using jOOQ, you do not have to generate any source code with jOOQ. Several users have used jOOQ the way you do, by supplying dynamic table/column names at runtime to Factory methods such as: DSL

jOOQ insert into .. where not exists for Postgres

六月ゝ 毕业季﹏ 提交于 2020-01-15 15:28:10
问题 I'm attempting to do an upsert-style statement for Postgres in jOOQ. The framework I'm running in takes care of concurrency concerns in this specific situation so I'm not worried about that. I'm only using jOOQ for creating the SQL, the actual execution is done via Spring's JdbcTemplate and a BeanPropertySqlParameterSource. I've decided to go with a two-step "insert..where not exists" / "update .." process. My SQL is: insert into mytable (my_id, col1, col2) select :myId, :firstCol, :secondCol

jOOQ insert into .. where not exists for Postgres

二次信任 提交于 2020-01-15 15:27:08
问题 I'm attempting to do an upsert-style statement for Postgres in jOOQ. The framework I'm running in takes care of concurrency concerns in this specific situation so I'm not worried about that. I'm only using jOOQ for creating the SQL, the actual execution is done via Spring's JdbcTemplate and a BeanPropertySqlParameterSource. I've decided to go with a two-step "insert..where not exists" / "update .." process. My SQL is: insert into mytable (my_id, col1, col2) select :myId, :firstCol, :secondCol

jooq- fetching a single value

喜你入骨 提交于 2020-01-13 08:26:08
问题 I had a question.. Why do I have repeat what I have selected in the fetch method. Date minDate = getDSLContext() .select(CON_CAL_INSTANCE.DATE.min()) .from(CON_CAL_INSTANCE) .join(CON_CAL_TEMPLATES) .on(CON_CAL_INSTANCE.TEMPLATE_ID.eq(CON_CAL_TEMPLATES.ID)) .where(CON_CAL_TEMPLATES.ENTRY_TYPE.in("REPT", "HRPT")) .fetchOne(CON_CAL_INSTANCE.DATE.min()); So I have provided CON_CAL_INSTANCE.DATE.min() in my select clause, why do I have to repeat it in fetchOne(CON_CAL_INSTANCE.DATE.min()) ? Or am

Is it possible to write a data type Converter to handle postgres JSON columns?

五迷三道 提交于 2020-01-13 06:08:27
问题 Ideally using Jackson on the Java side of things. I have tried the obvious solution: public class JsonObjectConverter implements Converter<Object, ObjectNode> { private final ObjectMapper mapper = new ObjectMapper(); @Override public ObjectNode from(Object dbo) { try { return dbo != null ? mapper.readValue((String) dbo, ObjectNode.class) : null; } catch (IOException e) { throw new RuntimeException(e); } } @Override public Object to(ObjectNode uo) { try { return uo != null ? mapper