Stored Procedure Date casting problem...

From: Michal Kozlowski (mkozlowsk..MVProjects.com)
Date: Wed Apr 06 2005 - 13:54:44 EDT

  • Next message: Fredrik Liden: "Testing ExpressionFactory for null values"

    Hi everyone,
    I'm loving the new SQL Server generatePK feature rith the jTDS driver, works awesome.

    Now my problem is I create a stored procedure that I want to generate a data object from, the stored procedure is in the modeler, and I also generated a stored procedure query that would allow me to fetch data objects. Now the data object that I'm getting has a sql.Date attribute which works if I just do a Select Query using cayenne like so...

        Expression qualifier = ExpressionFactory.matchDbExp("ProjectId", "Z00451");
        qualifier = qualifier.andExp(ExpressionFactory.matchDbExp("UserId", "NGO001"));
        qualifier = qualifier.andExp(ExpressionFactory.matchDbExp("UnitId", "020"));

        SelectQuery query = new SelectQuery(ActualConnected.class, qualifier);
        List actuals = getDataContext().performQuery(query);
        return actuals;

    When I do the same thing with a stored procedure I get an error from a cast that is trying to cast a util.Date to sql.Date which cannot be done. Is there any way to prevent this cast from happening automatically?

        ProcedureQuery query = (ProcedureQuery) getDataContext().getEntityResolver().lookupQuery("getUserActualsQuery");
        query.addParameter(..rojectID","Z00451");
        query.addParameter(..serID", "NGO001");
        query.addParameter(..nitID", "020");
        return getDataContext().performQuery(query);

    The error happens here in the data object that is trying to be read ...

        public java.sql.Date getDate() {
            return (java.sql.Date)readProperty("date");
        }

    Thanks for any information to get this working, I'm wondering if there is any way to prevent the stored procedure result from being cast to a util.Date and make it go into a sql.Date object

    Cheers
    Mike

    Developer/Database Administrator
    IMV Projects Inc.
    (403) 770-7552

    It is a painful thing
    To look at your own trouble and know
    That you yourself and no one else has made it
      - Sophocles, Ajax



    This archive was generated by hypermail 2.0.0 : Wed Apr 06 2005 - 13:56:30 EDT