[jboss-user] [EJB 3.0] - Design question - how to create a thread safe operation in s

avihaimar do-not-reply at jboss.com
Sun May 27 14:07:20 EDT 2007


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


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4048923#4048923

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4048923



More information about the jboss-user mailing list