Results 1 to 3 of 3

Thread: Hibernate updates not committing

  1. #1

    Default Hibernate updates not committing

    I have a nightly job that retrieves 2000+ objects sets a value on them and then attempts to persist them. However it is crashing because all the updates are waiting to commit which causes the system to slow down, which causes method to not complete, which causes the commits to not get fired. If I limit my data returned to 100 everything completes and commits as expected. How can I tell hibernate to commit more frequently?

    Code:
    		List<Widget> allWidgets = widgetManager.findWidgets(); 
    		for (Widget widget : allWidgets) {
    			Widget activeWidget = widgetManager.getWidget(widget.getParentWidget().getId());
    			activeWidget.setSomeCost(activeWidget.getCost() * someValue); 
    			widgetManager.updateWidget(activeWidget); 
    			
    		}
    Thanks in advanced,

    Keith

  2. #2
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,796

    Default

    Hello Keith

    If I limit my data returned to 100 everything completes and commits as expected.
    How can I tell hibernate to commit more frequently?
    I suggest you strongly check Spring Batch, it can work with Hibernate
    There you can work with chunks and transactional support
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

  3. #3
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    I suggest a read on batch in combination with Hibernate... You want to flush and clear after each x items. This has to do with first level caching and dirty checking the more elements in the first level cache the longer a dirty check takes...
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •