[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3403?page=c...
]
Antony Stubbs updated HHH-3403:
-------------------------------
Attachment: HHH3403.patch
There, that should be it.
Sorry about that, was very tired when I uploaded it didn't think of the inconvenience.
Main motivation was that my laptop isn't very good and it was much much easier to
develop and test it as a separate project - but of course that's a pain to merge!
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: HHH3403.patch, 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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira