public static List<Transaction1> debitSourceAccBalance (Integer youraccinput, Integer toaccinput, String recname, Double amtsender) {
EntityManager em = emf.createEntityManager();
em.getTransaction().begin();
Query q = em.createQuery("SELECT t from Transaction1 t where t.fromAccNo =:youraccinput AND t.toAccNo =:toaccinput AND t.name =:recname AND t.amount >=:amtsender");
q.setParameter("youraccinput", youraccinput);
q.setParameter("toaccinput", toaccinput);
q.setParameter("recname", recname);
q.setParameter("amtsender", amtsender);
Double currbal = (Double)q.getSingleResult();
amtsender = currbal - amtsender;
Query u = em.createQuery("UPDATE Transaction1 t SET t.amount =:amtsender WHERE t.fromAccNo =:youraccinput AND t.toAccNo =:toaccinput");
u.setParameter("youraccinput", youraccinput);
u.setParameter("toaccinput", toaccinput);
u.setParameter("amtsender", amtsender);
u.executeUpdate();
return q.getResultList();
的Servlet:實體不能轉換爲java.lang.Double的
Integer youraccinput = Integer.parseInt(request.getParameter("fromAccNo"));
Integer toaccinput = Integer.parseInt(request.getParameter("toAccNo"));
String recname = request.getParameter("name");
Double amtsender = Double.parseDouble(request.getParameter("amount"));
List<Transaction1> results = Transaction1.debitSourceAccBalance(youraccinput, toaccinput, recname, amtsender);
results.listIterator();
request.getRequestDispatcher("ListSingleTransaction").forward(request, response);
爲什麼會收到此錯誤信息?請幫助修復!
「Entities.Transaction1不能轉換 到java.lang.Double中的」
如果您收到了演員例外情況,首先看的地方就是您正在演員演員陣容的*。 – 2010-02-04 01:11:54
即時對不起,我沒有得到它 – kobrakai 2010-02-04 01:14:26
你寫這個代碼? – 2010-02-04 01:16:20