java - HQL - List country and fetch all the state and currency -


i wanted list countries fetch respective state , currency.

conffacade.java

public result<list<country>> listcountries() {     try {         string hql = "select distinct o ocountry o left join fetch o.ostate, o.ocurrency";         list<country> list = em.createquery(hql).getresultlist();          return new result(status.success, list);     } catch(exception e) {         e.printstacktrace();         return new result<>(status.error, exception.general, e.getmessage());     } } 

conffacadelocal.java

public interface conffacadelocal {            public result<list<country>> listcountries();        }

this jsp use , code it:

listcountries.jsp

<%          try {              initialcontext ctx = new initialcontext();              conffacadelocal conffacadelocal = (conffacadelocal)ctx.lookup("java:comp/env/tomin");                result<list<country>> result = conffacadelocal.listcountries();              if(result.isunsuccessful()) {                  throw new exception(result.geterrmsg());              }                            list<country> countrylist = result.getobject();              if(countrylist == null) {                  throw new exception("error.");              }              out.print("ok");                    %>                            <table border="1" align="center" style="width:50%">              <thead>                  <tr>                      <th>country code</th>                      <th>currency code</th>                      <th>state id</th>                      <th>state description</th>                                        </tr>              </thead>              <tbody><%                            (ocountry country : countrylist){ %>                  <tr>                      <td><%=country.getoccode()%></td>                      <td><%=country.getocurrency().getocucode()%></td>                      <td><%=country.getostate().getosid()%></td>                      <td><%=country.getostate().getosdesc()%></td>                    </tr><%              }          } catch (exception e) {              e.printstacktrace();              out.print("error: " + e.getmessage());          } %>                                               </tbody>          </table>

here error get:

cannot find symbol    symbol:   method getostate()    location: variable country of type com.ejb.entities.conf.country  pwc6197: error occurred @ line: 42 in jsp file: /country/listcountries.jsp  pwc6199: generated servlet error:  cannot find symbol    symbol:   method getostate()    location: variable country of type com.ejb.entities.conf.country  	at org.apache.jasper.compiler.defaulterrorhandler.javacerror(defaulterrorhandler.java:129)  	at org.apache.jasper.compiler.errordispatcher.javacerror(errordispatcher.java:299)  	at org.apache.jasper.compiler.compiler.generateclass(compiler.java:392)  	at org.apache.jasper.compiler.compiler.compile(compiler.java:453)  	at org.apache.jasper.jspcompilationcontext.compile(jspcompilationcontext.java:625)  	at org.apache.jasper.servlet.jspservletwrapper.service(jspservletwrapper.java:375)  	at org.apache.jasper.servlet.jspservlet.servicejspfile(jspservlet.java:473)  	at org.apache.jasper.servlet.jspservlet.service(jspservlet.java:377)  	at javax.servlet.http.httpservlet.service(httpservlet.java:790)  	at org.apache.catalina.core.standardwrapper.service(standardwrapper.java:1682)  	at org.apache.catalina.core.standardwrappervalve.invoke(standardwrappervalve.java:318)  	at org.apache.catalina.core.standardcontextvalve.invoke(standardcontextvalve.java:160)  	at org.apache.catalina.core.standardpipeline.doinvoke(standardpipeline.java:734)  	at org.apache.catalina.core.standardpipeline.invoke(standardpipeline.java:673)  	at com.sun.enterprise.web.webpipeline.invoke(webpipeline.java:99)  	at org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:174)  	at org.apache.catalina.connector.coyoteadapter.doservice(coyoteadapter.java:415)  	at org.apache.catalina.connector.coyoteadapter.service(coyoteadapter.java:282)  	at com.sun.enterprise.v3.services.impl.containermapper$httphandlercallable.call(containermapper.java:459)  	at com.sun.enterprise.v3.services.impl.containermapper.service(containermapper.java:167)  	at org.glassfish.grizzly.http.server.httphandler.runservice(httphandler.java:201)  	at org.glassfish.grizzly.http.server.httphandler.dohandle(httphandler.java:175)  	at org.glassfish.grizzly.http.server.httpserverfilter.handleread(httpserverfilter.java:235)  	at org.glassfish.grizzly.filterchain.executorresolver$9.execute(executorresolver.java:119)  	at org.glassfish.grizzly.filterchain.defaultfilterchain.executefilter(defaultfilterchain.java:284)  	at org.glassfish.grizzly.filterchain.defaultfilterchain.executechainpart(defaultfilterchain.java:201)  	at org.glassfish.grizzly.filterchain.defaultfilterchain.execute(defaultfilterchain.java:133)  	at org.glassfish.grizzly.filterchain.defaultfilterchain.process(defaultfilterchain.java:112)  	at org.glassfish.grizzly.processorexecutor.execute(processorexecutor.java:77)  	at org.glassfish.grizzly.nio.transport.tcpniotransport.fireioevent(tcpniotransport.java:561)  	at org.glassfish.grizzly.strategies.abstractiostrategy.fireioevent(abstractiostrategy.java:112)  	at org.glassfish.grizzly.strategies.workerthreadiostrategy.run0(workerthreadiostrategy.java:117)  	at org.glassfish.grizzly.strategies.workerthreadiostrategy.access$100(workerthreadiostrategy.java:56)  	at org.glassfish.grizzly.strategies.workerthreadiostrategy$workerthreadrunnable.run(workerthreadiostrategy.java:137)  	at org.glassfish.grizzly.threadpool.abstractthreadpool$worker.dowork(abstractthreadpool.java:565)  	at org.glassfish.grizzly.threadpool.abstractthreadpool$worker.run(abstractthreadpool.java:545)  	at java.lang.thread.run(thread.java:745)

can fix it?

from jsp error logs, guess missed declare #listcountries method conffacadelocal bean interface.

adding needed method declaration interface should resolve issue:

public interface conffacadelocal {    // other api methods ...    public result<list<country>> listcountries();  } 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -