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 I L <is...@hotmail.com> on 2008/09/05 19:43:58 UTC

Calendars in paramter Maps not working

Hi guys,





Let me just start by saying this is an awesome project! We were using hibernate which ended up being too complicated for what we needed. We switched to ibatis and it fit like a glove. Keep up the good work!

I am having one issue with maps and calendars. I am passing a Java Map as a parameter to the <select> entity. It is a map of objects and has two key-value pair. One is a String and the other is a Calendar:

String id => "3333"
Calendar fromDate => Java Calendar

The problem is that ibatis is throwing this error:
----------------------------------
--- The error occurred in com/blahblah/config/AccountEvent.xml.  
--- The error occurred while applying a parameter map.  
--- Check the AccountEvent.findByAccount-InlineParameterMap.  
--- Check the parameter mapping for the 'fromDate' property.  
--- Cause: java.lang.NullPointerException
[Ljava.lang.StackTraceElement;@b036af
----------------------------------

Here is the xml:
    <select id="findByAccount" parameterClass="map" resultMap="AccountEventResult">
            SELECT * FROM user_event WHERE create_datetime <![CDATA[ < ]]> #fromDate:DATE# AND user_id=#id#
     </select>

----------------------------------

Now, if I pass a Date object instead of a Calendar in the map, it works with no issues. We do have a CalendarTypeHandler and if I pass a Calendar as a single field (parameterClass="java.util.Calendar") it works. For some reason passing a Calendar in a parameter Map just doesn't work. 

Any hints?

_________________________________________________________________
See how Windows Mobile brings your life together—at home, work, or on the go.
http://clk.atdmt.com/MRT/go/msnnkwxp1020093182mrt/direct/01/

RE: Calendars in paramter Maps not working

Posted by I L <is...@hotmail.com>.
Thanks Jeff, I'll give that a shot!



Date: Fri, 5 Sep 2008 13:01:44 -0500
From: jeffgbutler@gmail.com
To: user-java@ibatis.apache.org
Subject: Re: Calendars in paramter Maps not working

Specify your Calendar type handler directly like this:
 
<select id="findByAccount" parameterClass="map" resultMap="AccountEventResult">
  SELECT * FROM user_event WHERE create_datetime <![CDATA[ < ]]> #fromDate,handler=com.foo.CalendarTypeHandler# AND user_id=#id#

</select>

Things get a little funky when there's a Map involved - iBATIS must not be finding the type handler mapping.
 
Jeff Butler


On Fri, Sep 5, 2008 at 12:43 PM, I L <is...@hotmail.com> wrote:


Hi guys,

Let me just start by saying this is an awesome project! We were using hibernate which ended up being too complicated for what we needed. We switched to ibatis and it fit like a glove. Keep up the good work!



I am having one issue with maps and calendars. I am passing a Java Map as a parameter to the <select> entity. It is a map of objects and has two key-value pair. One is a String and the other is a Calendar:


String id => "3333"
Calendar fromDate => Java Calendar

The problem is that ibatis is throwing this error:
----------------------------------
--- The error occurred in com/blahblah/config/AccountEvent.xml.  

--- The error occurred while applying a parameter map.  
--- Check the AccountEvent.findByAccount-InlineParameterMap.  
--- Check the parameter mapping for the 'fromDate' property.  
--- Cause: java.lang.NullPointerException

[Ljava.lang.StackTraceElement;@b036af
----------------------------------

Here is the xml:
    <select id="findByAccount" parameterClass="map" resultMap="AccountEventResult">

            SELECT * FROM user_event WHERE create_datetime <![CDATA[ < ]]> #fromDate:DATE# AND user_id=#id#
     </select>

----------------------------------

Now, if I pass a Date object instead of a Calendar in the map, it works with no issues. We do have a CalendarTypeHandler and if I pass a Calendar as a single field (parameterClass="java.util.Calendar") it works. For some reason passing a Calendar in a parameter Map just doesn't work. 


Any hints?


See how Windows Mobile brings your life together—at home, work, or on the go. See Now


_________________________________________________________________
See how Windows Mobile brings your life together—at home, work, or on the go.
http://clk.atdmt.com/MRT/go/msnnkwxp1020093182mrt/direct/01/

Re: Calendars in paramter Maps not working

Posted by Jeff Butler <je...@gmail.com>.
Specify your Calendar type handler directly like this:

<select id="findByAccount" parameterClass="map"
resultMap="AccountEventResult">
  SELECT * FROM user_event WHERE create_datetime <![CDATA[ < ]]>
#fromDate,handler=com.foo.CalendarTypeHandler# AND user_id=#id#
</select>
Things get a little funky when there's a Map involved - iBATIS must not be
finding the type handler mapping.

Jeff Butler

On Fri, Sep 5, 2008 at 12:43 PM, I L <is...@hotmail.com> wrote:

> Hi guys,
>
> Let me just start by saying this is an awesome project! We were using
> hibernate which ended up being too complicated for what we needed. We
> switched to ibatis and it fit like a glove. Keep up the good work!
>
> I am having one issue with maps and calendars. I am passing a Java Map as a
> parameter to the <select> entity. It is a map of objects and has two
> key-value pair. One is a String and the other is a Calendar:
>
> String id => "3333"
> Calendar fromDate => Java Calendar
>
> The problem is that ibatis is throwing this error:
> ----------------------------------
> --- The error occurred in com/blahblah/config/AccountEvent.xml.
> --- The error occurred while applying a parameter map.
> --- Check the AccountEvent.findByAccount-InlineParameterMap.
> --- Check the parameter mapping for the 'fromDate' property.
> --- Cause: java.lang.NullPointerException
> [Ljava.lang.StackTraceElement;@b036af
> ----------------------------------
>
> Here is the xml:
>     <select id="findByAccount" parameterClass="map"
> resultMap="AccountEventResult">
>             SELECT * FROM user_event WHERE create_datetime <![CDATA[ < ]]>
> #fromDate:DATE# AND user_id=#id#
>      </select>
>
> ----------------------------------
>
> Now, if I pass a Date object instead of a Calendar in the map, it works
> with no issues. We do have a CalendarTypeHandler and if I pass a Calendar as
> a single field (parameterClass="java.util.Calendar") it works. For some
> reason passing a Calendar in a parameter Map just doesn't work.
>
> Any hints?
>
> <http://windowslive.com/connect/post/jamiethomson.spaces.live.com-Blog-cns%21550F681DAD532637%215295.entry?ocid=TXT_TAGLM_WL_domore_092008>
> ------------------------------
> See how Windows Mobile brings your life together—at home, work, or on the
> go. See Now <http://clk.atdmt.com/MRT/go/msnnkwxp1020093182mrt/direct/01/>
>