Hi

I do not really know who to send this to but hopefully somebody who can change this 
will read this.


I have created a PreparedStatement using BasePeer.doPSSelect and I have noticed a 
problem in its source when the database is Sybase, it works fine on MySQL.

I have a primary key which is of type INT but I am getting a SybSQLException : 
"Implicit conversion from datatype 'CHAR' to 'INT' is not allowed", as I have only one 
column of type INT I know it is definitely this column.

I looked at the code for BasePeer.doPSSelect and I think I see the problem.

for (int i = 0; i < params.size(); i++)
            {
                Object param = params.get(i);
                if (param instanceof java.sql.Date)
                {
                    stmt.setDate(i + 1, (java.sql.Date)param);
                }
                else
                {
                    stmt.setString(i + 1, param.toString());
                }
}


When setting the PreparedStatement params it assumes if the param object is not an 
instance of Date that it must be a string which is not always true. I think here we 
need a further check something like

                if (param instanceof Integer)
                {
                    stmt.setInt(i + 1, param.IntValue());
                }


This amendment will ,I suspect, cause changes to be required in the methods 
BasePeer.createPreparedStatement and Criteria.Criterion.appendPsTo

Rgrds
John


#--------------------------------------
# John Colvin  [EMAIL PROTECTED]
#
# OpenConnect(Ireland) Ltd
#
# Tel    : 0044(0) 28 93329321
# Mobile : 0044 (0)786 6859764
#--------------------------------------


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.281 / Virus Database: 149 - Release Date: 18/09/2001

Reply via email to