Note that there are some explanatory texts on larger screens.

plurals
  1. POTransmit data into jsp from 2 tables in one query
    text
    copied!<p>I have a two tables( Entity classes) and need select from both and transmit result into jsp page.</p> <p>My Entity for Balance:</p> <pre><code> @Entity @NamedQuery (name = "findLastFiveTransaction", query = "select c, b from Categorietype c, Balance b where c.user = :user and b.user = :user") public class Balance implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy=GenerationType.IDENTITY) private String id; private BigDecimal sum; @Column(name="Description") private String descrip; </code></pre> <p>My Entity for Categorietype: </p> <pre><code>@Entity public class Categorietype implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy=GenerationType.IDENTITY) private String id; private String name; //bi-directional many-to-one association to Balance @OneToMany(mappedBy="categorietype") private List&lt;Balance&gt; balances; //bi-directional many-to-one association to User @ManyToOne @JoinColumn(name="UserID") private User user; </code></pre> <p>Method in EJB Class:</p> <pre><code> public List getUserTransaction(User user) { return em.createNamedQuery("findLastFiveTransaction").setParameter("user", user).getResultList(); } </code></pre> <p>My code on jsp page:</p> <pre><code>&lt;table border="1"&gt; &lt;tr&gt; &lt;th&gt;Sum&lt;/th&gt; &lt;th&gt;Descrip&lt;/th&gt; &lt;th&gt;Name&lt;/th&gt; &lt;/tr&gt; &lt;c:forEach items="${result}" var="r"&gt; &lt;tr&gt; &lt;td&gt; ${r.sum} &lt;/td&gt; &lt;td&gt; ${r.descrip} &lt;/td&gt; &lt;td&gt; ${r.name} &lt;/td&gt; &lt;/tr&gt; &lt;/c:forEach&gt; &lt;/table&gt; </code></pre> <p>In such variant I getting messages </p> <blockquote> <p>org.apache.jasper.JasperException: java.lang.NumberFormatException: For input string: "sum"</p> </blockquote> <p>My problem is how parse data transferred into jsp page. I transmit data from my servlet:</p> <pre><code>List result = balance.getUserTransaction(user); request.setAttribute("result", result ); request.getRequestDispatcher("finance.jsp").forward(request, response); </code></pre> <p>How I must to do correct this or show me where I can read this?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload