문제

I am using 3.0 Apache Cayenne, how can I ommit @SuppressWarnings("unchecked") in Eclipse for such simple code:

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

I cannot find any solution, is it because (I think) performQuery retuns an object List ?

도움이 되었습니까?

해결책

Generics in queries is a feature available since Cayenne 3.2. In 3.2 you'd run queries like this, getting type-safe results:

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

But there will be 'unchecked' warnings if you are using 3.0. There's no way around this.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top