jooq

How to start transaction and rollback with JOOQ?

╄→尐↘猪︶ㄣ 提交于 2019-12-05 03:00:46
Yes! I have read the docs about jOOQ will never commit or rollback on the Connection (Except for CSV-imports, if explicitly configured in the Import API) jOOQ will never start any transactions. ... but when I need some transaction management, what is the best practice to do this? Have I said that I'm a big fan of a way of JOOQ! This question was asked at a time when jOOQ did not yet implement a transaction API. As of jOOQ 3.4 onwards, such an API is available and documented here: https://www.jooq.org/doc/latest/manual/sql-execution/transaction-management Transaction API and its default binding

jooq- fetching a single value

这一生的挚爱 提交于 2019-12-05 02:12:31
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 I not doing this right? You're doing it right. The way the jOOQ DSL is constructed with Java generics,

How to use a custom strategy with the jOOQ code-generator and Maven?

笑着哭i 提交于 2019-12-05 00:02:49
With jOOQ , I may want to combine using the jOOQ code generator with Maven and a custom generator strategy . It looks as though this can be done as such (leaving out irrelevant parts): <plugin> <groupId>org.jooq</groupId> <artifactId>jooq-codegen-maven</artifactId> <version>2.2.2</version> <!-- The plugin should hook into the generate goal --> <executions> <execution> <goals> <goal>generate</goal> </goals> </execution> </executions> <configuration> <generator> <name>org.jooq.util.DefaultGenerator</name> <!-- But the custom strategy is not yet compiled --> <strategy> <name>com.example

How to manage DSLContext in jooq? (close connection)

给你一囗甜甜゛ 提交于 2019-12-04 21:35:09
问题 This is how I implement each jooq query that i want. UtilClass{ //one per table more or less static void methodA(){ //my method Connection con = MySQLConnection.getConexion(); //open DSLContext create = DSL.using(con, SQLDialect.MYSQL); //open /* my logic and jooq querys */ //The code !!!!!!! try { if ( con != null ) con.close(); //close } catch (SQLException e) { } //close con=null; //close create=null; //close } } Am I overworking here? / Is it safe to leave the Context and Connection Open?

jOOQ and Caching?

元气小坏坏 提交于 2019-12-04 18:21:57
问题 I am considering moving from Hibernate to jOOQ but I am not sure if I can do without caching. Hibernate has a first- and second-level cache. I know that jOOQ does have support for reusing prepared statements. Will I have to take care of caching on my own if I use jOOQ? 回答1: Query caching / result caching: I'm mentioning this, because this kind of cache is also possible with Hibernate, and it might make sense under certain circumstances. In Hibernate, the query cache works closely with the

Heroku DATABASE_URL as a JDBC Url for Maven

≯℡__Kan透↙ 提交于 2019-12-04 16:54:04
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. But I would like this to happen during the actual build process, not during application startup.

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

戏子无情 提交于 2019-12-04 16:36:49
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.writeValueAsString(uo) : null; } catch (JsonProcessingException e) { throw new RuntimeException(e); } } @Override

How to get all the result columns from database with other custom(concat, sum, count) columns in Jooq

一曲冷凌霜 提交于 2019-12-04 16:29:35
问题 I have a table Table1 with 6 columns. Here is the sql statement that i need to map. Select *,count(ID) as IdCount from Table1; Now, the sql query result will be 7 columns ( 6 Table1 columns and 1 IdCount column). But when i implement the same in Jooq with this query, it only gets a single column "IDCount". SelectQuery q = factory.selectQuery(); q.addSelect(Table1.ID.count().as("IdCount")); q.addFrom(Table1.TABLE1); Now, the resultant recordset have only a single column "IdCount" while what i

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

爷,独闯天下 提交于 2019-12-04 09:07:16
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? You can have multiple <execution> elements in any Maven plugin configuration, e.g. <plugin> <groupId>org.jooq</groupId> <artifactId>jooq-codegen-maven</artifactId> <version>3.9.1</version> <executions> <execution> <id>first-generation</id> <phase>generate-sources</phase>

Replacing a full ORM (JPA/Hibernate) by a lighter solution : Recommended patterns for load/save?

耗尽温柔 提交于 2019-12-04 07:39:55
问题 I'm developing a new Java web application and I'm exploring new ways (new for me!) to persist the data. I mostly have experience with JPA & Hibernate but, except for simple cases, I think this kind of full ORM can become quite complex. Plus, I don't like working with them that much. I'm looking for a new solution, probably closer to SQL. The solutions I'm currently investigating : MyBatis JOOQ Plain SQL/JDBC, potentially with DbUtils or some other basic utility libraries. But there are two