[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-3403) new ResultSetTransformer which converts a two columns of a result set into one big HashMap.

Max Rydahl Andersen (JIRA) noreply at atlassian.com
Tue Jul 29 06:16:47 EDT 2008


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3403?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_30749 ] 

Max Rydahl Andersen commented on HHH-3403:
------------------------------------------

We do have tests for the transformers (CriteriaQueryTest, Dom4jtest, NativeSQLQueryTest etc.)

btw. any possibility you could submit it as a *patch* ?



> new ResultSetTransformer which converts a two columns of a result set into one big HashMap.
> -------------------------------------------------------------------------------------------
>
>                 Key: HHH-3403
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3403
>             Project: Hibernate3
>          Issue Type: Patch
>          Components: query-criteria
>    Affects Versions: 3.3.0.CR1
>            Reporter: Antony Stubbs
>            Priority: Minor
>         Attachments: PassThroughTransformer.java, ResultElementTransformer.java, resultrow-to-mapentry.rar
>
>
> This patch introduces a new ResultSetTransformer which converts a two column result set into a HashMap.
> I realised when trying to integrate it into the Hibernate package that I would have to remove the Generics which is a shame. 
> Wasn't sure where to house the test case as there seem to be no direct tests of ResultTransformer type code, so I added a new test package and put it there.
> The first result column should contain unique values. Any non-unique values will cause the hash map to overwrite the previous value stored in the hash map.
> A usage example might be to easily convert a country code lookup table into a hashmap.
> The closest existing transformer AliasToEntityMapResultTransformer converts a result map into a list of hash maps contain key/value pairs for the column name / value, as opposed to this patch which creates one large map, vertically instead of horizontally you could say.
> "A Result Transformer which generates a map of the results. Useful for use
> with lookup tables or simple key value pair tables. For example, with a
> country codes to names table you could use the result like this:
> result.get("nz") would return "New Zealand"."
> I've attached the project I made it in, from which you should just be able to take the class files.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list