Hi all,
I am a happy ibatis user for years and now I have encountered a strange
thing.
I have Ibatis build with jdk 1.5.0_16 on my Windows XP.
When updating with any of the 4 abator generated stubs on either jdk 1.5 or
1.6 I encounter *no* problems on a windows XP box.
When I deploy everthing to a Linux box I get the weirdest errors from the
Driver.
abatorgenerated_updateByExampleSelective & abatorgenerated_updateByExample
both give;
com.ibatis.common.jdbc.exception.NestedSQLException:
--- The error occurred while applying a parameter map.
--- Check the
vdprre.abatorgenerated_updateByExampleSelective-InlineParameterMap.
--- Check the statement (update failed).
--- Cause: java.sql.SQLException: [unixODBC][INTERCHAIN][UNIMS-ODBC] [UNIMS]
Invoeren of wijzigen: Duplikaat in index!
*insert or update : duplicate in index *
updateByPrimaryKeySelective & updateByPrimaryKey inputs the wrong data;
{conn-100231} Preparing Statement: update vdprre
set vdperc = ? , vdmuwe =
? where relnr = ? and artgrf = ? and vdweek =
? and vdsort = ?
{pstm-100232} Executing Statement: update vdprre
set vdperc = ? , vdmuwe =
? where relnr = ? and artgrf = ? and vdweek =
? and vdsort = ?
{pstm-100232} Parameters: [11, 200847, 131505, 310, 200852, PGE55]
{pstm-100232} Types: [java.lang.Short, java.lang.Integer, java.lang.Integer,
java.lang.Short, java.lang.Integer, java.lang.String]
Returned connection 15529415 to pool.
While I try to update vdperc = 12 ,vdmuwe = *20*0844 the data becomes;
relnr artgrf vdweek vdsort vdperc vdmuwe
131505 310 200852 PGE55 *null* *20*
131505 310 200852 PGE65 *null* *20*
Note: there is some difference in the XP logging (spacing)?
{conn-100021} Preparing Statement: update vdprre set
vdperc=?,vdmuwe=? where relnr = ? and artgrf = ? and vdweek = ? and
vdsort = ?
{pstm-100022} Executing Statement: update vdprre set
vdperc=?,vdmuwe=? where relnr = ? and artgrf = ? and vdweek = ? and
vdsort = ?
{pstm-100022} Parameters: [11, 200847, 131505, 310, 200852, PGE55]
{pstm-100022} Types: [java.lang.Short, java.lang.Integer, java.lang.Integer,
java.lang.Short, java.lang.Integer, java.lang.String]
<update id="abatorgenerated_updateByPrimaryKeySelective"
parameterClass="nl.pfm.vdn.ds.vdn.model.AanvoerVerwachtingRegel">
update vdprre
<dynamic prepend="set">
<isNotNull prepend="," property="percentage">
vdperc = #percentage:NUMERIC#
</isNotNull>
<isNotNull prepend="," property="mutatieWeek">
vdmuwe = #mutatieWeek:NUMERIC#
</isNotNull>
</dynamic>
where relnr = #relatieNummer:NUMERIC#
and artgrf = #groepFinancieel:NUMERIC#
and vdweek = #weekNummer:NUMERIC#
and vdsort = #sortering:VARCHAR#
</update>
Where as hardcoded values will be updated correctly
<update id="abatorgenerated_updateByPrimaryKeySelective"
parameterClass="nl.pfm.vdn.ds.vdn.model.AanvoerVerwachtingRegel">
update vdprre
set vdperc = 12 ,vdmuwe = 200844
here relnr = #relatieNummer:NUMERIC#
and artgrf = #groepFinancieel:NUMERIC#
and vdweek = #weekNummer:NUMERIC#
and vdsort = #sortering:VARCHAR#
</update>
Swapping the set columns doesn't change this behaviour set vdmuwe = 200844,
vdperc = 12.
Could this have something to do with a xmlparser ?
Can anyone help me putting me on the right track or give me ways to get
closer to the solution.
Because i am desperately stuck at the moment.
I even found more erroneus data (null & chopped) but kept it for brevity.
Thanks and if someone needs more input just let me know,
Corne
*Below my testing code;
* Integer telerNummer = new Integer(131505);
Short productNummer = new Short("310");
Integer weekNummer = new Integer(200852);
String sorteringNaam = "PGE55";
Integer mutatieDatum = new Integer(200847);
Short percentage = new Short("11");
Connection conn = java.sql.DriverManager.*getConnection*(driverURL, user,
password);
PreparedStatement ps = conn.prepareStatement(sql);
ps.setShort(1, percentage);
ps.setInt( 2, mutatieDatum);
ps.setInt(3, telerNummer);
ps.setShort(4, productNummer);
ps.setInt(5, weekNummer);
ps.setString(6, sorteringNaam);
int retval = ps.executeUpdate();
System.out.println("UPDATED RECORDS:" + retval);
AanvoerVerwachtingRegel record = new AanvoerVerwachtingRegel();
record.setRelatieNummer(telerNummer);
record.setWeekNummer(weekNummer);
record.setGroepFinancieel(productNummer);
record.setSortering(sorteringNaam);
record.setMutatieWeek(mutatieDatum);
record.setPercentage(percentage);
SqlMapClient vdn_SqlMapClient = VDN_SqlMapClient.getSqlMapInstance();
AanvoerVerwachtingRegelDAO aanvoerVerwachtingRegelDAO = new
AanvoerVerwachtingRegelDAOImpl(vdn_SqlMapClient);
try {
int result1 =
aanvoerVerwachtingRegelDAO.updateByPrimaryKeySelective(record);
System.out.println("UPDATED RECORDS updateByPrimaryKeySelective:" +
result1);
} catch (Exception e) {
e.printStackTrace();
}
try {
record.setSortering("PGE65");
int result2 = aanvoerVerwachtingRegelDAO.updateByPrimaryKey(record);
System.out.println("UPDATED RECORDS updateByPrimaryKey:" + result2);
} catch (Exception e) {
e.printStackTrace();
}
AanvoerVerwachtingRegelExample example = new
AanvoerVerwachtingRegelExample();
AanvoerVerwachtingRegelExample.Criteria criteria =
example.createCriteria();
criteria = criteria.andRelatieNummerEqualTo(telerNummer);
criteria = criteria.andGroepFinancieelEqualTo(productNummer);
criteria = criteria.andWeekNummerEqualTo(weekNummer);
criteria = criteria.andSorteringEqualTo(sorteringNaam);
try {
int result3 = aanvoerVerwachtingRegelDAO.updateByExample(record,
example);
System.out.println("UPDATED RECORDS updateByExample:" + result3);
} catch (Exception e) {
e.printStackTrace();
}
try {
int result4 =
aanvoerVerwachtingRegelDAO.updateByExampleSelective(record, example);
System.out.println("UPDATED RECORDS updateByExampleSelective:" +
result4);
} catch (Exception e) {
e.printStackTrace();
}