I have the following problem.
I need to create a new EntityManagerFactory and rebind it to the JNDI:
[code]EntityManagerFactory emf = new Ejb3Configuration().setProperty(
"hibernate.hbm2ddl.auto", "create").setProperty("hibernate.show_sql", "true")
new InitialContext().rebind("java:/sample3", emf);[/code]
I need that this code will be thread safe, because i dont want that 2 threads simultaneously will create the same EntityManagerFactory .
How can I do it in a stateless?
Do it in a startup class... Any particular reason to put it in stateless sb
I didn't understand what do you want !
Do you want 1 instance of EntityManagerFactory only that another place(method) it'll use it?
Remember, about stateless's life cycle, wherever you must analyze what do you need.
I advise you for each method you need use it, you to create a new instance of EntityManagerFactory, because the objetc will living while the method to be living.