Yes, you are right. This is very hacky. But it even gets worse. I need to switch this temporary, and revert it back. So the Cascade All will take effect only to load the graph, and insert/update the date base from file. Then I need it back to the original configuration.
I think I need to reconsider this approach. If you have any an advice please let me know. On Fri, Jun 13, 2014 at 4:43 PM, Rick Curtis <curti...@gmail.com> wrote: > > I am wondering if this can be done programmatically AND at runtime > (After the > entityManager is created). > Yes I'm sure it is possible to do programmatically. The problem you're > going to run into with changing this after the EntityManager is loaded is > that we will have already processed all of our metadata and the setting > will have already taken hold. It's possible to walk through the entire > metadata tree and reset this value for each relationship, but that would be > very hacky. > > > On Fri, Jun 13, 2014 at 3:14 PM, Mansour Al Akeel < > mansour.alak...@gmail.com > > wrote: > > > Rick, > > Thank you a lot for your help. > > I am wondering if this can be done programmatically AND at runtime (After > > the entityManager is created). > > > > Thank you. > > > > > > > > On Fri, Jun 13, 2014 at 9:18 AM, Rick Curtis <curti...@gmail.com> wrote: > > > > > You can enable cascade persist globally via the jpa defined > > > persistence-unit-metadata defauls element in the orm.xml See the > snippet > > > below: > > > > > > <entity-mappings > > > xmlns="http://java.sun.com/xml/ns/persistence/orm" > > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > > > xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm > > > orm_2_0.xsd" > > > version="2.0"> > > > <persistence-unit-metadata> > > > <persistence-unit-defaults> > > > <cascade-persist/> > > > </persistence-unit-defaults> > > > </persistence-unit-metadata> > > > ... > > > </entity-mappings> > > > > > > Thanks, > > > Rick > > > > > > On Thu, Jun 12, 2014 at 9:09 PM, Mansour Al Akeel < > > > mansour.alak...@gmail.com > > > > wrote: > > > > > > > Is the a way to enable cascade persist globally and pro grammatically > > > using > > > > an EntityManager instance ?? > > > > > > > > > > > > Thank you. > > > > > > > > > > > > > > > > -- > > > *Rick Curtis* > > > > > > > > > -- > *Rick Curtis* >