Jump to content
We've recently updated our Privacy Statement, available here ×

swapnilnagtilak722

Members
  • Posts

    3
  • Joined

  • Last visited

 Content Type 

Profiles

Forum

Events

Featured Visualizations

Knowledge Base

Documentation (PDF Downloads)

Blog

Documentation (Test Area)

Documentation

Dr. Jaspersoft Webinar Series

Downloads

Everything posted by swapnilnagtilak722

  1. Getting: net.sf.jasperreports.engine.JRException: Error retrieving field value from bean: fullname.[/code] Only when using `NativeQuery` in `Hibernate` with `JasperReports`. When I use JPA criteria query then there's no issue **JPA Criteria** try (Session session = sessionFactory.openSession()) { CriteriaBuilder criteriaBuilder = session.getCriteriaBuilder(); CriteriaQuery Client criteriaQuery = criteriaBuilder.createQuery(Client.class); Root root = criteriaQuery.from(Client.class); criteriaQuery.where(criteriaBuilder.equal(root.get("id"), id)); return session.createQuery(criteriaQuery).getResultList(); }[/code]But when I use NativeQuery I face `net.sf.jasperreports.engine.JRException: Error retrieving field value from bean: fullname.` <b>Native Query :</b> try (Session session = sessionFactory.openSession()) { List<Client> query = session.createNativeQuery("select c.*, p.* from client c join product p on c.pid = p.id where c.id = :id") .addEntity("c", Client.class).addJoin("p", "c.product") .setParameter("id", id).list(); return query; }[/code] Here Jasper JRXML <?xml version="1.0" encoding="UTF-8"?> <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="Quotation" pageWidth="595" pageHeight="600" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="3954e5eb-656a-454e-b9e5-35f7e5262d48"> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/> <property name="ireport.zoom" value="1.0"/> <property name="ireport.x" value="0"/> <property name="ireport.y" value="0"/> <field name="fullname" class="java.lang.String"/> <field name="mobile" class="java.lang.String"/> <field name="city" class="java.lang.String"/> <field name="address" class="java.lang.String"/> <field name="quotationNo" class="java.lang.String"/> <field name="valid" class="java.lang.String"/> <field name="product.description" class="java.lang.String"/> <field name="product.cost" class="java.lang.String"/> <field name="product.name" class="java.lang.String"/>[/code] Client.java: public class Client implements java.io.Serializable { private Integer id; private Product product; private String fullname; private String business; private String address; private String city; private String mobile; private String addedBy; private String date; private String status; private String quotationNo; private String valid; private String productName; private Set orderses = new HashSet(0); public String getFullname() { return this.fullname; } public void setFullname(String fullname) { this.fullname = fullname; } [/code]I've already removed <FieldDescription>[/code]from fields in Jasper JRXML I also tried passing and removing false parameter in new JRBeanColllectionDataSource(collection, false); new JRBeanColllectionDataSource(collection); Passing `"false" parameter` only works for `JPA criteria` for `Native query` it doesn't matter whether parameter is passed or not it gives net.sf.jasperreports.engine.JRException: Error retrieving field value from bean: fullname. [/code]
  2. I'm using JDK 11.0.8+10 Hibernate 5.4 NetBeans 11.0Java FX on Debian 10.5 DefaultJasperReportsContext context = DefaultJasperReportsContext.getInstance(); JRPropertiesUtil.getInstance(context).setProperty("net.sf.jasperreports.xpath.executer.factory", "net.sf.jasperreports.engine.util.xml.JaxenXPathExecuterFactory"); BLManager bLManager = new BLManager(); List beanCollection = bLManager.searchReportId(118); try ( InputStream inputStream = JavaFXApplication.class.getResourceAsStream("/javafxapplication/Quotation.jasper")) { JRBeanCollectionDataSource jRBeanCollectionDataSource = new JRBeanCollectionDataSource(beanCollection, false); JasperPrint jasperPrint = JasperFillManager.fillReport(inputStream, null, jRBeanCollectionDataSource); JasperViewer.viewReport(context, jasperPrint, false); JasperViewer.viewReport(jasperPrint, false); } catch (JRException | IOException ex) { Logger.getLogger(JavaFXApplication.class.getName()).log(Level.SEVERE, null, ex); }[/code]This code take to fill report approx 20 seconds after event fired. But once it is filled then for second time it doesn't take even 1 second to fill up report again. I've tried including and excluding Jaxen Path but thing not gonna change. I'm using JPA CriteriaQuery to retrieve record as follows : public List searchReportId(int id) { try ( Session session = sessionFactory.openSession()) { CriteriaBuilder criteriaBuilder = session.getCriteriaBuilder(); CriteriaQuery<Client> criteriaQuery = criteriaBuilder.createQuery(Client.class); Root root = criteriaQuery.from(Client.class); criteriaQuery.where(criteriaBuilder.equal(root.get("id"), id)); return session.createQuery(criteriaQuery).getResultList(); } } [/code]So what would be reason taking such long time to filling reports? How can I improve speed of filling report?
  3. List<Orders> orders = bLManager.searchOrder(Integer.parseInt(textField.getText())); Map map = new HashMap(); map.put("id", Integer.parseInt(textField.getText())); try { InputStream inputStream = getClass().getResourceAsStream("/com/clientie/reports/Receipt Voucher.jasper"); JRBeanCollectionDataSource jRBeanCollectionDataSource = new JRBeanCollectionDataSource(orders, false); JasperPrint jasperPrint = JasperFillManager.fillReport(inputStream, map, jRBeanCollectionDataSource); JasperViewer.viewReport(jasperPrint, false); } catch (JRException ex) { Logger.getLogger(NewOrderController.class.getName()).log(Level.SEVERE, null, ex); } So when in Order class field name fullname is not exist it's being cause of error. Do I need to change my query or I should use JDBC connection insted JRBeanCollectionDataSource? Using MySQL 8.0.20 JDK 11.0+10 and JasperReport 6.12.2
×
×
  • Create New...