Home > > JNDI in JSE?


Is it possible to use JNDI to fetch an EntityManager(!) in JSE, not JEE?
The alternative I have is store the EM in a Thread(Group) based store and fetch that on demand.
Oh, actually the reason is quite simple: I want to open an EM, store it somewhere and fetch it when I need it versus having to drag it through all method calls.
As said, it can be stored in a Thread based repository, but since JEE is using JNDI to access it, I was thinking that maybe doing something similar in JSE might be practical too.
Can you elaborate on how your suggestion would work? You mean a "Bootstrap" class which opens the EM and holds it in a static variable. Singleton alike?
Read the other 3 answers