【发布时间】:2016-02-17 01:11:31
【问题描述】:
我有一个来自 jOOQ 的 fetch() 的 Result,我将其转换为 Collection,然后对其进行各种操作。
然后我想把它改回import org.jooq.Result。 (我承认我想这样做是因为我希望能够使用像 formatCSV 这样的功能
和
formatJSON 所以如果有更好的方法来实现这一点,我愿意接受!)
我在弄清楚如何实例化新的result 时遇到了麻烦。我尝试了几种不同的方法:
// ResultImpl cannot be resolved to a type
ResultImpl<R> newResult1 = new ResultImpl<R>( ctx.configuration(), cursorFields );
ResultImpl<Record2<Long, String>> newResult2 = new ResultImpl<Record2<Long, String>>( ctx.configuration(), cursorFields );
Result<Record2<Long, String>> newResult3 = new ResultImpl<Record2<Long, String>>();
// Cannot instantiate the type Result<Record2<Long,String>>
Result<Record2<Long, String>> newResult4 = new Result<Record2<Long, String>>();
// The type org.jooq.impl.ResultsImpl is not visible
Configuration configuration;
// ... would make sure configuration was properly initialized
Result newResult5 = new org.jooq.impl.ResultsImpl.ResultsImpl( configuration );
任何帮助将不胜感激!
谢谢!
编辑(2015 年 11 月 16 日/9:16aEST):
我是这样做的:
Result<Record> tempResult = null;
tempResult = getResults().into( getResults().fields() );
tempResult.clear();
for (Buffer b : bufferPrimary)
tempResult.add( b.dataRecord );
return tempResult.formatCSV();
我不喜欢 tempResult 获取所有记录只是为了清除它们。有没有办法将.where( false ) 添加到.into?
【问题讨论】:
-
“有没有办法将 .where(false) 添加到 .into” - 没有。这样的
where()方法似乎没有足够好的用例......