-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: hibernate and jasperreport problem
PostPosted: Tue Oct 07, 2008 9:15 am 
Beginner
Beginner

Joined: Mon Mar 17, 2008 11:25 am
Posts: 42
hi all,
I try go create simple jasperreport and fill him with 2table valuse. problem is that i canno't get values from table adressen. here is my code.
Code:
package model;

// default package
// Generated 22.09.2008 09:49:57 by Hibernate Tools 3.2.1.GA

import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
* Beleg generated by hbm2java
*/
public class Beleg implements java.io.Serializable {

   private String belegid;
   private String adressid;
   private Date datum;
   private Float netto;
   private Float mwst;
   private Integer rabatt;
   private Integer zbid;
   private byte[] vortext;
   private byte[] nachtext;
   private String bemerkung;
   private Integer ausgewaehlt;
   private Float bezahlt;
   private String oztyp;
   private int status;
   private Adressen adressen;
   private Belegpos bp;
   //beleg 1 : n Belegpos
   private Set<Belegpos> belegpos=new HashSet<Belegpos>();
   //private List<Belegpos> belegpos = new ArrayList<Belegpos>();
   
   public Beleg() {
   }

   public Beleg(String belegid, String adressid, int status) {
      this.belegid = belegid;
      this.adressid = adressid;
      this.status = status;
   }

   public Beleg(String belegid, String adressid, Date datum, Float netto,
         Float mwst, Integer rabatt, Integer zbid, byte[] vortext,
         byte[] nachtext, String bemerkung, Integer ausgewaehlt,
         Float bezahlt, String oztyp, int status) {
      this.belegid = belegid;
      this.adressid = adressid;
      this.datum = datum;
      this.netto = netto;
      this.mwst = mwst;
      this.rabatt = rabatt;
      this.zbid = zbid;
      this.vortext = vortext;
      this.nachtext = nachtext;
      this.bemerkung = bemerkung;
      this.ausgewaehlt = ausgewaehlt;
      this.bezahlt = bezahlt;
      this.oztyp = oztyp;
      this.status = status;
   }

   public String getBelegid() {
      return this.belegid;
   }

   public void setBelegid(String belegid) {
      this.belegid = belegid;
   }

   public String getAdressid() {
      return this.adressid;
   }

   public void setAdressid(String adressid) {
      this.adressid = adressid;
   }

   public Date getDatum() {
      return this.datum;
   }

   public void setDatum(Date datum) {
      this.datum = datum;
   }

   public Float getNetto() {
      return this.netto;
   }

   public void setNetto(Float netto) {
      this.netto = netto;
   }

   public Float getMwst() {
      return this.mwst;
   }

   public void setMwst(Float mwst) {
      this.mwst = mwst;
   }

   public Integer getRabatt() {
      return this.rabatt;
   }

   public void setRabatt(Integer rabatt) {
      this.rabatt = rabatt;
   }

   public Integer getZbid() {
      return this.zbid;
   }

   public void setZbid(Integer zbid) {
      this.zbid = zbid;
   }

   public byte[] getVortext() {
      return this.vortext;
   }

   public void setVortext(byte[] vortext) {
      this.vortext = vortext;
   }

   public byte[] getNachtext() {
      return this.nachtext;
   }

   public void setNachtext(byte[] nachtext) {
      this.nachtext = nachtext;
   }

   public String getBemerkung() {
      return this.bemerkung;
   }

   public void setBemerkung(String bemerkung) {
      this.bemerkung = bemerkung;
   }

   public Integer getAusgewaehlt() {
      return this.ausgewaehlt;
   }

   public void setAusgewaehlt(Integer ausgewaehlt) {
      this.ausgewaehlt = ausgewaehlt;
   }

   public Float getBezahlt() {
      return this.bezahlt;
   }

   public void setBezahlt(Float bezahlt) {
      this.bezahlt = bezahlt;
   }

   public String getOztyp() {
      return this.oztyp;
   }

   public void setOztyp(String oztyp) {
      this.oztyp = oztyp;
   }

   public int getStatus() {
      return this.status;
   }

   public void setStatus(int status) {
      this.status = status;
   }

   public Adressen getAdressen() {
      return adressen;
   }

   public void setAdressen(Adressen adressen) {
      this.adressen = adressen;
   }

   public Set<Belegpos> getBelegpos() {
      return belegpos;
   }

   public void setBelegpos(Set<Belegpos> belegpos) {
      this.belegpos = belegpos;
   }

   public Belegpos getBp() {
      return bp;
   }

   public void setBp(Belegpos bp) {
      this.bp = bp;
   }

   
}

package model;

// default package
// Generated 22.09.2008 09:49:57 by Hibernate Tools 3.2.1.GA

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

/**
* Adressen generated by hbm2java
*/
public class Adressen implements java.io.Serializable {

   private String adressid;
   private String kurzname;
   private String anrede;
   private String name;
   private String strasse;
   private String plz;
   private String ort;
   private String vorwahl;
   private String telefon;
   private String fax;
   private String email;
   private String unsereKdnr;
   private byte[] notiz;
   private String blz;
   private String konto;
   private Date geburtstag;
   private Integer status;

   //1:n Adressen : Belegpos
   private Set<Beleg> beleg=new HashSet<Beleg>();
   
   public Adressen() {
   }

   public Adressen(String adressid) {
      this.adressid = adressid;
   }

   public Adressen(String adressid, String kurzname, String anrede,
         String name, String strasse, String plz, String ort,
         String vorwahl, String telefon, String fax, String email,
         String unsereKdnr, byte[] notiz, String blz, String konto,
         Date geburtstag, Integer status) {
      this.adressid = adressid;
      this.kurzname = kurzname;
      this.anrede = anrede;
      this.name = name;
      this.strasse = strasse;
      this.plz = plz;
      this.ort = ort;
      this.vorwahl = vorwahl;
      this.telefon = telefon;
      this.fax = fax;
      this.email = email;
      this.unsereKdnr = unsereKdnr;
      this.notiz = notiz;
      this.blz = blz;
      this.konto = konto;
      this.geburtstag = geburtstag;
      this.status = status;
   }

   public String getAdressid() {
      return this.adressid;
   }

   public void setAdressid(String adressid) {
      this.adressid = adressid;
   }

   public String getKurzname() {
      return this.kurzname;
   }

   public void setKurzname(String kurzname) {
      this.kurzname = kurzname;
   }

   public String getAnrede() {
      return this.anrede;
   }

   public void setAnrede(String anrede) {
      this.anrede = anrede;
   }

   public String getName() {
      return this.name;
   }

   public void setName(String name) {
      this.name = name;
   }

   public String getStrasse() {
      return this.strasse;
   }

   public void setStrasse(String strasse) {
      this.strasse = strasse;
   }

   public String getPlz() {
      return this.plz;
   }

   public void setPlz(String plz) {
      this.plz = plz;
   }

   public String getOrt() {
      return this.ort;
   }

   public void setOrt(String ort) {
      this.ort = ort;
   }

   public String getVorwahl() {
      return this.vorwahl;
   }

   public void setVorwahl(String vorwahl) {
      this.vorwahl = vorwahl;
   }

   public String getTelefon() {
      return this.telefon;
   }

   public void setTelefon(String telefon) {
      this.telefon = telefon;
   }

   public String getFax() {
      return this.fax;
   }

   public void setFax(String fax) {
      this.fax = fax;
   }

   public String getEmail() {
      return this.email;
   }

   public void setEmail(String email) {
      this.email = email;
   }

   public String getUnsereKdnr() {
      return this.unsereKdnr;
   }

   public void setUnsereKdnr(String unsereKdnr) {
      this.unsereKdnr = unsereKdnr;
   }

   public byte[] getNotiz() {
      return this.notiz;
   }

   public void setNotiz(byte[] notiz) {
      this.notiz = notiz;
   }

   public String getBlz() {
      return this.blz;
   }

   public void setBlz(String blz) {
      this.blz = blz;
   }

   public String getKonto() {
      return this.konto;
   }

   public void setKonto(String konto) {
      this.konto = konto;
   }

   public Date getGeburtstag() {
      return this.geburtstag;
   }

   public void setGeburtstag(Date geburtstag) {
      this.geburtstag = geburtstag;
   }

   public Integer getStatus() {
      return this.status;
   }

   public void setStatus(Integer status) {
      this.status = status;
   }

   public Set<Beleg> getBeleg() {
      return beleg;
   }

   public void setBeleg(Set<Beleg> beleg) {
      this.beleg = beleg;
   }
   
}
String sampleReportFile=new String("E:/eclipse3.4/Handwerk2008/src/JasperReports/testBeleg.xml");
      
      
      //List belege=null;
      try{
         
         begin();
         List belege= getSession().createQuery("select b from Beleg b join b.adressen join b.belegpos where b.belegid='RA004805'").list();
         
         //wypelnia parametry
         HashMap parameters= new HashMap();
         parameters.put("titel", "Rechnung");
         
         //laduje  z pliku xml do .jasper
         JasperDesign design=JRXmlLoader.load(sampleReportFile);
         //kompiluje
         JasperReport report= new JasperCompileManager().compileReport(design);
         
         //wypelnia raport uzywajac metody...
         JasperPrint print= JasperFillManager.fillReport(report, parameters, new JRBeanCollectionDataSource(belege));
         //
         //export do pdf
         JasperExportManager.exportReportToPdfFile(print, "testBeleg.pdf");
         //commit();
         
         System.out.println("Datei wurde gespeichert" );
      }catch(JRException jre){
         jre.printStackTrace();
      }
      catch(MappingException me){
         me.printStackTrace();
      }
      catch(HibernateException he){
         he.printStackTrace();
      }
      
   }

<?xml version="1.0" encoding="UTF-8"  ?>
<!-- Created with iReport - A designer for JasperReports -->
<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
<jasperReport
       name="testBeleg"
       columnCount="1"
       printOrder="Vertical"
       orientation="Portrait"
       pageWidth="595"
       pageHeight="842"
       columnWidth="555"
       columnSpacing="0"
       leftMargin="20"
       rightMargin="20"
       topMargin="30"
       bottomMargin="30"
       whenNoDataType="NoPages"
       isTitleNewPage="false"
       isSummaryNewPage="false">
   <property name="ireport.scriptlethandling" value="0" />
   <import value="java.util.*" />
   <import value="net.sf.jasperreports.engine.*" />
   <import value="net.sf.jasperreports.engine.data.*" />
   <reportFont name="Arial_Normal" isDefault="true" fontName="Arial" size="8" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
   <reportFont name="Arial_Bold" isDefault="false" fontName="Arial" size="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
   <parameter name="ReportTitle" isForPrompting="true" class="java.lang.String"/>
   <parameter name="NoOfGames" isForPrompting="true" class="java.lang.Integer"/>
   
   <field name="belegid" class="java.lang.String"/>
   <field name="adressid" class="java.lang.String"/>
   <field name="plz" class="java.lang.String"/>
   <variable name="adress" class="model.Adressen"></variable>
   
   
      <background>
         <band height="0"  isSplitAllowed="true" >
         </band>
      </background>
      <title>
         <band height="30"  isSplitAllowed="true" >
            <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
               <reportElement
                  mode="Transparent"
                  x="0"
                  y="0"
                  width="261"
                  height="30"
                  forecolor="#000000"
                  backcolor="#FFFFFF"
                  key="textField-1"
                  stretchType="NoStretch"
                  positionType="FixRelativeToTop"
                  isPrintRepeatedValues="true"
                  isRemoveLineWhenBlank="false"
                  isPrintInFirstWholeBand="false"
                  isPrintWhenDetailOverflows="false"/>
               <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
               <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single">
                  <font fontName="Arial" pdfFontName="Helvetica" size="24" isBold="true" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1252" isStrikeThrough="false" />
               </textElement>
            <textFieldExpression   class="java.lang.String"><![CDATA[$P{ReportTitle}]]></textFieldExpression>
            </textField>
         </band>
      </title>
      <pageHeader>
         <band height="20"  isSplitAllowed="true" >
            <staticText>
               <reportElement
                  mode="Transparent"
                  x="0"
                  y="4"
                  width="50"
                  height="15"
                  forecolor="#000000"
                  backcolor="#FFFFFF"
                  key="staticText"
                  stretchType="NoStretch"
                  positionType="FixRelativeToTop"
                  isPrintRepeatedValues="true"
                  isRemoveLineWhenBlank="false"
                  isPrintInFirstWholeBand="false"
                  isPrintWhenDetailOverflows="false"/>
               <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
               <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single">
                  <font reportFont="Arial_Bold"/>
               </textElement>
            <text><![CDATA[Belegid]]></text>
            </staticText>
            <staticText>
               <reportElement
                  mode="Transparent"
                  x="60"
                  y="4"
                  width="30"
                  height="15"
                  forecolor="#000000"
                  backcolor="#FFFFFF"
                  key="staticText"
                  stretchType="NoStretch"
                  positionType="FixRelativeToTop"
                  isPrintRepeatedValues="true"
                  isRemoveLineWhenBlank="false"
                  isPrintInFirstWholeBand="false"
                  isPrintWhenDetailOverflows="false"/>
               <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
               <textElement textAlignment="Right" verticalAlignment="Top" rotation="None" lineSpacing="Single">
                  <font reportFont="Arial_Bold"/>
               </textElement>
            <text><![CDATA[Adressid]]></text>
            </staticText>
            <staticText>
               <reportElement
                  mode="Transparent"
                  x="60"
                  y="4"
                  width="30"
                  height="15"
                  forecolor="#000000"
                  backcolor="#FFFFFF"
                  key="staticText"
                  stretchType="NoStretch"
                  positionType="FixRelativeToTop"
                  isPrintRepeatedValues="true"
                  isRemoveLineWhenBlank="false"
                  isPrintInFirstWholeBand="false"
                  isPrintWhenDetailOverflows="false"/>
               <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
               <textElement textAlignment="Right" verticalAlignment="Top" rotation="None" lineSpacing="Single">
                  <font reportFont="Arial_Bold"/>
               </textElement>
            <text><![CDATA[PLZ]]></text>
            </staticText>
            </band>
      </pageHeader>
      <columnHeader>
         <band height="0"  isSplitAllowed="true" >
         </band>
      </columnHeader>
      <detail>
         <band height="20"  isSplitAllowed="true" >
            <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
               <reportElement
                  mode="Transparent"
                  x="0"
                  y="4"
                  width="50"
                  height="15"
                  forecolor="#000000"
                  backcolor="#FFFFFF"
                  key="textField"
                  stretchType="NoStretch"
                  positionType="FixRelativeToTop"
                  isPrintRepeatedValues="true"
                  isRemoveLineWhenBlank="false"
                  isPrintInFirstWholeBand="false"
                  isPrintWhenDetailOverflows="false"/>
               <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
               <textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single">
                  <font fontName="Arial" pdfFontName="Helvetica" size="8" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1252" isStrikeThrough="false" />
               </textElement>
            <textFieldExpression   class="java.lang.String"><![CDATA[$F{belegid}]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
               <reportElement
                  mode="Transparent"
                  x="60"
                  y="4"
                  width="30"
                  height="15"
                  forecolor="#000000"
                  backcolor="#FFFFFF"
                  key="textField"
                  stretchType="NoStretch"
                  positionType="FixRelativeToTop"
                  isPrintRepeatedValues="true"
                  isRemoveLineWhenBlank="false"
                  isPrintInFirstWholeBand="false"
                  isPrintWhenDetailOverflows="false"/>
               <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
               <textElement textAlignment="Right" verticalAlignment="Top" rotation="None" lineSpacing="Single">
                  <font fontName="Arial" pdfFontName="Helvetica" size="8" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1252" isStrikeThrough="false" />
               </textElement>
            <textFieldExpression   class="java.lang.String"><![CDATA[$F{adressid}]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
               <reportElement
                  mode="Transparent"
                  x="60"
                  y="4"
                  width="30"
                  height="15"
                  forecolor="#000000"
                  backcolor="#FFFFFF"
                  key="textField"
                  stretchType="NoStretch"
                  positionType="FixRelativeToTop"
                  isPrintRepeatedValues="true"
                  isRemoveLineWhenBlank="false"
                  isPrintInFirstWholeBand="false"
                  isPrintWhenDetailOverflows="false"/>
               <box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>
               <textElement textAlignment="Right" verticalAlignment="Top" rotation="None" lineSpacing="Single">
                  <font fontName="Arial" pdfFontName="Helvetica" size="8" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1252" isStrikeThrough="false" />
               </textElement>
            <textFieldExpression><![CDATA[$F{plz}]]></textFieldExpression>
            </textField>
            
         </band>
      </detail>
      <columnFooter>
         <band height="0"  isSplitAllowed="true" >
         </band>
      </columnFooter>
      <pageFooter>
         <band height="0"  isSplitAllowed="true" >
         </band>
      </pageFooter>
      <summary>
         <band height="0"  isSplitAllowed="true" >
         </band>
      </summary>
</jasperReport>




I recive fallowing error :
net.sf.jasperreports.engine.JRException: Error retrieving field value from bean : plz
at net.sf.jasperreports.engine.data.JRAbstractBeanDataSource.getBeanProperty(JRAbstractBeanDataSource.java:127)
at net.sf.jasperreports.engine.data.JRAbstractBeanDataSource.getFieldValue(JRAbstractBeanDataSource.java:100)
at net.sf.jasperreports.engine.data.JRBeanCollectionDataSource.getFieldValue(JRBeanCollectionDataSource.java:104)
at net.sf.jasperreports.engine.fill.JRFillDataset.setOldValues(JRFillDataset.java:799)
at net.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:763)
at net.sf.jasperreports.engine.fill.JRBaseFiller.next(JRBaseFiller.java:1402)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:111)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:888)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:810)
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:89)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:601)
at DAO.SimpleHibernateExample.GenerateBeleg(SimpleHibernateExample.java:48)
at DAO.SimpleHibernateExample.main(SimpleHibernateExample.java:68)
Caused by: java.lang.NoSuchMethodException: Unknown property 'plz' on class 'class model.Beleg'
at org.apache.commons.beanutils.PropertyUtilsBean.getSimpleProperty(PropertyUtilsBean.java:1313)
at org.apache.commons.beanutils.PropertyUtilsBean.getNestedProperty(PropertyUtilsBean.java:762)
at org.apache.commons.beanutils.PropertyUtilsBean.getProperty(PropertyUtilsBean.java:837)
at org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:426)
at net.sf.jasperreports.engine.data.JRAbstractBeanDataSource.getBeanProperty(JRAbstractBeanDataSource.java:115)
... 12 more

how can i get plz proerty of Adressen?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.