Skip to content
Advertisement

Tag: jooq

Using classes from /target

I am using JOOQ. JOOQ generates meta classes, using with database requests. It’s recommended to generate classes into /target/generated-sources/jooq. But when I try to call these meta classes in code, they are not accessible. Please, tell me what to do. Answer This is the default output location because the assumption is that most people are using Maven, and Maven will

Returning id in generic insert using JOOQ

I have a very generic API to insert stuff using JOOQ to soem tables: Is there a way to return id of that inserted record? All primary keys of tables in my db are named “id” so I could ahrdcode it but I cannot find a way to return it and cast to Integer / Long. I’m using JOOQ 3.9.5.

Case When syntax expression in jooq

I am trying to reproduce this MySQL query in jooq to Answer What you seem to be looking for is the SQL:2003 simple CASE expression, which allows to form something like “partial predicates” based on the case value, akin to pattern matching in other languages. This is not yet supported in jOOQ, see Issue #3223. Interestingly, though, your SQL example

Convert Hibernate @Formula (case ) to JOOQ field

I am rewriting entire DB access layer from Hibernate to JOOQ and I face following issue. One of JPA models is annotated with @Formula annotation as follows: I saw the following question : Convert Hibernate @Formula to JOOQ field but it did not really help How can above query be translated to JOOQ DSL? Answer The jOOQ manual’s section about

Convert Hibernate @Formula to JOOQ field

I am rewriting entire DB access layer from Hibernate to JOOQ and I face following issue. One of JPA models is annotated with @Formula annotation as follows: Later in the code, a JPA query is made against the database which compares fee5 to parameter: How can above query be translated to JOOQ DSL? Answer I managed to resolve the issue

jOOQ: Mocking DAO objects

jOOQ 3.5.0 I’m currently trying to write unit tests for a resource that is using jOOQs generated DAO objects. I’ve noticed one of the base classes (DAOImpl) in the DAO hierarchy has many final methods which makes it unfriendly to mock (I’m excluding byte code manipulators like Powermock as a solution). I’m currently using the MockConnection and MockDataProvider pattern to

How to use named parameter in plain sql with jooq

I’m using JOOQ with plain/raw SQL, so that means i’m not using any code generation or the fluid DSL thingy. The following code works: Now let’s say i have a query with multiple parameters like this: How do i use a named parameter with these types of queries? I’m thinking something like : But the above code doesn’t work (for

Advertisement