[hibernate-issues] [Hibernate-JIRA] Created: (HHH-3403) new ResultSetTransformer which converts a two columns of a result set into one big HashMap.
Antony Stubbs (JIRA)
noreply at atlassian.com
Mon Jul 28 05:10:47 EDT 2008
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