Hibernate获取JasperRunManager的Connection对象 [英] Hibernate get Connection object for JasperRunManager

查看:152
本文介绍了Hibernate获取JasperRunManager的Connection对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在项目和Jasper 3.7.2中使用Hibernate 3.2.5为应用程序生成一些报告。

I'm using Hibernate 3.2.5 in a project and Jasper 3.7.2 to generate Some Reports for the application.

有没有办法获得连接来自HibernateSessionFactory对象的对象?我只想处理一个连接,因为此时我必须有一个ODBC连接的属性文件,它将通过JasperRunManager静态方法处理Jasper,还有Hibernate用于其他方面。

Is there any way to get a Connection Object from a HibernateSessionFactory Object? I wanna handle only one connection, because at this time I have to have a properties file for the ODBC connection that is gonna handle the Jasper through the JasperRunManager statics methods, and also Hibernate for other side.

这是我传递连接所需的方法:

This is the method I need to pass the connection:

byte[] net.sf.jasperreports.engine.JasperRunManager.runReportToPdf(InputStream inputStream, Map parameters, Connection conn) throws JRException

提前致谢。 :)

推荐答案

我遇到了与hibernate相同的问题4
这里是解决方案

I had the same problem with hibernate 4 and here is solution

Session ses = ...
final InputStream finalCompiledReportStream = compiledReportStream;
final OutputStream finalByteArrayOutputStream = byteArrayOutputStream;
ses.doWork(new Work() {
    public void execute(Connection connection) throws SQLException {
       try {
           JasperFillManager.fillReportToStream(finalCompiledReportStream, finalByteArrayOutputStream, parameters, connection);
       } catch (JRException e) {
           ReportAction.this.logger.error(e);
       }
    }
});

这篇关于Hibernate获取JasperRunManager的Connection对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆