Announcement Announcement Module
No announcement yet.
Get HibernateTemplate puts alock on databse Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Get HibernateTemplate puts alock on databse

    Hello All,
    I am using Spring2.0 and hibernate 3.2. I take the application context in the following manner, as I am not using the Spring's dependency Injection.

    static ApplicationContext ctx = new ClassPathXmlApplicationContext(new String[] {"applicationContext.xml"});

    static SessionFactory sessionFactory = (SessionFactory) ctx.getBean("sessionFactory");

    Now I don't know where I am committing mistake but when I call a hibernate function for 5-10 times, then a lock is put on the databse, it never retrieves any data. And no exception or error is thrown. Can anyone help me here as what should I do to correct this problem.

  • #2
    Don't create a new applicationcontext each time unless you want to run out of resources/connections/etc... that is step 1. Step 2 fix your transactions.

    Also why aren't you using dependency injection it makes your life a lot easier...


    • #3
      Hello Marten,
      Thanks for your reply. But my application context is static. So I dont think, my connections or resources will end up in this way. There may be something else.