| Author |
How to inject EntityManager into singleton at startup?
|
Volodymyr Levytskyi
Ranch Hand
Joined: Mar 29, 2012
Posts: 187
|
|
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 Levytskyi
Ranch Hand
Joined: Mar 29, 2012
Posts: 187
|
|
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 !!!
|
 |
 |
|
|
subject: How to inject EntityManager into singleton at startup?
|
|
|