문제

public static List<FieldOption> 
getFieldOptionListOfField(PersistenceManager pm, long fieldId) throws NoSuchFieldOptionException { 
    Query query = pm.newQuery(FieldOption.class);

    try {
        query.setFilter("this.fieldId == fieldId");
        query.declareParameters("long fieldId");
        query.setOrdering("orderId ascending");
        List<FieldOption> fieldOptions = (List<FieldOption>) query.execute(fieldId);
        logger.debug("fieldOptions = " + fieldOptions);
        return fieldOptions();
    } finally {
        query.closeAll();
    }
}

After execution of excute method 'fieldOptions' is having certain values. But after closeAll() the list becomes empty. Can you please suggest why it happens?

도움이 되었습니까?

해결책

The "List" returned after you end a transaction and close a PM is not a real List, but instead a lazy load list, that cannot lazy load once it has no connection to the datastore. Easiest option is put (copy) the query results into your own List before closing the txn/PM.

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