Thanks so much for this Jeff. Sadly, I am new to both Java and iBATIS. I am learning though.

 

This is working now.

 

J

~Rashmi

 


From: Jeff Butler [mailto:[EMAIL PROTECTED]
Sent: Friday, January 20, 2006 10:26 PM
To: [email protected]
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 <[EMAIL PROTECTED]> 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

 

Reply via email to