tapestry-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Luther Baker" <lutherba...@gmail.com>
Subject Re: architectural question
Date Sat, 06 Dec 2008 00:04:41 GMT
Thanks - that worked just fine.

-Luther


On Fri, Dec 5, 2008 at 1:41 PM, James Hillyerd <james@hillyerd.com> wrote:

> Look at the bottom of this page:
>
> http://tapestry.apache.org/tapestry5/tapestry-hibernate/userguide.html
>
> It explains how to get @CommitAfter working with DAOs.
>
> -james
>
> On Fri, Dec 5, 2008 at 10:20 AM, Luther Baker <lutherbaker@gmail.com>
> wrote:
>
> > If I inject a Hibernate session into my DAO and have my Tapestry
> Controller
> > invoke that, is there a Tapestry way that I can tell hibernate to start
> and
> > commit a transaction via annotations or configuration?
> >
> > IE:
> >
> >
> http://tapestry.apache.org/tapestry5/tapestry-core/ref/org/apache/tapestry5/corelib/components/BeanEditForm.html
> >
> > public class CreateUser
> > {
> >    @Inject
> >    private UserDAO userDAO;
> >
> > ...
> >    Object onSuccess()
> >    {
> >        userDAO.add(user);
> >
> >        return UserAdmin.class;
> >    }
> > }
> >
> > public class UserDAO
> > {
> >    @Inject
> >    private Session session;
> >
> >    void add(User user)
> >    {
> >        session.persist(user);
> >    }
> > }
> >
> >
> > I tried to use @CommitAfter in my DAO but that didn't work. I essentially
> > want to simulate:
> >
> >    void add(User user)
> >    {
> >        session.beginTransaction();
> >        session.persist(user);
> >        sessino.getTransaction().commit();
> >    }
> >
> > but I don't want to explicitly code this in my DAO for fear that I may
> have
> > some instances where the the transactional boundaries must be larger.
> >
> > Maybe this isn't a Tapestry specific thing - but I'm not sure how to
> inject
> > the Hibernate Session into my DAO but have my Tapestry Controller define
> > the
> > transactional boundaries ... was hoping some Tapestry annotations might
> > help
> > me out.
> >
> > -Luther
> >
>
>
>
> --
> James A. Hillyerd <james@hillyerd.com>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message