tapestry-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Luther Baker" <lutherba...@gmail.com>
Subject architectural question
Date Fri, 05 Dec 2008 18:20:06 GMT
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

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