JOOQ vs Hibernate [closed]

While jOOQ and Hibernate compete for the same target audience, they do not solve the same problem at all. You’ve already linked this article in your question. The essence of it is simple: Are you going to solve object graph persistence problems? Use an ORM (e.g. Hibernate) Are you going to embed SQL into Java? … Read more

How to write Count Query In jOOQ

The most straight-forward way to implement what you’re requesting is this, by using selectCount(): int count = DSL.using(configuration) .selectCount() .from(Table) .fetchOne(0, int.class); Alternatively, you can explicitly express the count() function: int count = DSL.using(configuration) .select(DSL.count()) .from(Table) .fetchOne(0, int.class); Or, you can use this, if you don’t like mapping the value: int count = DSL.using(configuration) .fetchValue(selectCount().from(Table)); … Read more

Comparing Querydsl, jOOQ, JEQUEL, activejdbc, iciql and other query DSLs

In modern JVM’s you shouldn’t be worrying about SQL string concatenation too much. The true overhead any database abstraction layer may produce (compared to the relatively high round-trip time to the database and back), is usually due to second-level caching, which is done in Hibernate/JPA. Or by inefficiently mapping object models to SQL in a … Read more

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

This kind of problem is typical when not using a real ORM, and there is no silver bullet. A simple design approach that worked for me for a (not very big ) webapp with iBatis (myBatis), is to use two layers for persistence: A dumb low-level layer: each table has its Java class (POJO or … Read more

UPSERT in PostgreSQL using jOOQ

jOOQ 3.7+ supports PostgreSQL 9.5’s ON CONFLICT clause: https://github.com/jOOQ/jOOQ/issues/4299 http://www.postgresql.org/docs/9.5/static/sql-insert.html The full PostgreSQL vendor-specific syntax is not yet supported, but you can use the MySQL or H2 syntax, which can both be emulated using PostgreSQL’s ON CONFLICT: MySQL INSERT .. ON DUPLICATE KEY UPDATE: DSL.using(configuration) .insertInto(TABLE) .columns(ID, A, B) .values(1, “a”, “b”) .onDuplicateKeyUpdate() .set(A, “a”) … Read more

java.util.stream with ResultSet

The first thing you have to understand is that code like try (Connection connection = dataSource.getConnection()) { … try (PreparedStatement pSt = connection.prepareStatement(sql)) { … return stream; } } does not work as by the time you leave the try blocks, the resources are closed while the processing of the Stream hasn’t even started. The … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)