ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Butler <jeffgbut...@gmail.com>
Subject Re: NPE with iBATIS - queryForObject
Date Fri, 20 Jan 2006 16:55:43 GMT
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