-
-
Notifications
You must be signed in to change notification settings - Fork 336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't use Map<String, Object> inside a 'SQL Object Query' #466
Comments
So if you're using the fluent API (i.e. using the Handle to create queries We seem to have overlooked this case for SQL objects. I'll submit an issue An easy workaround is to implement your SQL method as a concrete method: public List<Map<String,Object>> doQuery(String arg0, int arg1) { On Wed, Aug 31, 2016 at 8:23 AM, Matty Southall notifications@github.com
|
We should also add some code examples of various methods for joining. |
@stevenschlansker Some samples would be great for joining. How to handle one to many or one to one effectively? |
My go-to tool for one-to-n joins is to use
|
@qualidafial It would be interesting to make use of java.util.Optional (https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html) for one-to-n joins. If my entity is setup as:
'bar' may always not be required, wrapping it into an |
That's certainly up to you. |
So looking at the v2 code, supporting Another workaround in v2: you could also call In v3, you can simply call |
@qualidafial Wouldn't it be a better idea to have a custom ResultSet class instead of handling |
@matty What you're describing is pretty much the point of |
It looks like we support this via registering Let us know if this doesn't solve your problem! |
When returning type Map<String, Object> or List<Map<String, Object>> causes a failure saying there is no result set mapper for type 'java.util.Map'. I know 'SQL Object Query' (http://jdbi.org/sql_object_api_queries/) is for returning objects, but it would be nice to be able to return this type for when you don't want to specify and object and a result set mapper which is useful in some scenarios. (e.g when doing a complex join query).
I got around the issue by providing a mapper for the type 'java.util.Map' using the code below.
But it would be nice if this was included as standard.
ps. If anyone knows of a proper way of doing SQL joins easily in JDBI without having to specify multiple complex objects for each join (or an object for each data set you want) then let me know.. AFAIK transforming the ResultSet into a Map<String, Object> is the easiest way.
The text was updated successfully, but these errors were encountered: