[ 
https://issues.apache.org/jira/browse/CAMEL-6366?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Zemian Deng updated CAMEL-6366:
-------------------------------

    Attachment: CAMEL-6366.patch.v2

Okay, I have made some assumptions and providing a second version of the patch. 
The new URI options work like this:

{{outputType=SelectList|SelectOne}}. It default to {{SelectList}}
{{outputClass=null|<fullClassName>}}. It default to {{null}}

The {{outputType=SelectList}} will function just as original camel-sql output, 
which produce List of Map result.

The {{outputType=SelectOne}} will produce single object in the following way:
a) If the query has only single column, then that object is returned. (such as 
{{select count(*) from project}} will return a {{Long}} object.
b) If the query has more than one column, then it will return a {{Map}} of that 
result.
c) If the {{outputClass}} is set, then it will convert the query result into an 
Java bean object by calling all the setters that match the column names. It 
will assume your class has a default constructor to create instance with.
d) If the query resulted in more than one rows, it throws an non-unique result 
exception.

Let me know what you think.

Zemian Deng


                
> SQL component - Add option to dictate if output is list, object or map
> ----------------------------------------------------------------------
>
>                 Key: CAMEL-6366
>                 URL: https://issues.apache.org/jira/browse/CAMEL-6366
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-sql
>            Reporter: Claus Ibsen
>             Fix For: 2.12.0
>
>         Attachments: CAMEL-6366.patch, CAMEL-6366.patch.v2
>
>
> When using the sql component, the output is always a List<Map>.
> It would be nice if you could configure an option to say its a 
> - selectForObject
> - selectForList
> - selectForMap
> Like MyBatis can do.
> Also we can consider having a way to store the output on a header instead of 
> altering the body. 

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to