0 Replies Latest reply on May 27, 2007 2:07 PM by Avihai Marchiano

    Design question - how to create a thread safe operation in s

    Avihai Marchiano Novice


      I have the following problem.

      I need to create a new EntityManagerFactory and rebind it to the JNDI:

      EntityManagerFactory emf = new Ejb3Configuration().setProperty(
      "hibernate.connection.datasource", "java:/DefaultDS").setProperty(
      "hibernate.hbm2ddl.auto", "create").setProperty("hibernate.show_sql", "true")
      new InitialContext().rebind("java:/sample3", emf);

      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?

      Thank you