This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to inject EntityManager into singleton at startup?

 
Volodymyr Lysenko
Ranch Hand
Posts: 511
1
Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!

I want to query database when application starts. I want to do such queries only once !
For this I use singleton with @Startup annotation.

Unfortunately all ways to obtain EntityManager fails. I always have EntityManager is null.
If I inject session bean into my singleton it is null too.

How to inject EntityManager into singleton at startup?
How to perform quries on database only once per application at singleton startup?

Thank you!
 
Volodymyr Lysenko
Ranch Hand
Posts: 511
1
Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have solved it already.

The problem was that in singleton's constructor entitymanager was really null.
BUT in @PostConstruct lifecycle method my entitymanager was not null !!!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic