按日期查询实体时出错

时间:2013-05-30 13:03:37

标签: java google-app-engine jpa

我正在尝试执行查询,该查询会选择超过1天的所有实体:

@Entity
public class Foo {
    // other stuff
    @Temporal(TemporalType.TIMESTAMP)
    private Date myDate;
    // getters, setters, etc.pp.
}


// in my DAO class:
Date yesterday = new Date(new Date().getTime()-24*60*60*1000);
TypedQuery<Foo> query = mgr.createQuery("SELECT f FROM Foo f WHERE f.myDate < :dateParam", Foo.class);
query.setParameter("dateParam", yesterday); // also tried adding additional TemporalType.TIMESTAMP parameter ...

当这件事被执行时,它会说明"java.lang.IllegalArgumentException: Type (\"org.datanucleus.query.evaluator.InMemoryQueryResult\") is not that of an entity but needs to be for this operation"
我的查询有问题吗?或者我处理日期的方式?

根据请求:persistence.xml

<?xml version="1.0" encoding="UTF-8" ?>
<persistence>

    <persistence-unit name="transactions-optional">
        <provider>org.datanucleus.api.jpa.PersistenceProviderImpl</provider>
        <properties>
            <property name="datanucleus.NontransactionalRead" value="true"/>
            <property name="datanucleus.NontransactionalWrite" value="true"/>
            <property name="datanucleus.ConnectionURL" value="appengine"/>
        </properties>
    </persistence-unit>
</persistence>

0 个答案:

没有答案