0

I have written this code to insert into a column in a table but it does not, I don't know what exactly is wrong with the code.

"WEB-INF.views.Register.cyclosUsersCreditLimit.value" is the path to an input control (textbox) on a jsp page. I think maybe possibly this is where I missed it. What needs to be done?

This is the DAO class:

@Override
        public void saveCyclosUsers(CyclosUsers cyclosUsers) {
            Object inputLowerCredit = null;
            inputLowerCredit = sessionFactory.getCurrentSession().createSQLQuery("UPDATE Cyclos30.accounts SET credit_limit =" +"WEB-INF.views.Register.cyclosUsersCreditLimit.value" +" " 
                                                                                  +"WHERE owner_name =" +"WEB-INF.views.Register.ownerName.selectedItem");
            if(inputLowerCredit != null)
            {
                try
                {
                    sessionFactory.getCurrentSession().saveOrUpdate(inputLowerCredit);
                }
                catch(Exception exception)
                {
                    exception.printStackTrace();
                }
            }
        }
6
  • first of all invoking fields from JSPs like that is not exactly best practice, can't you pass the form via a Controller to the service and then further on to the DAO? might be easier to debug Dec 16, 2013 at 12:25
  • can you give us the error stack for this application? or is there any log displayed?
    – Rugal
    Dec 16, 2013 at 12:26
  • You are creating a Query object and try to pass that to the saveOrUpdate method, that obviously is never going to work. Seems to me you lacking basic understanding what hibernate is and does? What you want to do is to bind your input to the object you want to update, then store that object. Hibernate takes care of updating the fields.
    – M. Deinum
    Dec 16, 2013 at 12:32
  • it does not give any error. It simply does not update. From what @Bogdan Emil Mariesan, appreciate your comment. Could you give me a simple code or a tutorial that does that? I am a newbie. please your valid contributions would be highly appreciated by either providing the simple code that corrects my error or a tutorial that achieves what i want to do. Thanks.
    – ken4ward
    Dec 16, 2013 at 12:42
  • try viralpatel.net/blogs/… Dec 16, 2013 at 12:48

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.