|Relation between Mulitple instance of EntityManagerFactory [message #810842]
||Thu, 01 March 2012 16:00
| Kamran Muhammad
Registered: March 2012
I am creating entitymanagerfactory and adding dynamic types to it using JPADynamicHelper class. Types are added successfully.
Now if i go and create a new instance of EntityManagerFactory
with same name and properties . Newly created Factory already has dynamic types earlier added for previous instance of Entity Manager Factory. What is the reason. and what is the relation between multiple instnace of Entity manager factory here.?
Following is the out line of code.
EntityManagerFactory factory = Persistence.createEntityManagerFactory("elink", properties);
List<DynamicType> dynamicTypes = DynamicTypeGenerator
JPADynamicHelper helper = new JPADynamicHelper(factory);
helper.addTypes(false, false,dynamicTypes.toArray(new DynamicType[dynamicTypes.size()]));
//now again creating entity manager factory with same name and properties.
EntityManagerFactory factory2 = Persistence.createEntityManagerFactory("elink", properties);
JPADynamicHelper helper2 = new JPADynamicHelper(factory2);
DynamicType type = helper2.getType(dynamicTypes.get(0).getName());
//returned type is not null. This time factory already has dynamic types earlier loaded. Reason why it has those.
[Updated on: Thu, 01 March 2012 16:02]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.01722 seconds