Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
    Bookmark Topic Watch Topic
  • New Topic

JPA JSE EntityListener and Singleton

 
Markus Schmider
Ranch Hand
Posts: 132
1
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hello I have a JSE Application using JPA 2.1
I have run into a curious problem.
I am using an EntityListener for auditing purposes



This listener is dependent on UserService.
I have tried to make that a Singleton:



This in turn uses PersistenceService (which should be a singleton too ...) and which should provide one and only one instance of the EntityManagerFactory
to the application:



When I run tests I see that a lot of instances of these "Singletons" are created until the application crashes because all connections to the database are used up.
When I remove the EntityListener this behavior stops, but I really need the AuditListener
What is going on? And how can I correct this problem?



Many thanks for any hints
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Report post to moderator
Locking this one since this got answered in your other topic here http://www.coderanch.com/t/635105/java/java/Singleton.
 
    Bookmark Topic Watch Topic
  • New Topic