I'm creating a dynamic class in EclipseLink, but after created can not add a new field to my class.
When I add a new field, eclipselink creates a column in the table but when trying to set the value in this column the EntityManager can not salver and puts NULL.
How do I add a new field to my DynamicType after adding it in JPADynamicHelper?
DynamicClassLoader dcl = new DynamicClassLoader(Thread.currentThread().getContextClassLoader());
Class<?> exClass= dcl.createDynamicClass(packagePrefix + "Example");
JPADynamicTypeBuilder exBuilder= new JPADynamicTypeBuilder(doClass, null, "Example");
// configure builber
exBuilder.setPrimaryKeyFields("ID");
exBuilder.addDirectMapping("id", int.class, "ID");
exBuilder.addDirectMapping("name", String.class, "NAME");
// configure descriptor
ClassDescriptor exDescriptor = exBuilder.getType().getDescriptor();
//configure sequence id
exBuilder.configureSequencing("DYNAMIC_SEQ", "ID");
// EntityManagerFactory
emf = createEntityManagerFactory(dcl, "default");
JPADynamicHelper helper = new JPADynamicHelper(emf);
//Here I add the helper type
helper.addTypes(true, true, exBuilder.getType());
// Create tables and relationship
new SchemaManager(helper.getSession()).extendDefaultTables(true);
//Adding a new field
exBuilder.addDirectMapping("id", int.class, "ID");
//here I add the helper again but do not add
helper.addTypes(true, true, exBuilder.getType());
Can anyone help me?