You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ibatis.apache.org by "Tom Cassimon (JIRA)" <ib...@incubator.apache.org> on 2005/04/20 00:29:24 UTC
[jira] Created: (IBATIS-114) Problem with primitive parameters
Problem with primitive parameters
---------------------------------
Key: IBATIS-114
URL: http://issues.apache.org/jira/browse/IBATIS-114
Project: iBatis for Java
Type: Bug
Components: SQL Maps
Environment: Using Eclipse 3.1.0 M5 under Linux
Reporter: Tom Cassimon
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();
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
[jira] Commented: (IBATIS-114) Problem with primitive parameters
Posted by "Brandon Goodin (JIRA)" <ib...@incubator.apache.org>.
[ http://issues.apache.org/jira/browse/IBATIS-114?page=comments#action_63261 ]
Brandon Goodin commented on IBATIS-114:
---------------------------------------
You select uses both a resultMap and a resultClass. You should only use the resultMap in this case. Remove the resultClass attribute from the select.
BAD:
<select id="getUserbyName" resultMap="User" resultClass="db.bean.User">
SELECT * FROM users WHERE name = #value#
</select>
GOOD (add parameterClass for good measure):
<select id="getUserbyName" parameterClass="string" resultMap="User">
SELECT * FROM users WHERE name = #value#
</select>
Also, i ran all of our tests using jdk 1.5 and it all worked perfectly fine.
> Problem with primitive parameters
> ---------------------------------
>
> Key: IBATIS-114
> URL: http://issues.apache.org/jira/browse/IBATIS-114
> Project: iBatis for Java
> Type: Bug
> Components: SQL Maps
> Environment: Using Eclipse 3.1.0 M5 under Linux
> Reporter: Tom Cassimon
>
> 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();
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
[jira] Commented: (IBATIS-114) Problem with primitive parameters
Posted by "Tom Cassimon (JIRA)" <ib...@incubator.apache.org>.
[ http://issues.apache.org/jira/browse/IBATIS-114?page=comments#action_63291 ]
Tom Cassimon commented on IBATIS-114:
-------------------------------------
Hi,
i did as you said and changed it to the select you proposed, but still a nullpointer. However i'm sure that the SQL should return a user. I don't see where the problem could be then. I've also tested it in eclipse under windows, it doesn't work either.
If somebody has a proposal or something.
The full project is available at http://cassimon.mine.nu/tom/vbapp.tar.gz
Maybe it's some other misconfiguration, i don't know.
> Problem with primitive parameters
> ---------------------------------
>
> Key: IBATIS-114
> URL: http://issues.apache.org/jira/browse/IBATIS-114
> Project: iBatis for Java
> Type: Bug
> Components: SQL Maps
> Environment: Using Eclipse 3.1.0 M5 under Linux
> Reporter: Tom Cassimon
>
> 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();
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
[jira] Closed: (IBATIS-114) Problem with primitive parameters
Posted by "Clinton Begin (JIRA)" <ib...@incubator.apache.org>.
[ http://issues.apache.org/jira/browse/IBATIS-114?page=all ]
Clinton Begin closed IBATIS-114:
--------------------------------
Assign To: Clinton Begin
Resolution: Invalid
This should be on the support mailing list.
> Problem with primitive parameters
> ---------------------------------
>
> Key: IBATIS-114
> URL: http://issues.apache.org/jira/browse/IBATIS-114
> Project: iBatis for Java
> Type: Bug
> Components: SQL Maps
> Environment: Using Eclipse 3.1.0 M5 under Linux
> Reporter: Tom Cassimon
> Assignee: Clinton Begin
>
> 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();
> }
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira