You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by bsterner <br...@gmail.com> on 2007/11/30 22:18:10 UTC
resultMap and HashMap
I'm wondering if it is possible to have a resultMap with type HashMap/TreeMap
where the key/value pairs map to 2 columns. So, for example if I have a
column "id" and a column "date", the k => v pair would be date => id or vice
versa. The overall goal here is to provide the developer a data structure
that allows them to be able to search for a date entry, and then research
for the entire object using the id.
Thanks
--
View this message in context: http://www.nabble.com/resultMap-and-HashMap-tf4924592.html#a14093711
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
Re: resultMap and HashMap
Posted by Larry Meadors <lm...@apache.org>.
Uh, what?
On Nov 30, 2007 2:18 PM, bsterner <br...@gmail.com> wrote:
>
> I'm wondering if it is possible to have a resultMap with type HashMap/TreeMap
> where the key/value pairs map to 2 columns. So, for example if I have a
> column "id" and a column "date", the k => v pair would be date => id or vice
> versa. The overall goal here is to provide the developer a data structure
> that allows them to be able to search for a date entry, and then research
> for the entire object using the id.
>
> Thanks
> --
> View this message in context: http://www.nabble.com/resultMap-and-HashMap-tf4924592.html#a14093711
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>
Re: resultMap and HashMap
Posted by Argan <ar...@yahoo.com.cn>.
You can use queryForMap("STATEMENT-NAME",paramObj,"keyColumn","valueColumn")
bsterner wrote:
>
> Well, if my result map was this...
>
> <resultMap id="diaryResult" class="Map">
> <result property="diaryId" column="DiaryID"/>
> <result property="entryDate" column="EntryDate" jdbcType="DATE"
> javaType="java.util.Date"/>
> </resultMap>
>
> The result is a hashmap with the following entries
>
> diaryId => {DiaryID Value}
> entryDate => {Entry Date Value}
>
> What I want is...
>
> {DiaryID Value} => {Entry Date Value}
>
> One of the columns makes the key, the other the value. Would there be a
> way to do this with a custom type handler, if it cannot be done using the
> standard mapping rules?
>
>
>
>
--
View this message in context: http://www.nabble.com/resultMap-and-HashMap-tf4924592.html#a14187333
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
Re: resultMap and HashMap
Posted by bsterner <br...@gmail.com>.
Well, if my result map was this...
<resultMap id="diaryResult" class="Map">
<result property="diaryId" column="DiaryID"/>
<result property="entryDate" column="EntryDate" jdbcType="DATE"
javaType="java.util.Date"/>
</resultMap>
The result is a hashmap with the following entries
diaryId => {DiaryID Value}
entryDate => {Entry Date Value}
What I want is...
{DiaryID Value} => {Entry Date Value}
One of the columns makes the key, the other the value. Would there be a way
to do this with a custom type handler, if it cannot be done using the
standard mapping rules?
--
View this message in context: http://www.nabble.com/resultMap-and-HashMap-tf4924592.html#a14108984
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.