Last active
August 29, 2015 13:59
-
-
Save yuki-takei/10561649 to your computer and use it in GitHub Desktop.
Grails Script (gant) で session を flush する ref: http://qiita.com/yuki-takei/items/3856c9a65c328d3d65b4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def persistenceInterceptor = appCtx.containsBean('persistenceInterceptor') ? appCtx.persistenceInterceptor : null | |
persistenceInterceptor?.init() | |
try { | |
// サービスメソッドをcall | |
def service = appCtx.getBean("userService") | |
service.updateUser() | |
} | |
finally { | |
persistenceInterceptor?.flush() | |
persistenceInterceptor?.destroy() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Transactional(propagation=Propagation.REQUIRES_NEW) | |
def updateUser() { | |
User user = User.findById(1L) | |
user.doSomething() | |
user.save() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment