jdbi

What does @SingleValueResult do?

半腔热情 提交于 2021-01-29 02:05:00
问题 What does @SingleValueResult do? Does it impose the constraint 'single value result'? Full name: org.skife.jdbi.v2.sqlobject.customizers.SingleValueResult Here are some links about it: https://groups.google.com/forum/#!topic/jdbi/tQge_FNUoiw https://news.ycombinator.com/item?id=8134591 回答1: No, it doesn't. Instead it just provides some more type information for Optional or Maybe return types. When JDBI recognizes that only a single row will be needed from the database, it will tell the

What does @SingleValueResult do?

a 夏天 提交于 2021-01-29 02:04:54
问题 What does @SingleValueResult do? Does it impose the constraint 'single value result'? Full name: org.skife.jdbi.v2.sqlobject.customizers.SingleValueResult Here are some links about it: https://groups.google.com/forum/#!topic/jdbi/tQge_FNUoiw https://news.ycombinator.com/item?id=8134591 回答1: No, it doesn't. Instead it just provides some more type information for Optional or Maybe return types. When JDBI recognizes that only a single row will be needed from the database, it will tell the

How do you inject jdbiFactory DAOs into a Dropwizard Command?

有些话、适合烂在心里 提交于 2020-01-03 07:29:44
问题 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 dependency inversion and Service initialization and run phases in Dropwizard. Dropwizard encourages to use its DbiFactory to build DBI instances but in order to get one, you need an Environment instance and/or the database configuration: public class

Dropwizard and Guice: injecting Environment

狂风中的少年 提交于 2020-01-01 05:04:28
问题 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 Service classes accessing a DAO class that in turn accesses the database. It would be nice to get all this wired up in a proper DI way, although I guess I can build my object graph in the run() method of the application if all else fails. So, I'm running

Dropwizard and Guice: injecting Environment

大城市里の小女人 提交于 2020-01-01 05:04:13
问题 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 Service classes accessing a DAO class that in turn accesses the database. It would be nice to get all this wired up in a proper DI way, although I guess I can build my object graph in the run() method of the application if all else fails. So, I'm running

How to print the @SqlQuery annotation in JDBI sql api

两盒软妹~` 提交于 2019-12-18 16:25:21
问题 I want to know what exactly sql query is processed by jdbi sql api for debugging purposes. My interface class is following public inteface myinteface{ @SqlQuery("select :c1 from tablename where cond = :cd") String returnMeValue(@Bind("c1") String c1, @Bind("cd") Integer cd); } and later called in another class as String result = myinterfaceclassobject.returnMeValue("Name",1); I am not getting expected answer so I want to see what actually going to the sql query. So is there any method to get

Jdbi - how to bind a list parameter in Java?

て烟熏妆下的殇ゞ 提交于 2019-12-17 19:28:08
问题 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<Map<String, Object>> sqlQuery = handle.createQuery(query); sqlQuery.bind(...) However we have a problem with in-lists and currently we are using String.format for this. So our query can look like this: SELECT DISTINCT tableOne.columnOne, tableTwo.columnTwo, tableTwo.columnThree FROM tableOne JOIN tableTwo ON tableOne.columnOne = tableTwo

JDBI's @BindBean doesn't find named parameters in bean class during INSERT

本小妞迷上赌 提交于 2019-12-14 02:16:22
问题 I am consistently getting the following exception below when inserting values using JDBI's @BindBean into my Mysql database within Dropwizard. The problem seems to be that JDBI is unable to find the properties in the bean. I already isolated the issue into a separate project, but can't figure out where this is going wrong. I would be very grateful for some advice. org.skife.jdbi.v2.exceptions.UnableToExecuteStatementException: Unable to execute, no named parameter matches "title" and no

How to insert into a snowflake variant field using a DAO?

▼魔方 西西 提交于 2019-12-13 03:30:14
问题 I have the following code: @RegisterMapper(MyEntity.ResultMapper.class) @UseStringTemplate3StatementLocator public interface MyDao { @Transaction(TransactionIsolationLevel.SERIALIZABLE) @SqlBatch("INSERT INTO mySchema.myTable (" + " id, entity_type, entity_id, flags " + " ) VALUES " + "(" + " :stepId , :entityType , :entityId,parse_json(:flags) " + ")") @BatchChunkSize(500) Object create( @BindBean List<MyEntity> entities ); } As you can see, I am bulk inserting a list of entities into my

How do I create a Dynamic Sql Query at runtime using JDBI's Sql Object API?

痞子三分冷 提交于 2019-12-12 13:18:47
问题 I've been moving an existing project from jdbc to jdbi, and I've been making much use out of jdbi's beautiful SQL Object API. We're using mysql. While the SQL Object API can construct handled queries that are known at compile time, I couldn't find a way of generating queries at run time. Specifically, I want to be able to do something like this: @SqlUpdate( "UPDATE record SET "+ @IfNotZero("foo") "foo=:foo" + @IfNotNull("bar") "bar=:bar" + @IfNotNull("baz") "baz=:baz" + "WHERE id=:id" )