When using the JOOQ MockDataProvider what is the correct way to build a MockResult for stored procedures? The examples I’ve found show how to return results for tables and views by creating a result and record from generated table definitions and then returning them. For stored procedures I’m not sure how to build the Result. How do I create a
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
Perform SQL statement after each DELETE
Is there a way to make jOOQ perform a SQL statement (in my case a CHECKPOINT) after each DELETE? Ideally there would also be a way to specify the tables that this happens for. The RDBMS I’m using (…
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.
How to resolve ambiguous match when chaining generated Jooq classes
I have defined my models in JPA and am writing some queries for my application and I am using JOOQ generated classes to join all the tables together to check if the requested resources actually belong to the requesting user. However, when I do this I get the following warning: This is my code This is the SQL it generates
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