ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmwalm <cmw...@yahoo.com>
Subject ueryForObject returns bean with null properties
Date Tue, 22 Jan 2008 21:37:48 GMT

Hi all,

I have a simple problem that I can't seem to get to the root of.  I have
searched the archives, the wiki and the SQL map guide with no success.  So,
if there is a previous post or other resource that will solve this problem I
would be grateful for a link or other help.

That being said, I am trying to perform a simple test select statement and
it returns a result class all the properties are null.  I have placed debug
statements in setter of the bean and I can see the setter is called by when
queryForObject() is invoked. I have also looked in to the the debug
statements from the result set proxy and I can see that the database has
returned the data.

What can possibly be going wrong?

Thanks in advance,


Here are the simplified versions of the relevant files:

# SqlMapConfig #
    <transactionManager type="JDBC">
        <dataSource type="SIMPLE">
            <property name="JDBC.Driver"
            <property name="JDBC.ConnectionURL "
            <property name="JDBC.Username" value="XXX"/>
            <property name="JDBC.Password" value="ZZZ"/>
    <sqlMap resource="User.xml"/>

# User.xml #
<select id='simpleTest' resultClass='User'>
    SELECT user_name as userName FROM Users WHERE user_id = 1

# User.java #
public class User implements java.io.Serializable {
    private String userName;

    public String getUserName() { return this.userName; }
    public void setUserName(String s) { this.userName = userName; }

# Test.java #
public class Test{
    private static SqlMapClient sqlMap;

    public static void main(String[] argv) {
        try {
            String resource = "SqlMapConfig.xml";
            Reader reader = Resources.getResourceAsReader(resource);
            sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
            Object o = sqlMap.queryForObject("simpleTest");
            System.out.println("object type: " + o.getClass().getName());
            User u = (User) o;
            System.out.println (u.getUserName());

        } catch (Exception e) {
            throw new RuntimeException("Error initialzing SQLMap." + e);
View this message in context: http://www.nabble.com/ueryForObject-returns-bean-with-null-properties-tp15029119p15029119.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.

View raw message