But, when I insert or update a row and I start up the application from other computer, I can't see the last changes. Can it be caused for transactions not completed? For example, in the code below, the line highlighted cause the next Exception: Transaction not successfully started
DocumentDAO documentDAO=(DocumentDAO)DocumentDAO.getInstance();
Session s=documentDAO.getSession();
Transaction tx=documentDAO.beginTransaction(s);
Document docu=documentDAO.get(new Integer(idDocument));
SecurityClasDAO securityClasDAO=(SecurityClasDAO)SecurityClasDAO.getInstance();
Session s3=securityClasDAO.getSession();
Transaction tx3=securityClasDAO.beginTransaction(s3);
SecurityClas secClas=(SecurityClas)securityClasDAO.getQuery("from SecurityClas s where s.value=?",s3).setCacheable(false).setString(0, clasiSeg).list().get(0);
securityClasDAO.commitTransaction(tx3);
securityClasDAO.closeSession(s3);
TypeParagraphDAO typeParagraphDAO=(TypeParagraphDAO)TypeParagraphDAO.getInstance();
Session s4=typeParagraphDAO.getSession();
Transaction tx4=typeParagraphDAO.beginTransaction(s4);
TypeParagraph typeParagraph=(TypeParagraph)typeParagraphDAO. getQuery("from TypeParagraph t where t.value=?",s4).setCacheable(false).setString(0, tipo).list().get(0);
System.out.println("TIPO DE PARRAFO:"+typeParagraph.getValue());
typeParagraphDAO.commitTransaction(tx4);
typeParagraphDAO.closeSession(s4);
Paragraph parrafo=new Paragraph();
parrafo.setContent(contenido);
parrafo.setCreationDate(new Date());
parrafo.setDeleted(false);
parrafo.setIdDocument(docu);
parrafo.setIdParentNode(new Long(ppid));
parrafo.setIdSecurityclas(secClas);
parrafo.setIdType(typeParagraph);
parrafo.setLevel("level");
parrafo.setLock(locked);
parrafo.setModificationDate(new Date());
parrafo.setOwner(owner);
parrafo.setTitle(titulo);
ParagraphDAO paragraphDAO=(ParagraphDAO)ParagraphDAO.getInstance();
Session s2=paragraphDAO.getSession();
Transaction tx2=paragraphDAO.beginTransaction(s2);
Integer idNuevoParrafo=paragraphDAO.save(parrafo);
System.out.println("PARRAFO GUARDADO OK");
paragraphDAO.commitTransaction(tx2); paragraphDAO.closeSession(s2);
if(docu==null)
{
System.out.println("RETURN NULL");
return null;
}
else if(docu.getName().equals(""))
{
resul=idNuevoParrafo.toString();
}
else
{
String nuevoDocumento=annadeParrafoAlXML(docu.getName(),idNuevoParrafo,titulo,ppid,"",tipo, locked, contenido, clasiSeg);
docu.setName(nuevoDocumento);
documentDAO.saveOrUpdate(docu);
resul=idNuevoParrafo.toString();
}
}
catch(Exception e)
{
System.out.println("Error en el Servicio de addParagraph--> "+e.getMessage());
return null;
}
|