Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/347.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何创建我自己的jOOQ结果?_Java_Sql_Jooq - Fatal编程技术网

Java 如何创建我自己的jOOQ结果?

Java 如何创建我自己的jOOQ结果?,java,sql,jooq,Java,Sql,Jooq,我从一个jOOQfetch()中得到了一个结果,我将其转换为一个集合,然后对其进行各种操作 然后我想把它转换回一个import org.jooq.Result。(我承认我想这样做是因为我想能够使用像formatCSV 及 formatJSON因此,如果有更好的方法来实现这一点,我愿意接受!) 但是,我很难弄清楚如何实例化新的结果。我尝试了几种不同的方法: // ResultImpl cannot be resolved to a type ResultImpl<R> newResu

我从一个jOOQ
fetch()
中得到了一个
结果
,我将其转换为一个
集合
,然后对其进行各种操作

然后我想把它转换回一个
import org.jooq.Result
。(我承认我想这样做是因为我想能够使用像
formatCSV
formatJSON
因此,如果有更好的方法来实现这一点,我愿意接受!)

但是,我很难弄清楚如何实例化新的
结果。我尝试了几种不同的方法:

// 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 );
//ResultImpl无法解析为类型
ResultImpl newResult1=newresultimpl(ctx.configuration(),cursorFields);
ResultImpl newResult2=newresultimpl(ctx.configuration(),cursorFields);
结果newResult3=newresultimpl();
//无法实例化类型结果
结果newResult4=新结果();
//类型org.jooq.impl.ResultsImpl不可见
配置;
// ... 将确保配置已正确初始化
Result newResult5=neworg.jooq.impl.ResultsImpl.ResultsImpl(配置);
任何帮助都将不胜感激

谢谢


编辑(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();
Result tempResult=null;
tempResult=getResults().into(getResults().fields());
tempResult.clear();
用于(缓冲区b:bufferPrimary)
tempResult.add(b.dataRecord);
返回tempResult.formatCSV();

我不喜欢tempResult得到所有记录只是为了清除它们。是否有方法将
.where(false)
添加到
.into
中?

您不能实例化
ResultsImpl
内部类,因为它是

除非您想使用反射(不要),否则请使用


我修改了原来的帖子来展示我最终得到了什么。。。我真的不喜欢,但似乎很管用。我不喜欢的是必须清除结果-效率很低。@danielc:有趣的解决方法:)你知道,你可以在这里回答你自己关于堆栈溢出的问题…“有没有办法将.where(false)添加到.into”-没有。对于这样的
where()
方法,似乎没有足够好的用例。。。。
DSL.using(configuration).newResult(cursorFields);