JPA - When to use getTransaction() when persisting objects

后端 未结 4 1731
长情又很酷
长情又很酷 2020-12-24 12:07

I\'ve recently started working with JPA on the Google App Engine. In reading some examples, I\'ve noticed a couple of variations in the way objects are persisted. In one cas

4条回答
  •  时光说笑
    2020-12-24 13:13

    In GAE there is no Java EE/JTA so ignore terms such as bean managed transaction (BMT), and container managed transactions (CMT).

    Your work is either transactional (where you want multiple objects to go to the datastore at once, or all to fail - this is where you have getTransaction() used), or nontransactional (where everything goes to the datastore one by one, and the failure of one persist doesn't affect others - this is where you just call persist()/merge()/remove()).

提交回复
热议问题