ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rashmi Dave" <rash...@persistent.co.in>
Subject RE: NPE with iBATIS - queryForObject
Date Sat, 21 Jan 2006 11:15:32 GMT
Thanks so much for this Jeff. Sadly, I am new to both Java and iBATIS. I am
learning though. 

 

This is working now. 

 

:-)

~Rashmi

 

  _____  

From: Jeff Butler [mailto:jeffgbutler@gmail.com] 
Sent: Friday, January 20, 2006 10:26 PM
To: user-java@ibatis.apache.org
Subject: Re: NPE with iBATIS - queryForObject

 

You are not accessing the DAO correctly (see the DAO manual, page 8).  This
is the proper way to gain access to a DAO implementation with iBATIS DAO:

 

UsersDAO usersdao = daoManager.getDao(UsersDAO.class);


If you still have a problem after making this fix, then please send more
specifics about the problem.

 

Jeff Butler

 

P.S. - a good rule of thumb in Java is that you should never use "new" with
any class that has "Impl" in the name.  "Impl" is a good indication that
there is a factory somewhere that is responsible for creating the object. 

 

 

 

On 1/20/06, Rashmi Dave <rashmid@persistent.co.in> wrote: 

We have used ABATOR to generate DAO classes for tables in Oracle.
The SQLMap.xml generated by abator is unchanged. I have the following 
daoconfig

<daoConfig>
<context id="sqlmap">
<transactionManager type="SQLMAP">
<property name="SqlMapConfigResource" value=
  "com/eobone/uam/dblayer/impl/sqlmap/EOBNE_USERS_SqlMap.xml"/> 
</transactionManager>
<dao interface="com.uam.dblayer.dao.UsersDAO"
  implementation=
  "com.uam.dblayer.dao.UsersDAOImpl"/>
</context>
</daoConfig>



Code to call this

// TODO Auto-generated method stub
       Reader reader=
           Resources.getResourceAsReader("daoConfig.xml");
       daoManager =
           DaoManagerBuilder.buildDaoManager (reader);
               usersdao = new UsersDAOImpl(daoManager);
               UsersKey ukey = new UsersKey();
           ukey.setUserId(new BigDecimal(1));
           Users users = null;
           users = usersdao.selectByPrimaryKey(ukey);

The exception occurs at the selectByPrimaryKey. I am not sure what is wrong.
Any pointers on this please ASAP would be very helpful.

TIA

~Rashmi

 


Mime
View raw message