spring - 使用 Java Streams 时出现 Eclipselink 错误
问题描述
我正在尝试使用Java 8 Streams和JpaRepository从表中读取数据,但我遇到了一些问题。
知道我应该如何解决这个问题吗?
import org.eclipse.persistence.config.HintValues;
import org.eclipse.persistence.config.ResultSetConcurrency;
import org.eclipse.persistence.config.ResultSetType;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.QueryHints;
import org.springframework.stereotype.Repository;
import javax.persistence.QueryHint;
import java.util.stream.Stream;
import static org.eclipse.persistence.config.QueryHints.*;
@Repository
public interface CancelledDetailedHeaderRepository extends JpaRepository<Entity, Long> {
@QueryHints(value = {
@QueryHint(name = RESULT_SET_TYPE, value = ResultSetType.ForwardOnly),
@QueryHint(name = RESULT_SET_CONCURRENCY, value = ResultSetConcurrency.ReadOnly),
@QueryHint(name = JDBC_FETCH_SIZE, value = "" + 100),
@QueryHint(name = SCROLLABLE_CURSOR, value = HintValues.TRUE)
})
@Query("SELECT h" + " FROM #{#entityName} h " +
"WHERE h.status = ?1")
Stream<Entity> findAllByStatus(String status);
}
Eclipselink 属性:
@Override
protected Map<String, Object> getVendorProperties() {
HashMap<String, Object> map = new HashMap<String, Object>();
map.put("eclipselink.weaving", "false");
map.put("eclipselink.ddl-generation", "none");
map.put("eclipselink.query-results-cache", "false");
map.put("eclipselink.logging.logger", "JavaLogger");
map.put("eclipselink.logging.level", "FINE");
map.put("eclipselink.logging.level.sql", "FINE");
map.put("eclipselink.logging.parameters", "true");
map.put(PersistenceUnitProperties.BATCH_WRITING, BatchWriting.JDBC);
return map;
}
异常说明:
方法 [getContainerClass()] 不是调用对象 [ScrollableCursorPolicy(page size = 10)] 的有效方法
.
解决方案
推荐阅读
- python - 在 Python 中将十进制对象转换为科学计数法
- javascript - Passing data from java file to ajax
- mysql - MYSQL 创建摘要视图
- d3.js - D3 V4如何强制堆叠条的标签对小条可见?请回复我真的很努力
- algorithm - 什么算法适合寻找可能的匹配以形成一组 L 玩家?
- c# - Ctrl+M、Ctrl+M(键盘快捷键)无法按预期工作(VS-2015)
- react-native - React Native Animated.Value/Animated.timing 没有 Animated.View
- python - Django 模板:如何模拟 break 函数或 while 循环
- rxjs - 前 3 个项目延迟 1 秒,第四个项目延迟 4 秒
- c++ - 该标准对未对齐的内存访问有何规定?