Announcement Announcement Module
Collapse
No announcement yet.
Will this execute as a single transaction? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Will this execute as a single transaction?

    Hi,

    I'm using Spring 3.1.0.RELEASE. I want to use Spring's @Transaction annotation to manage my transactions in my service class. I have three methods marked with "@Transactional(readOnly=false)" and one of them invokes the other two ...

    Code:
    	@Transactional(readOnly=false)
    	public void refreshEventsDb() { 
    		// Purge everything from Events table.
    		deleteAllEvents();
    		final Set<EventFeed> eventFeeds = eventFeedsDao.getAllEventFeeds();
    		for (final EventFeed eventFeed : eventFeeds) { 
    			final List<Event> allEvents = eventFeed.getEvents();
    			for (final Event event : allEvents) {
    				if (!event.isInThePast()) {
    					saveEvent(event);
    				}	// if
    			}	// for
    		}	// for
    	}	// refreshEventDb
    
    	@Transactional(readOnly = false)
    	public void saveEvent(final Event event) { 
    		...
    	}	// saveEvent
    
    	@Transactional(readOnly=false)
    	public void deleteAllEvents() {
    		...
    	}
    Will the method that invokes the other two, "refreshEventsDb", execute as a single transaction? If not, how do I make it do that?

    Thanks, - Dave
Working...
X