cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Savva Kolbachev (JIRA)" <j...@apache.org>
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
                 URL: https://issues.apache.org/jira/browse/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|https://issues.apache.org/jira/browse/CAY-1626]
to the ExtendedType.

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

	<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"/>
	</obj-entity>
{code}

And I got java.util.Date instead of org.joda.time.DateTime for column DATETIME1 AS D by the
code below.
{code}
        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();
        resultDescriptor.addEntityResult(jodaResult);
        resultDescriptor.addColumnResult("D");

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

        List<Object[]> dataList = context.performQuery(query);
        for (Object[] data : dataList) {
            System.out.println(data[0].getClass());
            System.out.println(data[1].getClass());
        }
{code}

{noformat}
class org.example.cayenne.persistent.Joda
class java.util.Date
{noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message