At the risk of sounding like a fanatic... I would avoid using @CommitAfter or anything similar to do with persistence in page classes, it contravenes the OO "seperation of concerns" principle. (For the same reasons @CommitAfter should also not be in interface definitions as suggested in the Tapestry docs' because it's implementation specific.)
A better place would be a facade layer* between your DAOs and your page classes. This might not be justified if you want to keep your application architecture minimal, but even so it represents best practice and is a great place to code your business logic. Your page classes can then focus exclusively on delivery of page content and your DAOs on pure data access. regards, John *http://en.wikipedia.org/wiki/Facade_pattern ----- Original Message ----- From: Tony Nelson To: Tapestry users Sent: Wednesday, April 30, 2014 9:59 PM Subject: RE: @CommitAfter for GenericDao From my experience, you really don't want to put CommitAfter on a generic method like that. It really doesn't do what you expect in code like this: void saveSomeData(List<Widget> widgets) { for (Widget w: widgets) { widgetDao.saveWidget(widget); } } In that case, assuming saveWidget is annotated with @CommitAfter, every iteration of the loop will commit separately, which is likely not what you want. The @CommitAfter annotation is much better used in your page classes to commit transactions after a logical unit of work is complete. Tony > -----Original Message----- > From: Eugen [mailto:eugens...@gmail.com] > Sent: Wednesday, April 30, 2014 4:48 PM > To: Tapestry users > Subject: @CommitAfter for GenericDao > > Hi, > I try to use the CommitAfter on a GenericDao, but the method does not > commit the transaction. Does it exists a worcaround to do that? > > This is the code: > > public interface GenericDao<T> { > @CommitAfter > public void save(T entity); > } > > public abstract class GenericDaoImpl<T> { > @Override > public void save(T entity) { > entityManager.persist(entity); > } > } > > public interface UserDao extends GenericDao<User> { } > > public class UserDaoImpl extends GenericDaoImpl<User> implements > UserDao { } > > and respective advisor in AppModule: > > @Match("*Dao") > public static void adviseTransactions(JpaTransactionAdvisor advisor, > MethodAdviceReceiver receiver) { > advisor.addTransactionCommitAdvice(receiver); > } > > if I place the save() function into the UserDao all works fine. > > Thanks in advice > Eugen > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org Since 1982, Starpoint Solutions has been a trusted source of human capital and solutions. We are committed to our clients, employees, environment, community and social concerns. We foster an inclusive culture based on trust, respect, honesty and solid performance. Learn more about Starpoint and our social responsibility at http://www.starpoint.com/social_responsibility This email message from Starpoint Solutions LLC is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. Opinions, conclusions and other information in this message that do not relate to the official business of Starpoint Solutions shall be understood as neither given nor endorsed by it. ---------------------------------------------- T ususcib, -mil uer-usus...@tpetr.aace.rg Fr ddtina cmmnd, -mil uer-hlptaesryapch.og --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com