Apache Cayenne performQuery结果列表演员

时间:2014-05-15 09:08:51

标签: list orm generic-list apache-cayenne

我正在使用3.0 Apache Cayenne, 我怎么能在Eclipse中省略@SuppressWarnings("未经检查")来获得这样简单的代码:

public List<Some> getSomes() {
    SelectQuery select = new SelectQuery(Some.class);
    List<Some> somes = dbContext.performQuery(select);
    return somes;
}

我找不到任何解决方案,是因为(我认为)performQuery会返回一个对象列表吗?

1 个答案:

答案 0 :(得分:0)

查询中的泛型是自Cayenne 3.2以来的一项功能。在3.2中,您将运行这样的查询,获得类型安全的结果:

SelectQuery<Some> select = new SelectQuery<>(Some.class);
List<Some> somes = dbContext.select(select);

但如果使用3.0,则会出现“未经检查”的警告。没有办法解决这个问题。

相关问题