how to get a cayenne object through SqlSelectQuery

From: wwlo..itao.com
Date: Fri Nov 14 2003 - 20:58:51 EST

  • Next message: Andrus Adamchik: "Re: how to translate a sqlselectquery to correct object?"

    hi!
        I want to get a CayenneObject using SqlSelectQuery, my source code like this:

        ObjEntity ent = MYDataContext.getDataContext().getEntityResolver().lookupObjEntity(entityName);
        SqlSelectQuery ssq = new SqlSelectQuery(ent, sql);
        List result = MYDataContext.getDataContext().performQuery(ssq);
        if (result.size() == 0)
            return null;

        for (Iterator it = result.iterator(); it.hasNext();) {
            Map m = (Map) it.next();
            Object o = MyDataContext.getDataContext().objectFromDataRow(ent, m, false);
        }

        At last, I failed to got the correct object, if the variable is java.sql.date, then the ClassCaseException
    is thrown as the Object give me a java.util.date.

    Jeffery Lou
    2003-11-15



    This archive was generated by hypermail 2.0.0 : Fri Nov 14 2003 - 20:55:59 EST