-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Code hangs when doing some tasks or when commit
PostPosted: Sun Oct 14, 2012 4:11 pm 
Newbie

Joined: Sun Oct 14, 2012 3:46 pm
Posts: 3
Hello.
I have this method some where in a helper class:
Code:
public void bindMethodsElements(Node node, TemplateVersions tv, long wvId,
            List<FormAction> pbs, List<FormActionParameter> pes) {
        prepareSession();
        WorkflowVersion wv = (WorkflowVersion) session.get(
                WorkflowVersion.class, new Long(wvId));

        deleteAllProc(node, tv);

        for (int k = 0; k < pbs.size(); k++) {
            TemplateActions ta = new TemplateActions();

            ta.setTemplateVersions(tv);
            ta.setNode(node);
            ta.setWorkflowVersion(wv);

            TemplateElements te = (TemplateElements) session.get(
                    TemplateElements.class, new Long(pbs.get(k).getBtnId()));
            ta.setTemplateElements(te);
            BusinessLogicMethods bm = (BusinessLogicMethods) session.get(
                    BusinessLogicMethods.class,
                    new Long(pbs.get(k).getProcId()));
            ta.setBusinessLogicMethods(bm);

            session.save(ta);

            // get params
            for (FormActionParameter formActionParameter : pes) {
                if (formActionParameter.getMethodId() != ta.getBusinessLogicMethods().getId()
                        || formActionParameter.getBtnId() != ta.getTemplateElements().getId()) {
                    continue;
                }
                TemplateActionsParams tap = new TemplateActionsParams();
                tap.setTemplateActions(ta);
                BusinessLogicMethodsParam pm = (BusinessLogicMethodsParam) session.get(BusinessLogicMethodsParam.class,
                        new Long(formActionParameter.getParamId()));

                if (pm != null) { // not a return
                    tap.setBusinessLogicMethodsParam(pm);
                    tap.setParamType(formActionParameter.getParamType());
                    tap.setName(formActionParameter.getParamPureName());
                } else {
                    tap.setBusinessLogicMethodsParam(null);
                    tap.setParamType(ta.getBusinessLogicMethods().getReturnType());
                    tap.setName("method return");
                }
                switch ((int) formActionParameter.getBindType()) {
                    case 0:
                        TemplateElements tpe = (TemplateElements) session.get(
                                TemplateElements.class, new Long(formActionParameter.getElmId()));
                        if (tpe != null) {
                            tap.setTemplateElements(tpe);
                        }
                        break;
                    case 1:
                        NodeInTokens nit = (NodeInTokens) session.get(
                                NodeInTokens.class, new Long(formActionParameter.getTokenId()));
                        if (nit != null) {
                            tap.setNodeInTokens(nit);
                        }
                        break;
                    case 2:
                        NodeOutTokens not = (NodeOutTokens) session.get(
                                NodeOutTokens.class, new Long(formActionParameter.getTokenId()));
                        if (not != null) {
                            tap.setNodeOutTokens(not);
                        }
                        break;
                    case 3:
                        // forcibly pm!=null
                        if (pm == null) {
                            return;
                        }
                        break;
                    default:
                        break;
                }

                session.save(tap);
            }
        }
        System.out.println("start commit");
        commitSession();
        System.out.println("end commit");
    }


sometimes this code stops executing in some point inside the loop or hangs in commitsession() call.
I don't know the reason.. I have faced this problem in other places without any advance in solving it.
please I need help I have a task should be achieved.


Top
 Profile  
 
 Post subject: Re: Code hangs when doing some tasks or when commit
PostPosted: Tue Dec 11, 2012 5:39 am 
Newbie

Joined: Sun Oct 14, 2012 3:46 pm
Posts: 3
Hello..
the problem was solved.
It was because the bad session management. so a table lock occurs prevent updating records in it..


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.