Well... I don't know what to tell you. iBATIS isn't reporting an error, and doesn't often fail silently (if ever). You can try turning on logging and replace your main method with a unit test that has assertions like assertNotNull(userProfile);, which is cleaner than letting an NPE occur.
Clinton On Wed, Dec 30, 2009 at 2:18 AM, vishalj <vish...@ivycomptech.com> wrote: > > tha db table contains a row with id vakue of '1' which i am trying to query > .And also the same select statement is working fine > > Clinton Begin wrote: > > > > The NPE is coming from your main method (profile.getName()). It's not > > finding the profile record. It looks like iBATIS is working, but there's > > simply no data to be found, or the parameter is incorrect. > > > > Clinton > > > > On Tue, Dec 29, 2009 at 10:28 PM, vishalj <vish...@ivycomptech.com> > wrote: > > > >> > >> Hi, > >> I am using iBatis for the first time ,but no success yet.This is how my > >> setup looks like > >> > >> DB SCHEMA: > >> CREATE TABLE TEST_USERPROFILE > >> ( NAME VARCHAR2(20), > >> ID NUMBER > >> ) ; > >> > >> iBatis configuration.xml > >> <configuration> > >> <properties > >> resource="com/pg/ibatis/config/config.properties"></properties> > >> <typeAliases> > >> <typeAlias type="com.pg.beans.UserProfile" > >> alias="UserProfile"/> > >> </typeAliases> > >> <environments default="development"> > >> <environment id="development"> > >> <transactionManager type="JDBC" /> > >> <dataSource type="POOLED"> > >> <property name="driver" value="${driver}" > >> /> > >> <property name="url" value="${url}" /> > >> <property name="username" > >> value="${username}" /> > >> <property name="password" > >> value="${password}" /> > >> </dataSource> > >> </environment> > >> </environments> > >> <mappers> > >> <mapper > >> resource="com/pg/ibatis/config/UserProfileMapper.xml" /> > >> </mappers> > >> </configuration> > >> > >> UserProfileMapper.xml > >> <mapper namespace="com.pg.mappers.UserProfileMapper"> > >> <select id="selectUserProfile" parameterType="int" > >> resultType="UserProfile"> > >> SELECT * FROM TEST_USERPROFILE WHERE id=#{id} > >> </select> > >> </mapper> > >> > >> UserProfileMapper.java > >> public interface UserProfileMapper { > >> UserProfile selectUserProfile(int id); > >> } > >> > >> UserProfile.java > >> public class UserProfile { > >> String name; > >> int id; > >> public int getId() { > >> return id; > >> } > >> public void setId(int id) { > >> this.id = id; > >> } > >> public String getName() { > >> return name; > >> } > >> public void setName(String name) { > >> this.name = name; > >> } > >> > >> } > >> > >> Main method > >> String resource = "com/pg/ibatis/config/Configuration.xml"; > >> Reader reader = Resources.getResourceAsReader(resource); > >> SqlSessionFactory factory = new > SqlSessionFactoryBuilder() > >> .build(reader); > >> SqlSession session = factory.openSession(); > >> try { > >> UserProfileMapper mapper = > >> session.getMapper(UserProfileMapper.class); > >> UserProfile profile = > mapper.selectUserProfile(1); > >> System.out.println("PROFILE " + profile); > >> System.out.println(profile.getName()); > >> } finally { > >> session.close(); > >> } > >> > >> But i am getting NPE > >> PROFILE null > >> Exception in thread "main" java.lang.NullPointerException > >> at Main.main(Main.java:23) > >> -- > >> View this message in context: > >> > http://old.nabble.com/New-to-iBatis-facing-problem-to-get-started-tp26964254p26964254.html > >> Sent from the iBATIS - User - Java mailing list archive at Nabble.com. > >> > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: user-java-unsubscr...@ibatis.apache.org > >> For additional commands, e-mail: user-java-h...@ibatis.apache.org > >> > >> > > > > > > -- > View this message in context: > http://old.nabble.com/New-to-iBatis-facing-problem-to-get-started-tp26964254p26965432.html > Sent from the iBATIS - User - Java mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-java-unsubscr...@ibatis.apache.org > For additional commands, e-mail: user-java-h...@ibatis.apache.org > >