我从jOOQ Result
中得到一个fetch()
,然后将其变成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 );
任何帮助,将不胜感激!
谢谢!
编辑(16-NOV-2015 / 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
? 最佳答案
您不能实例化ResultsImpl
内部类,因为它是package-private。
除非您想使用反射(不要),否则请使用
DSL.using(configuration).newResult(cursorFields);