This content has been marked as final.
Show 2 replies
-
1. Re: EntityController.persist + Redirect problems
thokuest Jul 26, 2010 1:46 PM (in response to vestnik)entityManager.persist(entity); entityManager.flush(); // force INSERT
Hope that helps!
-
2. Re: EntityController.persist + Redirect problems
vestnik Jul 27, 2010 4:20 AM (in response to vestnik)Thanks for your answer. When I start play with flush I found that on the line redirect.setParameter(
id
,entity.getId()); I'm actually using wrong entity instance and id parameter is set to 0. After fixing it this code works correctly:getEntityManager().joinTransaction(); Entity entity = new Entity(); ... // filling values from form ... persist(entity); Redirect redirect = Redirect.instance(); redirect.setViewId("/entity/view.xhtml"); redirect.setParameter("id",entity.getId()); redirect.setConversationPropagationEnabled(false); redirect.execute();