• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Persistence Unit Scoping

 
Remko Strating
Ranch Hand
Posts: 893
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Reading EJB3 in action I discovered at page 413 the local persistence unit take precedence over the global scoped. During testing I already discovered this.

Only this gives me a practical problem, because I test with a unit test my entities which have an another database and run my application on the production environment. I can build a custom entity manager factory for solving this problem which will guard the context in which it's running and then start a different entity manager factory depending on the name. The reason for developing this is that I don't want to adjust the persistence.xml for every update which is error prone.

Only my question is I'm not the first one having this problem so is there a general solution for this.

 
Remko Strating
Ranch Hand
Posts: 893
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have developed a factory for this which takes into account this behaviour.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic