I ran into a really weird problem when I tried to implement a count query
with jOOQ:
It doesn't matter how many rows the *todos* table has. My count query
always returns 1. The cleaned up version of my repository looks as follows:
import org.jooq.Condition;
import org.jooq.DSLContext;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import static net.petrikainulainen.spring.jooq.todo.db.tables.Todos.TODOS;
@Repository
public class JOOQTodoRepository implements TodoRepository {
private final DSLContext jooq;
//Removed constructor for the sake of clarity
@Transactional(readOnly = true)
@Override
public long findCountBySearchTerm(String searchTerm) {
String likeExpression = "%" + searchTerm + "%";
return jooq.selectCount()
.from(TODOS)
.where(
TODOS.DESCRIPTION.likeIgnoreCase(likeExpression)
.or(TODOS.TITLE.likeIgnoreCase(likeExpression)
)
.fetchCount();
}
}
I am using jOOQ 3.3.2 and H2 version 1.3.174. All help is appreciated :)
--
You received this message because you are subscribed to the Google Groups "jOOQ
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.