Hello!
I am new to iBATIS and I have experienced a problem in the most simple
implementation of querying my database...
Here is the problem:
I have a database with some simple tables (the RDBMS is Sybase and I am using
also the appropriate JDBC driver for use with iBATIS), and I try to run a
simple query on one of them but while iBATIS seems to read all the rows of the
table, it fills up a list with objects that all of them contain the data from
the last row of the table... I run the same query with pure JDBC and I got the
correct results ... I have attached the xml and java code with this email, and
I also have put it below:
_______________________________________
The xml and java code are following :
(The object "RequestTemplateData" has the appropriate getters and setters, i
don;t think it needs to be listed)
The SqlMap piece:
__________________________________
<sqlMap namespace="TemplatesList">
<select id="getTemplatesList"
resultClass="gr.forthnet.staff.objects.RequestTemplateData">
<![CDATA[
select
RequestTemplateDataId as REQUESTTEMPLATEDATAID,
RequestTemplateId as REQUESTTEMPLATEID,
KeyId as KEYID,
Required as REQUIRED,
DefValue as DEFVALUE
from RequestTemplateData
]]>
</select>
__________________________________
The Java piece is here :
////////////////////////////////////////////////////////////////////////////////
// iBATIS SQL MAPS TEST AREA //
try {
String resource = "ibatis/SqlMapConfig.xml";
Reader reader = Resources.getResourceAsReader(resource);
SqlMapClient sqlMap = SqlMapClientBuilder.buildSqlMapClient(reader);
sqlMap.startTransaction();
List<RequestTemplateData> TList=
sqlMap.queryForList("getTemplatesList", null);
sqlMap.commitTransaction();
for (RequestTemplateData rtd : TList){
System.out.print(rtd.getREQUESTTEMPLATEDATAID() + " ~ ");
System.out.print(rtd.getREQUESTTEMPLATEID() + " ~ ");
System.out.print(rtd.getKEYID() + " ~ ");
System.out.print(rtd.getREQUIRED() + " ~ ");
System.out.println(rtd.getDEFVALUE() + "
\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ");
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
The result output in my console is (actually the last row of the table
RequestTemplateData) :
10 ~ 2 ~ 8 ~ 1 ~ null
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 ~ 2 ~ 8 ~ 1 ~ null
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 ~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ed please
let me know and I will send them!
Thank you
Dimitris
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
iBatisCode.rtf
Description: MS-Word document
