Hi,
in my project, I have coded a callable method through the JMX console, in charge of migrating data from an external database, to the main datastore in my cuba application. In this task, I create jdbc connections and read this external db which is the source I use to populate my entity instances, which are among them interrelated, so there are instance references at many points. After completion of each record I store the info in the main datastore.
In previous projects I always used to include cascading annotations to persist data, and everything worked fine. Now using CUBA, at some point (when implementing EntityListeners), I was discouraged to use such annotations, then they prevent EntityListeners from being called.
My problem is that if I remove those annotations, I am not being able to import the data in the main datastore, then I get synchronization errors constantly of the form:
java.lang.IllegalStateException: During synchronization a new object was found through a relationship that was not marked cascade PERSIST
I try to merge the affected instances before commiting the main transaction with no luck. Have also tried persisting but doesn’t work either.
In a previous post I asked what DataImport strategies were more recommendable, and I was pointed to the implementation of a JMX bean method. But through this method, I am not being able to solve the above mentioned, without annotating the entities with the cascade options.
Any alternatives?
Regards,
Carlos.