user3528733
user3528733

Reputation: 1299

Stand-alone JPA and entityManager

I found sth like this:

My questions are:

Upvotes: 0

Views: 267

Answers (1)

V G
V G

Reputation: 19002

Answers:

  1. Standalone means more things, like: you create by your own instances of EntityManager (vs. they are not injected), you begin and commit by yourself transactions, you are responsible for propagating the transaction (which code (e.g of different services) gets executed in which transaction).

  2. Transaction demarcation is the way you start, propagate and end the transaction. If you use a managed environment (with JTA), then you can annotate the service methods somehow and control how the "transaction is propagated" between different service calls. Say: with only annotations you can decide that on calling PersService.addPerson(Person person) a transaction T1 automatically is begun, and that code executed in AddressService.saveAddress(Address address) (called from addPerson()) is executed in the same transaction T1 (or if you want, a new transaction T2). Also with JTA, different databases can do work within the same transaction.

  3. Yes, Spring can be and is almost always configured to work as a managed environment. But it can be configured to work also in a standalone mode. Other known managed environments are the Java EE enviroments (Application servers like WildFly or Glassfish).

Upvotes: 2

Related Questions