Roel De Nijs wrote:I assume you have created a view vLtklSubmitInfo in your database and this view actually exists in the database.
According to the Java Persistence WikiBook you can use/map a view just like it was a table, using the @Table annotation. So that would mean your entity class looks likeWhy do you have a @NamedNativeQuery annotation with the same name as your view (vLtklSubmitInfo). And your so called "native query" is not native SQL, it's JPQL. So remove this @NamedNativeQuery annotation and try again.
Hope it helps!
Kind regards,
Roel
Roel De Nijs wrote:I assume you have created a view vLtklSubmitInfo in your database and this view actually exists in the database.
According to the Java Persistence WikiBook you can use/map a view just like it was a table, using the @Table annotation. So that would mean your entity class looks like
Roel
Irliyanti Rahmadhani Lubis wrote:If I have join table in my View, is that must be have annotation in class (like ManyToOne, etc)?
Irliyanti Rahmadhani Lubis wrote:I don't know my is JPQL, so I'm using @NamedNativeQuery. I'm a beginner in Java programmer.
Irliyanti Rahmadhani Lubis wrote:I try it, but the error is same.
Irliyanti Rahmadhani Lubis wrote:Sorry, It's my fault, I forget to change the name View in DAO Impl. It works now. Thank's
Irliyanti Rahmadhani Lubis wrote:and, in my View database, there's have data, but when I running in Hibernate, there's no data, where the error?
Roel De Nijs wrote:
Irliyanti Rahmadhani Lubis wrote:and, in my View database, there's have data, but when I running in Hibernate, there's no data, where the error?
Do you get an error in your application? Or does the query execute without returning results? If it's the first one, you'll have to share that error because I'm not clairvoyant. If it's the latter one, try to execute the query without adding restrictions/conditions and see if results are returned.
get Date from URL -->16/10/2015
out of DateFri Oct 16 00:00:00 ICT 2015
print out of DAO IMPL --->[gov.siapuppatk.model.VLtklSubmitInfo@15dbb09, gov.siapuppatk.model.VLtklSubmitInfo@15dbb09, gov.siapuppatk.model.VLtklSubmitInfo@15dbb09]
result--> [gov.siapuppatk.model.VLtklSubmitInfo@15dbb09, gov.siapuppatk.model.VLtklSubmitInfo@15dbb09, gov.siapuppatk.model.VLtklSubmitInfo@15dbb09]
I try to see the output of my query in Log Apache, I got :
get Date from URL -->16/10/2015
out of DateFri Oct 16 00:00:00 ICT 2015
print out of DAO IMPL --->[gov.siapuppatk.model.VLtklSubmitInfo@15dbb09, gov.siapuppatk.model.VLtklSubmitInfo@15dbb09, gov.siapuppatk.model.VLtklSubmitInfo@15dbb09]
result--> [gov.siapuppatk.model.VLtklSubmitInfo@15dbb09, gov.siapuppatk.model.VLtklSubmitInfo@15dbb09, gov.siapuppatk.model.VLtklSubmitInfo@15dbb09]
Irliyanti Rahmadhani Lubis wrote:
get Date from URL -->16/10/2015
out of DateFri Oct 16 00:00:00 ICT 2015
print out of DAO IMPL --->[gov.siapuppatk.model.VLtklSubmitInfo@15dbb09, gov.siapuppatk.model.VLtklSubmitInfo@15dbb09, gov.siapuppatk.model.VLtklSubmitInfo@15dbb09]
result--> [gov.siapuppatk.model.VLtklSubmitInfo@15dbb09, gov.siapuppatk.model.VLtklSubmitInfo@15dbb09, gov.siapuppatk.model.VLtklSubmitInfo@15dbb09]
Irliyanti Rahmadhani Lubis wrote:Hem, I think, on controller I get the data with Array List, but in the return mav; I change it to model data type. is it the problem?
Roel De Nijs wrote:you would expect to see some code like this in the appropriate view (jsp file)Now you should see the zipFileName for every result.
Oct 28, 2015 9:20:30 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [siapuppatk-jsp] in context with path [/SIAPUPPATK-FE-SVN] threw exception [An exception occurred processing JSP page /pages/cekSubmitList.jsp at line 50
47:
48: <label style="display: inline-block; width:100px;">Tanggal Transaksi</label>
49: <lable style="display: inline-block; width:10px;">:</lable>
50: <input type="text" size="10" name="tdate" id="dateValue3" placeholder="dd/MM/yyyy" value="<fmt:formatDate value="${ltklSubmitInfoList}" pattern='dd/MM/yyyy'/>" />
51:![]()
52:
53: <label style="display: inline-block; width:100px;">Tanggal Transaksi Efektif</label>
Stacktrace:] with root cause
javax.el.ELException: Cannot convert [gov.siapuppatk.model.VLtklSubmitInfo@168adcb, gov.siapuppatk.model.VLtklSubmitInfo@168adcb, gov.siapuppatk.model.VLtklSubmitInfo@168adcb] of type class java.util.ArrayList to class java.util.Date
at org.apache.el.lang.ELSupport.coerceToType(ELSupport.java:431)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:944)
at org.apache.jsp.pages.cekSubmitList_jsp._jspx_meth_fmt_005fformatDate_005f3(cekSubmitList_jsp.java:3849)
at org.apache.jsp.pages.cekSubmitList_jsp._jspService(cekSubmitList_jsp.java:1274)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:439)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:748)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:486)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:411)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:338)
at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:263)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1208)
at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:992)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:939)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:953)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:844)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:829)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:957)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2516)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2505)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Hem, Okay I got it.
![]()
so, there's how to get data from controller and view in JSP.
In my previously JSP and Controller, there's is a DTO, and to view data from DTO to JSP, they use "data" as DTO.
But, now I want to add new search data by "Tanggal Transaksi" and "Tanggal Transaksi Efektif" without DTO.
Irliyanti Rahmadhani Lubis wrote:the results it's look same, but, when I execute query in database, there's 3 different data. (where d_Transaksi = '16/10/2015')
Irliyanti Rahmadhani Lubis wrote:The second problem, I have same code in Tanggal Transaksi Efektif, but when I trace and debug my code, there's no result. Meanwhile, in my database there's 3 data in column d_transaksi_efektif.
Roel De Nijs wrote:
Irliyanti Rahmadhani Lubis wrote:The second problem, I have same code in Tanggal Transaksi Efektif, but when I trace and debug my code, there's no result. Meanwhile, in my database there's 3 data in column d_transaksi_efektif.
And can you execute the query generated by Hibernate on your Oracle database and see which results are returned?
Irliyanti Rahmadhani Lubis wrote:In hibernate I used HQL, like this :
Roel De Nijs wrote:
Irliyanti Rahmadhani Lubis wrote:In hibernate I used HQL, like this :
That's indeed the JPQL (or HQL) query, but that's not what I asked. Hibernate will translate your JPQL/HQL query into an actual SQL query. So this generated query is the one you are looking for. And you should execute this query on your database, not some query you created yourself.
Irliyanti Rahmadhani Lubis wrote:I used DISTINCT, because, without it, there's is double data in di View. But, it not select all Data in my View
Roel De Nijs wrote:
Irliyanti Rahmadhani Lubis wrote:I used DISTINCT, because, without it, there's is double data in di View. But, it not select all Data in my View
And if you execute the view without DISTINCT, do you get all rows which you expect to have (besides having some double data)? And is it normal to have duplicate rows in your view or is there something wrong with the conditions in your join clauses?
Irliyanti Rahmadhani Lubis wrote:but, when I'm adding more table, the result just 1 row, and without DISTINCT they have double row and just view 1 data (not select all data).
Is not that when we want to join table based 1 same column in 2 table (and the content in column must be same with each other)?
Roel De Nijs wrote:
Irliyanti Rahmadhani Lubis wrote:but, when I'm adding more table, the result just 1 row, and without DISTINCT they have double row and just view 1 data (not select all data).
Is not that when we want to join table based 1 same column in 2 table (and the content in column must be same with each other)?
You should know your data better than me. So you should know what's normal and which results are correct and which are not.
If you use joins in your queries and some rows don't exist anymore in the results after adding another table with another join condition, that mostly means there is no match in the other table to match with that column value. And therefore that record will be excluded from the results. If you still want that record to be in the final results, you'll need to user a left outer join or a right outer join. I think it's very useful to read about SQL Joins and the different types. HAving a good understanding is probably crucial in creating the appropriate SELECT statement for your view.
Hope it helps!
Kind regards,
Roel
Don't get me started about those stupid light bulbs. |