Hello,

to have the functionality to perform a select on a Date field I've been using  the 
"doPSSelect" of BasePeer.java. Unfortunatly this doesn't work for 
"java.sql.Timestamp". So I've made the follwing changes and it seems to work. I don't 
have complete understanding of the mechanism. Is this the correct place to make these 
changes - or is there a more simple machanism I don't see ?


I've made the following changes:

in BasePeer.java:
    public static Vector doPSSelect(Criteria criteria, DBConnection dbCon)
        throws Exception
    {
        Vector v = null;
        
        StringBuffer qry = new StringBuffer();
        Vector params = new Vector(criteria.size());
        
        createPreparedStatement (criteria, qry, params);
        
        PreparedStatement stmt = null;
        try
        {
            stmt = dbCon.getConnection().prepareStatement(qry.toString());

            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);
                }
                // !!!!!!!  leo change start (added)
                else if (param instanceof java.sql.Timestamp)
                {
                    stmt.setTimestamp(i + 1, (java.sql.Timestamp)param);
                }
                // !!!!!!!! leo change end
                ...

in Criteria.java , method "appendPsTo":

    /* orignal
    if (value instanceof java.util.Date)
    {
        params.add ( new java.sql.Date (((java.util.Date)value).getTime()) );
    }
    else if (value instanceof DateKey)
    {
        params.add ( new java.sql.Date (((DateKey)value).getDate().getTime()) );
    }
    */
    
    /* leo change start: Timestamp eingef�gt */
    if (value instanceof java.sql.Timestamp)
    {
        params.add ( value );
    }
    else if (value instanceof java.util.Date)
    {
        params.add ( new java.sql.Date (((java.util.Date)value).getTime()) );
    }
    else if (value instanceof DateKey)
    {
        params.add ( new java.sql.Timestamp (((DateKey)value).getDate().getTime()) );
    }
    /* leo change end */

Thanks for comments,
--
Leo

mailto:[EMAIL PROTECTED]
_______________________________________________________________
SecureNet GmbH
Intranet und Internet Solutions         Tel:  +49 89/32133-654
Frankfurter Ring 193a                   Fax:  +49 89/32133-699
80807 M�nchen, Germany                  http://www.secure-net.de

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to