how to translate a sqlselectquery to correct object?

From: wwlo..itao.com
Date: Fri Nov 14 2003 - 12:35:45 EST

  • Next message: Craig Ziesman: "Inheritance?"

    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);
        }

        As myEntity have a field whose type is java.sql.Date, in the returned Object o, I got a java.util.Date
    for the corresponding field.
        I read cayenned source, cayenne convert this using javaTypes and dbAttributes in the ResultDescriptor
    class, but I did not find an easy way to reach my goal.
        Can you help me? thanks for your reading and sorry for my poor english!

    Jeffery Lou
    2003-11-15



    This archive was generated by hypermail 2.0.0 : Fri Nov 14 2003 - 12:32:43 EST