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

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

      Hey,

      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")
      .addAnnotatedClass(Hotel.class).addAnnotatedClass(Room.class)
      .buildEntityManagerFactory();
      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