ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brandon Goodin <brandon.goo...@gmail.com>
Subject Problem with primitive parameters
Date Tue, 19 Apr 2005 22:51:18 GMT
The conversation got moved off the list. Thought i'd put it back on.

---------- Forwarded message ----------
From: Brandon Goodin <brandon.goodin@gmail.com>
Date: Apr 19, 2005 4:50 PM
Subject: Re: Problem with primitive parameters
To: Tom Cassimon <tom.cassimon@gmail.com>


I'll run the tests against JDK 1.5 tonight and see what we com up with.

Brandon

On 4/19/05, Tom Cassimon <tom.cassimon@gmail.com> wrote:
> I've allready tried that, it gives no errors but returns null instead
> of a JavaBean.
> I know for sure the SQL statement should return valid data, but it
> doesn't with the string property, if i use the user_id it does work.
> He seems to have a problem with strings. I can't figure it out.
>
> Regards,
>
> Tom Cassimon
>
> On 4/20/05, Brandon Goodin <brandon.goodin@gmail.com> wrote:
> > You are specifying a resultClass and a resultMap. You should only
> > define one or the other. As far as passing in primitives. you should
> > be able to use the #value# syntax withouth issue. The default type
> > aliases are as such and are case sensitive. To specify this as a
> > parameter type you would use parameterClass="int" etc...
> >
> > string
> > byte
> > long
> > short
> > int
> > integer
> > double
> > float
> > boolean
> > date
> > decimal
> > object
> > map
> > hashmap
> > list
> > arraylist
> > collection
> > iterator
> >
> > Brandon
> >
> > On 4/19/05, Tom Cassimon <tom.cassimon@gmail.com> wrote:
> > > Okay,
> > >
> > > i'll put it there, meanwhile is there anybody who can think of some
> > > fix to get around this problem ?
> > >
> > > On 4/20/05, Brandon Goodin <brandon.goodin@gmail.com> wrote:
> > > > I'd hate to see this get lost. Can you place this into JIRA? We can
> > > > track it more fully there. This is most likely related to JDK 1.5 and
> > > > ibatis compatibility. We have not yet addressed compatibilities.
> > > >
> > > > Thanks,
> > > > Brandon
> > > >
> > > > On 4/19/05, Tom Cassimon <tom.cassimon@gmail.com> wrote:
> > > > > Hi,
> > > > >
> > > > > i'm currently working on a web application that uses iBATIS in Java
(
> > > > > JDK 1.5 ), but i ran into a problem and tried to fix it in a little
> > > > > test application, but no succes.
> > > > >
> > > > > The first problem is that the attribute parameter, to use primitive
> > > > > parameters ( according to the developer guide ), is not included
in
> > > > > the dtd ( http://www.ibatis.com/dtd/sql-map-2.dtd ). So i surfed
the
> > > > > internet and found examples where they used primitive parameters
and
> > > > > they didn't use any of the parameter attributes. But that doesn't
work
> > > > > either. I've also tried parameterClass="string" with no succes.
> > > > >
> > > > > I've also played with the database types, first it were VARCHAR2's
now
> > > > > it are CHAR's, the db is an Oracle 9.2.0.4 btw. Now i have an sql
> > > > > query with a where clause that compares a string as you can see in
> > > > > User.xml but i also tried with the user_id and then the sql query
> > > > > returns an result. If i use the Name in het where clause like it
is
> > > > > now, it returns null. Does anybody has any idea why ?
> > > > >
> > > > > Db Table:
> > > > >
> > > > > Create table Users (
> > > > > User_id numeric[10] primary key,
> > > > > Name Char[100] unique,
> > > > > Password Char[100] );
> > > > >
> > > > > My sqlMapConfig.xml:
> > > > >
> > > > > <?xml version="1.0" encoding="UTF-8" ?>
> > > > > <!DOCTYPE sqlMapConfig
> > > > >   PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN"
> > > > >   "http://www.ibatis.com/dtd/sql-map-config-2.dtd">
> > > > >
> > > > > <sqlMapConfig>
> > > > >
> > > > > <settings
> > > > >         cacheModelsEnabled="false"
> > > > >         maxRequests="32"
> > > > >         maxSessions="10"
> > > > >         maxTransactions="5"
> > > > > />
> > > > >
> > > > > <transactionManager type="JDBC">
> > > > >         <dataSource type="SIMPLE">
> > > > >                 <property name="JDBC.Driver"                 
                          value="oracle.jdbc.driver.OracleDriver"/>
> > > > >                 <property name="JDBC.ConnectionURL"
> > > > >                                 value="jdbc:oracle:thin:@localhost:1521:virodb"/>
> > > > >                 <property name="JDBC.Username"               
                          value="vbapp"/>
> > > > >                 <property name="JDBC.Password"               
                          value="vbapp"/>
> > > > >                 <property name="JDBC.DefaultAutoCommit"      
                  value="yes"/>
> > > > >                 <property name="Pool.MaximumActiveConnections"
         value="10"/>
> > > > >                 <property name="Pool.MaximumIdleConnections" 
          value="5"/>
> > > > >         </dataSource>
> > > > > </transactionManager>
> > > > >
> > > > > <sqlMap resource="db/sql/sqlmap/User.xml"/>
> > > > > <sqlMap resource="db/sql/sqlmap/Message.xml"/>
> > > > >
> > > > > </sqlMapConfig>
> > > > >
> > > > > My User.xml:
> > > > >
> > > > > <?xml version="1.0" encoding="UTF-8" ?>
> > > > > <!DOCTYPE sqlMap
> > > > >   PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN"
> > > > >   "http://www.ibatis.com/dtd/sql-map-2.dtd">
> > > > >
> > > > > <sqlMap namespace="User">
> > > > >
> > > > > <resultMap id="User" class="db.bean.User">
> > > > >         <result property="id"           column="USER_ID"     
          javaType="int"          jdbcType="NUMERIC[11]"/>
> > > > >         <result property="user"
> > > > >         column="NAME"                   javaType="string"       jdbcType="CHAR[100]"/>
> > > > >         <result property="password"     column="PASSWORD"    
          javaType="string"       jdbcType="CHAR[100]"/>
> > > > > </resultMap>
> > > > >
> > > > > <select id="getUserbyName" resultMap="User" resultClass="db.bean.User">
> > > > >         SELECT * FROM users WHERE name = #value#
> > > > > </select>
> > > > >
> > > > > </sqlMap>
> > > > >
> > > > > My Java file:
> > > > >
> > > > >                 reader = Resources.getResourceAsReader("db/sql/sqlmap/SqlMapConfig.xml");
> > > > >                 sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
> > > > >                 user = (User) sqlMap.queryForObject("getUserbyName",username);
> > > > >                 if ( password != user.getPassword() ) <-- NullpointerException
( so
> > > > > the previous line returns null )
> > > > >                 {
> > > > >                         throw new Exception();
> > > > >                 }
> > > > >
> > > >
> > >
> >
>

Mime
View raw message