This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Maintaining transation is required only if you are using application managed transation. If you are using container managed transation, then there is no need to opening transation and comitting it.
I think you are creating entity manager by using entity manager factory. If you are creating entity manager by using entity manager factory, then this is a example of application managed transation and you need to maintain transation other wise your data will not reflect to the database.
Container managed entity manager is not supported in Java SE env. you need to use Java EE env. otherwise in Java SE , you can use container managed entity manager with help of Spring. By using Spring dependency injection.