ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Goga, Murtaza" <murtaza.g...@trisyngroup.com>
Subject RE: Complex Properties problem
Date Tue, 16 Jan 2007 11:37:35 GMT
If you are using Spring, you might want to check if you are supplying a valid 'dataSource'
property to the SqlMapClientFactoryBean.  
I had seen similar behavior, and it turned out that the TransactionManager was not created
for the SqlMapExecutorDelegate.  The second query attempts to use a null txManager and it
cascades down to the error you are seeing.

-----Original Message-----
From: Witold Bołt [mailto:ja@houp.info] 
Sent: Sunday, January 14, 2007 4:35 PM
To: user-java@ibatis.apache.org
Subject: Complex Properties problem
Importance: Low

Hi!

I'm developing a simple Web app with Spring (2.0) and iBatis (2.2), and 
... got one strange problem with so called complex properties.

What I did was basically following the Developer guide (as on page 34, 
current stable version), and did:

<sqlMap namespace="foo">
     <resultMap id="User" class="foo.bar.User">
         <result property="id" column="id"  />
         <result property="login" column="login" />
     </resultMap>

     <resultMap id="Article" class="foo.bar.Article">
         <result property="id" column="id"  />
         <result property="author" column="user_id" select="getUser"/>
         <result property="title" column="title"  />
     </resultMap>
		
     <select id="getUser" parameterClass="int"  resultMap="User">
     	SELECT id,login FROM user WHERE id = #value#
     </select>

     <select id="getArticle" parameterClass="int" resultMap="Article">
     	SELECT id,user_id,title FROM object WHERE id = #value#
     </select>
</sqlMap>


User and Article classes are simple JavaBeans. Everything works without 
the select="getUser" in Article. I can get a selected User and Article. 
But I can not get them together. (I know that I could change this and do 
a select from two tables with some joins, but that is not the case - I 
want it the way it is.)

When the code is used as it's shown here, the first SQL statment is 
passed to the database (MySQL 5), and the second is not. Instead a Null 
Pointer Exception arise:

com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred in /org/kolor/cms/data/dao/ibatis/jcms-client.xml.
--- The error occurred while applying a result map.
--- Check the jcms-client.Article.
--- Check the result mapping for the 'author' property.
--- Cause: java.lang.NullPointerException
	at 
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:188)
	at 
com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForObject(GeneralStatement.java:104)
	at 
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:566)
	at 
com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:541)
	at 
com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessionImpl.java:106)
	at 
org.springframework.orm.ibatis.SqlMapClientTemplate$1.doInSqlMapClient(SqlMapClientTemplate.java:243)
	at 
org.springframework.orm.ibatis.SqlMapClientTemplate.execute(SqlMapClientTemplate.java:193)
	at 
org.springframework.orm.ibatis.SqlMapClientTemplate.queryForObject(SqlMapClientTemplate.java:241)
	at 
org.kolor.cms.data.dao.ibatis.IbatisClientDao.getArticle(IbatisClientDao.java:18)
	at 
org.kolor.cms.controler.ShowItemController.handleRequestInternal(ShowItemController.java:54)
...

(full log info and stack trace in attachment).

I'm sure that database is working well. The JDBC data source comes from 
the server (Apache Geronimo) database pool (and it's invoked through 
JNDI). And as I said - I can invoke getUser(1) alone, and getArticle(1) 
when this 'complex property' is removed.

I've tried running in different modes with and without lazy init, 
enchencments modes and so on.

How you got any idea what is wrong?

If you need any more code I can send it here.

Greetings,
-me.

-- 
--==--==----------------------
   Witold Bołt ::  ja@houp.info
gsm#660316053 :: www.houp.info

Mime
View raw message