Announcement Announcement Module
Collapse
No announcement yet.
Hibernate updates not committing Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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

    Comment


    • #3
      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...

      Comment

      Working...
      X