I have a jax-rs REST service that POSTs an
ArrayList<Book>
objects to the server.
On the server, I loop through each Book, convert it into a BookEntity (I'm using JPA), and then persist each book.
If any BookEntity fails to be persisted, I'd like the entire POST operation to fail and no Book Entities in that submitted ArrayList to be persisted. I want to rollback the entire operation so that it's all or nothing.
Does merely using Container Managed Transactions (which I understand you get for free by just injecting your Entity Manager) do the trick? Or do I need JTA to do this? I'm a bit confused about what part of transaction management is automatically done?
Thank you!