-
1. Re: Howto detach entity from entitymanager
nickarls Mar 5, 2008 11:59 AM (in response to boevink.boevinkp.xs4all.nl)use manual flush mode
-
2. Re: Howto detach entity from entitymanager
nickarls Mar 5, 2008 12:04 PM (in response to boevink.boevinkp.xs4all.nl)entityManager.clear() detaches everything so it might be overkill. Apparently there is no detach for a single entity in JPA?
-
3. Re: Howto detach entity from entitymanager
boevink.boevinkp.xs4all.nl Mar 5, 2008 12:14 PM (in response to boevink.boevinkp.xs4all.nl)
Nicklas Karlsson wrote on Mar 05, 2008 11:59 AM:
use manual flush mode
This only affects the flushmode...(the moment when changes are synchronised with the db).
At conversation end, the changed are still flushed.... -
4. Re: Howto detach entity from entitymanager
nickarls Mar 5, 2008 12:20 PM (in response to boevink.boevinkp.xs4all.nl)
This only affects the flushmode...(the moment when changes are synchronised with the db).
At conversation end, the changed are still flushed....
Hmm. I was under the impression that it manual flush mode, anything that isn't explicitly flush()ed gets lost...
-
5. Re: Howto detach entity from entitymanager
ajaygupta0512 Mar 5, 2008 3:24 PM (in response to boevink.boevinkp.xs4all.nl)Folks,
Here are my 25 cents based on my knowledge after working with Seam and EJB3. Hope this helps:
1. manual-flush mode can only be used if you are using Seam managed persistence contexts (SMPC) and are using Hibernate as the JPA provider. Both of these conditions need to be true for someone to be able to use manual flush mode.
2. Even with manual flush mode set, your changes won't be automatically flushed until you call em.flush() explicitly (even if the conversation ends and you forgot to do em.flush(), changes will not be flushed and you might end up). However, when you do call modifyEM.flush(), Seam will write all changes made to the persistenc context without having any control over it.
3. To detach a specific entity, you call em.refresh(entity) which discards all the in-memory changes made on that entity and if you return the newly loaded entity back to the Web Tier, you will have a new detached instance.
4. em.clear() discards all modified entities in the persistence context. So, only use it when you intend to do like a
Reset Screen values
functionality in your application.Sounds like in your multi-wizard app, em.refresh() is what y ou need to do to implement
Reset
functionality. Hope this helps.