ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tom Cassimon <tom.cassi...@gmail.com>
Subject Problem with primitive parameters
Date Tue, 19 Apr 2005 11:23:14 GMT

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 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"


<transactionManager type="JDBC">
	<dataSource type="SIMPLE">
		<property name="JDBC.Driver" 						value="oracle.jdbc.driver.OracleDriver"/>
		<property name="JDBC.ConnectionURL"
		<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"/> 

<sqlMap resource="db/sql/sqlmap/User.xml"/>
<sqlMap resource="db/sql/sqlmap/Message.xml"/>


My User.xml:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMap 
  PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN"
<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]"/>

<select id="getUserbyName" resultMap="User" resultClass="db.bean.User">
	SELECT * FROM users WHERE name = #value#

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();

View raw message