0
にトランザクションをコミットは私がtx.commitに多く、その後1時間を使用しています。このエラーが出る休止状態
これは私のコードである
message
description The server encountered an internal error() that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /JSP/Upload /upload.jsp at line 444
441: Query qLVa = hibernateSessiona1.createQuery("from Livrea where NomLivre = :userLV ");
442: qLVa.setParameter("userLV", newName);
443:
444: Livrea LVa =(Livrea) qLVa.uniqueResult();
445:
446: Ajouter add = new Ajouter();
447:
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:550)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:439)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:332)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
cause mère
javax.servlet.ServletException: net.sf.hibernate.NonUniqueResultException: query did not return a unique result: 2
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:901)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:830)
org.apache.jsp.JSP.Upload.upload_jsp._jspService(upload_jsp.java:612)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:68)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:332)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
cause mère
net.sf.hibernate.NonUniqueResultException: query did not return a unique result: 2
net.sf.hibernate.impl.AbstractQueryImpl.uniqueElement(AbstractQueryImpl.java:559)
net.sf.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:550)
org.apache.jsp.JSP.Upload.upload_jsp._jspService(upload_jsp.java:515)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:68)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:332)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
note La trace complète de la cause mère de cette erreur est disponible dans les fichiers journaux de Apache Tomcat/7
レポートtype'exception:
Session hibernateSession = HibernateUtil.currentSession();
Transaction tx = hibernateSession.beginTransaction();
Livrea LV = new Livrea();
LV.setNomLivre(newName);
hibernateSession.save(LV);
tx.commit();
HibernateUtil.closeSession();
if(session.getAttribute("type").equals("Enseignant")){
Session hibernateSessione1 = HibernateUtil.currentSession();
Transaction txe1 = hibernateSession.beginTransaction();
Query qEnseignant = hibernateSessione1.createQuery("from Enseignant where UserName = :userSID ");
qEnseignant.setParameter("userSID", session.getAttribute("UserName"));
Enseignant en =(Enseignant) qEnseignant.uniqueResult();
Query qLVe = hibernateSessione1.createQuery("from Livre wherea NomLivre = :userSID ");
qLVe.setParameter("userSID", newName);
Livrea LVe =(Livrea) qLVe.uniqueResult();
LVe.addToAjouterenseiSet(en);
int nbre =en.getNbrLivreAjou();
nbre = nbre+1;
en.setNbrLivreAjou(nbre);
hibernateSessione1.update(en);
txe1.commit();
HibernateUtil.closeSession();
}else
if(session.getAttribute("type").equals("Administrateur")){
Session hibernateSessiona1 = HibernateUtil.currentSession();
Transaction txa1 = hibernateSessiona1.beginTransaction();
Query qAdmin = hibernateSessiona1.createQuery("from Administrateur where UserName = :userAdmin ");
qAdmin.setParameter("userAdmin", session.getAttribute("UserName"));
Administrateur admin =(Administrateur) qAdmin.uniqueResult();
Query qLVa = hibernateSessiona1.createQuery("from Livrea where NomLivre = :userLV ");
qLVa.setParameter("userLV", newName);
Livrea LVa =(Livrea) qLVa.uniqueResult();
Ajouter add = new Ajouter();
LVa.addToAjouterSet(admin.getIdAdmin());
if(admin.getNbrLivreAjou()== null)admin.setNbrLivreAjou(1);
else{ int nbra =admin.getNbrLivreAjou();
nbra = nbra+1;
admin.setNbrLivreAjou(nbra);
}
hibernateSessiona1.update(admin);
txa1.commit();
HibernateUtil.closeSession();
}
plzヘルプme
をこのサイトのユーザーのほとんどは、英語を話しますあなたの質問が英語であれば、はるかに良い回答が得られます:http://blog.stackoverflow.com/2009/07/non-english-question-policy/ –
私はそれを手助けするために編集する – David