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.

320 questions
46
votes
7 answers

What is the difference between JDBC and JDBI?

I want to know about the differences between JDBC and JDBI in java. In particular, which one is generally better and why?
Amira Elsayed Ismail
  • 8,304
  • 26
  • 74
  • 144
33
votes
4 answers

How to do in-query in jDBI?

How can I execute somethings like this in jDBI ? @SqlQuery("select id from foo where name in ") List getIds(@Bind("nameList") List nameList); Table: foo(id int,name varchar) Similar to @SelectProvider from…
Mohit Verma
  • 1,749
  • 6
  • 22
  • 30
30
votes
4 answers

How to create a one-to-many relationship with JDBI SQL object API?

I'm creating a simple REST application with dropwizard using JDBI. The next step is to integrate a new resource that has a one-to-many relationship with another one. Until now I couldn't figure out how to create a method in my DAO that retrieves a…
Tilman
  • 855
  • 1
  • 8
  • 17
24
votes
2 answers

jdbi return autogenerated value on inserts

I am playing with dropwizard and I want to build a REST application that has various foreign-key relations in the entities. For example given the following 3 tables: -- table persons CREATE TABLE PUBLIC.PERSONS( ID BIGINT DEFAULT NOT NULL…
Alexander Köb
  • 904
  • 1
  • 8
  • 19
15
votes
2 answers

Jdbi - how to bind a list parameter in Java?

We have an SQL statement which is executed by Jdbi (org.skife.jdbi.v2). For binding parameters we use Jdbi's bind method: Handle handle = ... Query> sqlQuery = handle.createQuery(query); sqlQuery.bind(...) However we have a…
Jaroslaw Pawlak
  • 5,270
  • 7
  • 26
  • 52
15
votes
2 answers

Using Transaction with JDBI / IDBI / Dropwizard -- rollback problems

I'm having a lot of trouble getting transactions to work with IDBI. We're using the dropwizard framework and simple inserts, updates, selects, and deletes have worked find but now we cannot seem to get the transactions to work correctly. Here is…
jcity
  • 746
  • 1
  • 7
  • 13
14
votes
2 answers

JDBI using @bind for variables in queries inside quotes

I'm wondering if/how this is possible, if it is, I'm sure its a simple fix that I can't seem to figure out @SqlQuery("SELECT * FROM Table WHERE column LIKE '%:thingName%'") public Set getThings(@Bind("thingName", String…
user2441922
  • 143
  • 1
  • 4
13
votes
3 answers

Dynamic Order in JDBI SQL Object Queries

How do you do ordering with SQL Object Queries in JDBI? I want to do something like: @SqlQuery( "SELECT * FROM users " + "WHERE something = :something " + "ORDER BY :orderBy :orderDir" ) List getUsers( @Bind("something")…
sclausen
  • 1,670
  • 3
  • 15
  • 22
12
votes
5 answers

Using @Transaction in JDBI / Dropwizard application

I hava two jdbi dao like these: public interface dao1 { @Query("insert into table1 ...") findByid(myBean1); } public interface dao2 { @Query("insert into table2 ...) save(myBean2; } } i want to execute save of two dao in one transaction…
LucaA
  • 603
  • 2
  • 7
  • 18
10
votes
2 answers

How to use IN operator with JDBI?

I'm trying to do a IN query using MYSQL JDBI on Dropwizard (not relevant, I assume). @SqlQuery("SELECT id FROM table where field in ()") List findSomething(@BindIn("list") List someList); As suggested here, I've also…
Kenneth
  • 3,767
  • 8
  • 36
  • 59
10
votes
3 answers

Hibernate vs JDBI

I am building a web service using the Dropwizard framework (version 0.7.0). It involves executing some read-only queries to the database, manipulating the result set and then returning that data set. I am using MySQL as a database engine. Since I am…
rigal
  • 362
  • 4
  • 17
10
votes
2 answers

How do you inject jdbiFactory DAOs into a Dropwizard Command?

I'm starting to work with Dropwizard and I'm trying to create a Command that requires to use the database. If someone is wondering why I'd want to do that, I can provide good reasons, but this is not the point of my question anyway. It's about…
ggalmazor
  • 691
  • 6
  • 18
9
votes
2 answers

Can @Bind be used with enums and other arbitrary types using JDBI?

Does JDBI support binding of enum types via annotation? For example, assuming a DAO that included a method: @SqlQuery("select count(*) from answer a where a.foo = :foo") Long someSqlQuery(@Bind("foo") Foo foo); And, foo equal to Foo.BAR, could I…
vpiTriumph
  • 2,846
  • 1
  • 25
  • 34
9
votes
3 answers

Dropwizard and Guice: injecting Environment

I am currently building a Dropwizard + Guice + Jersey-based application where the database access is being handled by JDBI for the time being. What I am trying to achieve is to have your typical enterprise architecture, where Resources access…
CptPicard
  • 177
  • 1
  • 4
  • 15
9
votes
2 answers

How to dynamically bind a table name in JDBI

I tried using SELECT COUNT(*) FROM :TableName; And in JDBI I used .bind("Tablename", "MyTable") The result is always inside single quotes: SELECT COUNT(*) FROM 'MyTable'; Is there a proper way to parameterise something like TableName?
HelloPe
  • 165
  • 1
  • 4
1
2 3
21 22