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,
Clive
Here are the simplified versions of the relevant files:
# SqlMapConfig #
<sqlMapConfig>
<transactionManager type="JDBC">
<dataSource type="SIMPLE">
<property name="JDBC.Driver"
value="oracle.jdbc.driver.OracleDriver"/>
<property name="JDBC.ConnectionURL "
value="jdbc:oracle:oci:@stgods"/>
<property name="JDBC.Username" value="XXX"/>
<property name="JDBC.Password" value="ZZZ"/>
</dataSource>
</transactionManager>
<sqlMap resource="User.xml"/>
</sqlMapConfig>
# User.xml #
<select id='simpleTest' resultClass='User'>
SELECT user_name as userName FROM Users WHERE user_id = 1
</select>
# 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());
reader.close();
} catch (Exception e) {
e.printStackTrace();
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.