I am trying to get sequences with dynamic objects to work in EclipseLink and I need help.
I define my dynamic object as follows:
EntityManagerFactory emf = Persistence.createEntityManagerFactory("default"); EntityManager em = emf.createEntityManager(); Session session = JpaHelper.getEntityManager(em).getServerSession(); DynamicClassLoader dcl = DynamicClassLoader.lookup(session); Class<?> testClass = dcl.createDynamicClass("org.persistence.Test"); JPADynamicTypeBuilder test = new JPADynamicTypeBuilder(testClass, null, "TEST"); test.addDirectMapping("id", long.class, "T_ID"); test.setPrimaryKeyFields("T_ID"); test.addDirectMapping("col1", long.class, "T_COL1"); test.addDirectMapping("col2", int.class, "T_COL2"); test.addDirectMapping("col3", String.class, "T_COL3"); test.addDirectMapping("col4", String.class, "T_COL4"); test.addDirectMapping("col5", double.class, "T_COL5"); test.addDirectMapping("col6", double.class, "T_COL6"); DynamicHelper helper = new JPADynamicHelper(em); helper.addTypes(true, true, test.getType());
I noticed that everything was created as indicated. I tried to find documentation on how to use database sequences, and I noticed the JPADynamicTypeBuilder.configureSequencing (Sequence, String, String) method. But I could not find any example on how to do this. I played with this method, and I always end with the default sequence strategy, that is, a table called SEQUENCE.
I tried with a precompiled object using @GeneratedValue and @SequenceGenerator, and everything works fine, so I'm doing something wrong with dynamic objects.
Does anyone know what I could do wrong?
It seems irrelevant, but I still say that my database is Oracle.
Thanks in advance,
Rui
java dynamic sequence eclipselink entities
rpvilao
source share