[英]How to create my own jOOQ result?
我有一個來自 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 );
任何幫助,將不勝感激!
謝謝!
這是我如何做到的:
Result<Record> tempResult = null; tempResult = getResults().into( getResults().fields() ); tempResult.clear(); for (Buffer b : bufferPrimary) tempResult.add( b.dataRecord ); return tempResult.formatCSV();
我不喜歡 tempResult 獲取所有記錄只是為了清除它們。 有沒有辦法將.into
.where( false )
添加到.into
?
您不能實例化ResultsImpl
內部類,因為它是package-private 。
除非你想訴諸使用反射(不要),使用
DSL.using(configuration).newResult(cursorFields);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.