Not really. You choose transaction type when you configure your persistence
unit, you can't switch it later or even choose between them. When your entity manager is JTA, getTransaction() throws
IllegalStateException. Generally (as the specs say), in an
EJB container
you should use UserTransaction, and use EntityTransaction in JavaSE when no transaction manager (JTA) is available. UserTransaction is required in JavaEE environments, and there is really no advantage to use EntityTransaction in EE (at least I think so).