-
1. Re: Long running transaction - multiple save points?
andrew.rw.robinson Jul 9, 2006 12:42 AM (in response to andrew.rw.robinson)Just some more information,
I tried using merge to re-associate the object with the manager. The problem is that I have no active transaction, because I don't want the data committed yet (I using SeamExtendedManagedPersistencePhaseListener)
So when I called my method with NOT_SUPPORTED transaction type, I got an error. Method:private void beginEditProperties() { if (clone != null) { if (editingUser.getId() != null) editingUser = entityManager.merge(clone); clone = null; } try { clone = ObjectUtils.deepClone(editingUser); } catch (Exception ex) { handleActionError(ex); } }
Exception:Caused by: java.lang.IllegalStateException: No transaction. at org.jboss.tm.TxManager.setRollbackOnly(TxManager.java:751) at org.hibernate.ejb.AbstractEntityManagerImpl.markAsRollback(AbstractEntityManagerImpl.java:392) at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:545) at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:567) at org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:210) ...
So I seem to be stuck as I can't start a transaction, as EntityManager has no way of saying not to flush on this JSF action and I need the transaction to re-associate my clone with the entity manager in order to lazy load my children objects that may not have been loaded yet. -
2. Re: Long running transaction - multiple save points?
pmuir Jul 9, 2006 4:25 AM (in response to andrew.rw.robinson)Do the popups share entitiy beans or are entities attached to only one popup?
-
3. Re: Long running transaction - multiple save points?
andrew.rw.robinson Jul 9, 2006 1:58 PM (in response to andrew.rw.robinson)The User class is shared across popups. The child objects are only used in one popup.
I think I have an easier solution though after some thought. I think I will make editing user changes immediately saved (save per page) and new users, just queue all the changes to the end and have one save, but no cancel button.
That will fit in the web-page style editing much easier. -
4. Re: Long running transaction - multiple save points?
pmuir Jul 9, 2006 3:24 PM (in response to andrew.rw.robinson)I think I understand what you're trying to design (perhaps I don't thought ;)
I do something similar: For new users/whatever I have a wizard that includes the relevant detail page for that step. For editing I use a tabbed panel (tomahawk atm) and include the detail page (same as included for wizard) for each tab.
I persist the new user when the finish button is clicked, canel is easy here - just abandon the conversation.
I set the FlushMode to never for the edit, and only flush when apply or save is clicked (so cancel is just a navigation).
I use cascade so you don't need to choose whether to persist or not objects associations.
BUT I never worked out a way to do popups elegantly! -
5. Re: Long running transaction - multiple save points?
gavin.king Jul 10, 2006 1:09 PM (in response to andrew.rw.robinson)I think your approach with merge() in a non-transactional method is the correct one. HEM should _not_ throw an exception if the PC is an extended PC. So either (a) your PC is not an extended PC and it should be or (b) this is a bug in HEM.