Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Use of persistence unit in JPA

 
satish bodas
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ,
I was wondering what could be the use of the "persistence-unit"

Is it something that can be used if I wanted to have connectivity to more than one database ( by defining multiple "persistence-unit" elements ) ?

Also didnt know what the purpose of the attribute :: " transaction-type="RESOURCE_LOCAL" " is ?

Thanks ,
~satish
 
Thiebaut olivier
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,

You can describe mutltiple connexion in a persistence.xml file, unit test use "RESOURCE-LOCAL" for example. But if you develop an J2EE application with a connexion pool you must use transaction-type="JTA"

RESOURCE-LOCAL -> jdbc simple connect
JTA _> pool connect


olivier
 
satish bodas
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks .

So we should use RESOURCE LOCAL in a non managed environment ( outside of Container ) while we should use JTA when inside a container

~satish
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!