cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Savva Kolbachev (JIRA)" <>
Subject [jira] [Created] (CAY-2006) SQLTemplateAction doesn't consider javaType from #result directive
Date Sat, 25 Apr 2015 11:10:38 GMT
Savva Kolbachev created CAY-2006:

             Summary: SQLTemplateAction doesn't consider javaType from #result directive
                 Key: CAY-2006
             Project: Cayenne
          Issue Type: Bug
            Reporter: Savva Kolbachev
            Assignee: Savva Kolbachev
             Fix For: 4.0.M3

SQLTemplateAction doesn't consider javaType from #result directive when configurating RowDescriptorBuilder.
It put to RowDescriptorBuilder.typeOverrides only types from current ObjEntity and DbEntity.

So the following example doesn't work correctly.

I added Joda DateTimeType provided by John Huss in [CAY-1626|]
to the ExtendedType.

Than I created two DbEntities with fields of TIMESTAMP type and one dependent ObjEntity.
	<db-entity name="JODA">
		<db-attribute name="DATETIME" type="TIMESTAMP"/>
		<db-attribute name="ID" type="INTEGER" isPrimaryKey="true" isMandatory="true"/>
	<db-entity name="JODA1">
		<db-attribute name="DATETIME1" type="TIMESTAMP"/>

	<obj-entity name="Joda" className="org.example.cayenne.persistent.Joda" dbEntityName="JODA">
		<obj-attribute name="datetime" type="org.joda.time.DateTime" db-attribute-path="DATETIME"/>

And I got java.util.Date instead of org.joda.time.DateTime for column DATETIME1 AS D by the
code below.
        String sql = "SELECT j.ID, "
                + "#result('j.DATETIME' 'org.joda.time.DateTime' '' 'JODA.DATETIME'), "
                + "#result('DATETIME1' 'org.joda.time.DateTime' '' 'JODA1.DATETIME1') AS D
                + "FROM JODA j, JODA1";

        EntityResult jodaResult = new EntityResult(Joda.class);
        jodaResult.addDbField(Joda.ID_PK_COLUMN, "ID");
        jodaResult.addObjectField(Joda.DATETIME_PROPERTY, "DATETIME");

        SQLResult resultDescriptor = new SQLResult();

        SQLTemplate query = new SQLTemplate(Joda.class, sql);

        List<Object[]> dataList = context.performQuery(query);
        for (Object[] data : dataList) {

class org.example.cayenne.persistent.Joda
class java.util.Date

This message was sent by Atlassian JIRA

View raw message