Questions tagged [jdbi]

jDBI is an extension library over standard JDBC, to make writing relational database access more convenient (and correct!) from Java.

jDBI is a Java library that builds on JDBC to offer more convenient, light-weight access to relational databases. It aims to make database access more convenient and correct by building simple abstractions on top of raw JDBC.

384 questions
6
votes
1 answer

JDBI Object Query

I've used JDBI before for Java persistence stuff before but it's always been the fluent API not the object API. Trying the Object API now. I've got a DAO Object that is pretty simple: public interface PersonDAO { @SqlQuery("insert into…
Joe Schmuck
  • 309
  • 3
  • 7
5
votes
3 answers

transactions in jdbi

I execute sql queries as transactions using jdbi inTransaction() function. I would like to know how/what type of locking mechanism is used internally. additionally, is the whole table locked during the transaction or just the record that has to be…
FSP
  • 4,677
  • 2
  • 19
  • 19
5
votes
1 answer

Postgres delete before insert in single transaction

PostgreSQL DB: v 9.4.24 create table my_a_b_data ... // with a_uuid, b_uuid, and c columns NOTE: the my_a_b_data keeps the references to a and b table. So it keeps the uuids of a and b. where: the primary key (a_uuid, b_uuid) there is also an…
ses
  • 13,174
  • 31
  • 123
  • 226
5
votes
1 answer

Why JDBI 3 @ColumnName annotation doesn't work?

I want to use jdbi 3 @ColumnName annotations to map column name of the table and java bean field, but at runtime jdbi throws an exception. My question is why is the exception thrown? Is my usage incorrect? How to solve this problem? Thanks Database…
followflows
  • 51
  • 1
  • 3
5
votes
2 answers

Upgrading Dropwizard JDBI to JDBI 3

How do you upgrade dropwizard jdbi 2.78 to jdbi version 3 since I want to make use of the joins functionality included in it.
user2987773
  • 407
  • 5
  • 18
5
votes
1 answer

JDBI supports stored procedure with out parameter

JDBI has @SqlCall annotation for calling procedure, but right now the method marked by this annotation only can return null or OutParameters. So right now is there anyway we can get the out parameter via OutParameters when calling the procedure with…
Troy Young
  • 181
  • 1
  • 12
5
votes
1 answer

How to test JDBI DAO's with H2-in-memory database?

I'm using Dropwizard framework with JDBI and h2-in-memory for my test purposes. Also I've written my DAOs, and now I want to test them with unit tests. I came along the DBUnit which seem to fit my requirements. But how to integrate it with JDBI and…
VanDavv
  • 836
  • 2
  • 13
  • 38
5
votes
2 answers

jdbi BindBean userdefined property of the bean(nested object)

I have a bean class public class Group{string name;Type type; } and another bean public class Type{String name;} Now, i want to bind group by using jdbi @BindBean @SqlBatch("INSERT INTO (type_id,name) VALUES((SELECT id FROM type WHERE…
Nandu Prajapati
  • 129
  • 2
  • 7
5
votes
1 answer

What is the difference between @Bind and @BindBean in JDBI?

What is the difference between @Bind and @BindBean in JDBI? Example code: @SqlUpdate("insert into myObject (id, name) values (:id, :name)") int insert(@BindBean MyObject myObject); @SqlQuery("select id, name from myObject where id = :id") MyObject…
user4975679
  • 1,461
  • 16
  • 21
5
votes
3 answers

Are JDBI batch operation atomic?

Are JDBI batch operations (inserts or updates) atomic? Or do I need to wrap them in a transaction block?
Jairam
  • 113
  • 9
5
votes
2 answers

problems mocking a class

I'm trying to mock the Query class of JDBI with mockito, however it fails to mock the methods of its base class SqlStatement. When running the code below the when statement is actually calling the concrete implementation in the base class and fails…
LiorH
  • 18,524
  • 17
  • 70
  • 98
4
votes
3 answers

How do I bind a list of tuples in jdbi?

I have a mysql query in this format SELECT * from xyz where (key1, key2) in (('val1', 'val2'), ('val3', 'val4')); I'm using jdbi to make this query. How do I bind the list of tuples in jdbi ? I was trying to use something like this List
4
votes
2 answers

Mocking the arguments passed to callbacks (lambdas)

How would I mock methods that accept a lambda using Mockito so that I am able to control which arguments are passed into the callback? I am specifically trying to mock the JDBI method useExtension which is used like…
oligofren
  • 20,744
  • 16
  • 93
  • 180
4
votes
3 answers

Use a list of strings in IN clause with JDBI

I'm using JDBI / Dropwizard for a project and would like to run some simple queries. I have a query like so: private static final String GET_STUFF = "SELECT * FROM myTable WHERE state IN (:desiredState)" I bind the variable in my method like…
4
votes
2 answers

JDBI resultset mapping with joined list of results?

Trying to build a Country object with JDBIs ResultSetMapper API, however I have one issue which I am not sure how to solve. For a resultset like the following which joins the Regions (states/ territories) table to country (1 - 0..n) …
tomaytotomato
  • 3,788
  • 16
  • 64
  • 119
1 2
3
25 26