title: Jasper report and hibernate annotations
body: <p>I'm Using Hibernate with an H2 database, I'm using annotations for mapping Object with Relational tables instead of hbm.xml file. I want to integrate jasper report with out changing hibernate configuration.In jasper report studio, i choose hibernate session to connect to my H2 database, i have provided the hibernate.cfg.xml.After clicking test i got this error:</p>
  
  <pre><code>net.sf.jasperreports.engine.JRException: java.lang.reflect.InvocationTargetException
      at net.sf.jasperreports.data.hibernate.HibernateDataAdapterService.contributeParameters(HibernateDataAdapterService.java:129)
      at net.sf.jasperreports.data.AbstractDataAdapterService.test(AbstractDataAdapterService.java:105)
      at com.jaspersoft.studio.data.DataAdapterEditorPart$1.widgetSelected(DataAdapterEditorPart.java:175)
      at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:248)
      at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
      at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4362)
      at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1113)
      at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4180)
      at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3769)
      at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1127)
      at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
      at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1018)
      at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156)
      at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:694)
      at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
      at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:606)
      at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
      at com.jaspersoft.studio.rcp.intro.Application.start(Application.java:99)
      at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
      at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
      at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
      at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
      at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:669)
      at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608)
      at org.eclipse.equinox.launcher.Main.run(Main.java:1515)
  Caused by: java.lang.reflect.InvocationTargetException
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at net.sf.jasperreports.data.hibernate.HibernateDataAdapterService.contributeParameters(HibernateDataAdapterService.java:85)
      ... 29 more
  Caused by: org.hibernate.MappingException: An AnnotationConfiguration instance is required to use &lt;mapping class="bean.Entreprise"/&gt;
      at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1648)
      at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1603)
      at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1582)
      at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1556)
      at org.hibernate.cfg.Configuration.configure(Configuration.java:1510)
      ... 34 more
  </code></pre>
  
  <p>After that i go in other way by choosing an empty datasource, create field manually in jasper report studio, but again i get a problem (Fields need to have custom type whitch i use in my project like entreprise, transaction ..etc.
  So how i can tell jasper report to use my own types.</p>
  
  <p>And then i provide jasper report with collection of database in my java code: like so:</p>
  
  <pre><code>try {
              InputStream inputStream = new FileInputStream("./report/transactionReprot.jrxml");
  
              JasperDesign jasperDesign = JRXmlLoader.load(inputStream);
  
              JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
              HashMap parameter = new HashMap();
  
              JRBeanCollectionDataSource beanDataSource = new JRBeanCollectionDataSource(transactionModel.getTransactionList());
              JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameter, beanDataSource);
  
              if (jasperPrint != null) {
                  JasperViewer.viewReport(jasperPrint);
                  System.out.println("Printed");
              } else
                  System.out.println("Not able to print");
          } catch (FileNotFoundException e) {
              e.printStackTrace();
          } catch (JRException e) {
              e.printStackTrace();
          }
  </code></pre>
  
  <p>So my question is: How to integrate JasperReports in project that uses hibernate with annotations?</p>
  
  <p>If JasperReports can't work with annotations, so what other solution for this problem?</p>