Ah, darn it. This is for a vital product and my company wouldn't let me use 5.2 until its a final release. However, a little bit of digging I was able to improve on my previous code for 5.1.0.5. Albeit no @CommitAfter, but it does seem a better solution that using Transaction explicitly (which results in Tapestry-Hibernate exceptions). Basically replace Transaction with HibernateSessionManager injected into the constructor of the service. The instance I have is called hsm and you can see where I used it to replace Transaction txn.

    protected void executeUpdate(Entity entity){

        try{

        //    txn = ses.beginTransaction();

            System.out.println("In executeUpdate of DAO base class: about to commit 
a " + entity.getClass().getName());

            ses.update( (entity.getClass().cast(entity)) ); //Use reflection to 
cast the object correctly

            System.out.println("**Between ses.update and txn.commit**");

            hsm.commit();

    //        txn.commit();

            System.out.println("**after txn.commit**");

        }catch(HibernateException he){

            System.out.println("**Between ses.update and txn.rollback because of an 
exception! Exception: " + he);

            hsm.abort();

//            txn.rollback();

            throw new DAOException("Could not commit the " + entity.getClass().getName() 
+ " object!");

        }catch(ClassCastException cce){

            System.out.println("**Between ses.update and txn.rollback because of an 
exception! Exception: " + cce);

            hsm.abort();

//            txn.rollback();

            throw new DAOException("Could not commit the " + entity.getClass().getName() 
+ " object! ClassCastException reflecting the entity.");

        }

    }


Hopefully this is useful to some people trying to use Tapestry-Hibernate in 5.1.0.5, but also encountering issues with @CommitAfter and not liking the way Tapestry-Hibernate complains when you manage Transaction on your own. Once 5.2 comes out I'll try to remember to come back to this one and let you know about the @CommitAfter.

Thanks for the help Thiago.

-Rich

On 10/08/2010 02:11 PM, Thiago H. de Paula Figueiredo wrote:
On Fri, 08 Oct 2010 14:40:29 -0300, Rich M <rich...@moremagic.com> wrote:

Hi,

Hi!

I'm using 5.1.0.5, good to know about the annotations for services.

Please try 5.2 and tells us what happens.

Your code seems OK to me. My architecture looks exactly like yours for DAOs. :) But I don't use tapestry-hibernate myself, so I cannot say anything 100% sure about it.



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to