Greetings,
My application is creating entity beans dynamically, so, when i create i new entity bean i
must update the Ejb3Configuration to let it know there is a new bean, i make this using
the method 'addAnnotatedClass(Class clazz)' and 'buildMappings()'.
I have several EntityManagerFactory, created using the clas Ejb3Configuration , using the
method (createEntityManagerFactory()).
The problem is how to update the EntityManagerFactory that has been already created,
before the update of the Ejb3Copnfiguration.
If i want to do it, i have to create a new EntityManagerFactory from the Ejb3Configuration
updated.
Example:
Ejb3Configuration ejb3Configuration = new Ejb3Configuration();
Properties p = new Properties();
//Config properties .......
ejb3Configuration.addProperties(p);
//add some entities
ejbConfiguration.addAnnotatedClass(Entity1.class);
ejbConfiguration.addAnnotatedClass(Entity2.class);
//Create the factory
EntityManagerFactory factory = ejbConfiguration.createEntityManagerFactory();
.....
.....
.....
Then in some point my application needs to know about a new entity bean
so i add it to the configuration i've been using:
ejbConfiguration.addAnnotatedClass(EntityBean3.class);
EntityManager entityManager = factory.createEntityManagerFactory();
//Use this EntityManager to persist the new entity
entityManager.persist([instance of EntityBean3]);
In this point i got the error: EntityBean3 not mapped, that is because the factory is not
synchronized with the Ejb3Configuration.
How can i make this sync ?. I'm working creating a new EntityManagerFactory
everytime the application generates a new entity bean, but i think that is really ugly,
not to mention the performance problems for the application.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3956813#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...