Grails: how to structure transactions when I want to continue validating even after the transaction has already failed

后端 未结 2 1278
臣服心动
臣服心动 2021-01-26 16:45

My users are uploading a csv or xls or whatever and each line is going to be an instance of a domain object I save. If any of the lines fail I want the whole thing rolled back,

2条回答
  •  深忆病人
    2021-01-26 17:15

    here is what i am thinking:

    1 . Set a flag that signals ALL CLEAR and commit the transaction manually at the end if all is clear.

    or

    2 . Commit each line in a separate transaction capturing errors of failed lines and skipping over failures.

提交回复
热议问题