Question

I am new to ibatis,

i have written a small program in ibatis.

But i'm getting the below error. I tried in all way. I'm unaware of that how to resolve.

Could anyone tell me why this is occurring and whats the way to avoid this error?

Exception in thread "main" com.ibatis.common.exception.NestedRuntimeException: Error occurred.  Cause: com.ibatis.common.xml.NodeletException: Error parsing XML.  Cause: com.ibatis.common.exception.NestedRuntimeException: Error parsing XPath '/sqlMapConfig/sqlMap'.  Cause: com.ibatis.common.xml.NodeletException: Error parsing XML.  Cause: com.ibatis.common.exception.NestedRuntimeException: Error parsing XPath '/sqlMap/update'.  Cause: com.ibatis.common.beans.ProbeException: There is no READABLE property named 'first_name' in class 'Employee'
Caused by: com.ibatis.common.beans.ProbeException: There is no READABLE property named 'first_name' in class 'Employee'
Caused by: com.ibatis.common.exception.NestedRuntimeException: Error parsing XPath '/sqlMap/update'.  Cause: com.ibatis.common.beans.ProbeException: There is no READABLE property named 'first_name' in class 'Employee'
Caused by: com.ibatis.common.beans.ProbeException: There is no READABLE property named 'first_name' in class 'Employee'
Caused by: 
com.ibatis.common.beans.ProbeException: There is no READABLE property named 'first_name' in class 'Employee'

Code: Employee.java it contains getter and setter methods for first_name,last_name,id,salary

employeedao.java

public static void main()
{
Reader rd=Resources.getResourceAsReader("sql-maps-config.xml");
SqlMapClient smc = SqlMapClientBuilder.buildSqlMapClient(rd);
System.out.println("Going to read records.....");
 rec.setId(1);
           rec.setFirstName("Roma");
           smc.update("UserTEO.update", rec );
           System.out.println("Record updated Successfully ");

           System.out.println("Going to read records.....");
 List <employeedao> ems = (List<employeedao>)
           smc.queryForList("UserTEO.getAll", null);
           employeedao em = null;
           for (employedao e : ems) {
              System.out.print("  " + e.getId());
             // System.out.print("  " + e.getFirstName());
           //   System.out.print("  " + e.getLastName());
              System.out.print("  " + e.getSalary());
              em = e; 
              System.out.println("");
           }    

       System.out.println("Records Read Successfully ");
}

employee.xml

 <select id="getAll" resultClass="Employee">
   SELECT * FROM EMPLOYEE
</select>

<update id="update" parameterClass="Employee">
   UPDATE EMPLOYEE
   SET    first_name = #first_name#
   WHERE  id = #id#
</update>

</sqlMap>
Was it helpful?

Solution

The getter is

public String getFirstName()

So, the property is firstName, not first_name.

See http://docs.oracle.com/javase/tutorial/javabeans/writing/properties.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top