wayne
thats not all complete problem -
as the remote debugger reported problems with the transaction failure when
remote debugging into the server, i rewrote the removeLinks method in the local
application client using an application scoped EM.
that way i could run the debugger in local mode.
| public static boolean removeLink (Node fromNode, Node remoteNode)
| {
| EntityManager em;
| EntityManagerFactory emf ;
| List<Link> res;
| boolean result = false;
|
| emf = Persistence.createEntityManagerFactory("embedDS");
|
| em = emf.createEntityManager();
|
| try
| {
| EntityTransaction t = em.getTransaction();
|
| t.begin();
| fromNode = em.merge(fromNode);
| remoteNode = em.merge(remoteNode);
| Query q = em.createNamedQuery("findLinksBetweenNodes");
| q.setParameter("toNode", remoteNode);
| q.setParameter("fromNode", fromNode);
|
| res = (List<Link>)q.getResultList();
| if (res != null && res.size () == 1)
| {
| Link link = res.get(0);
| remoteNode.deleteLinkFrom(link);
| fromNode.deleteLinkTo(link);
| em.remove(link);
| result = true;
| }
| else
| {result = false;}
|
| t.commit();
| return result;
| }
| finally
| {
| em.close();
| emf.close();
| }
|
| }
|
this essentally throws the same optimistic lock error - so its something to do
with the transaction that this lives in updates the version for the attached
elements. when this completes the next step in the main application path
|
| //local if (removeLink(uNode, zNode))
| if (nodeEAO.removeLink(uNode, zNode))
| {
|
| System.out.println ("deleted link : \n");
| }
|
| //update to latest version number
| yNode = nodeEAO.refresh(uNode);
|
the code errors with optimistic lock when i try and do an em.merge within the
nodeEAO.refresh routine.
what this kind of implies i think is that i have to issue another "find"
operation to reread a fresh copy of the entity back to avoid this rather than
being able to "merge" the starting uNode back into the persistence context.
Is this the only/correct way to proceed - or am i not understanding properly
and theres a easy 'correct' fix that would allow me to avoid the exception (I
havnt tried to take the version annonation of yet - and see if it handles it
without the optimistic lock force enabled.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4119816#4119816
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4119816
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user