I agree the commit isn't necessary, but the session is created each time the display_id function is invoked. If you leave the session open then tests that open and run against the database don't work. It's nice to close the session either here or have the session closed in the controller so I closed it here.