0 Replies Latest reply on Dec 13, 2004 8:11 AM by Raj Subramani

    Hibernate(JBoss4) and the Sequence Block Pattern

    Raj Subramani Newbie

      Going through the hibernate docs (section 5.1.4) on id's, under Hi/Lo Algorithm it says


      .. you can't use hilo .. when Hibernate is using an application server datasource to obtain connections enlisted with JTA.


      I am therefore using the sequence block pattern (as per the EJB-DesignPattern book's description of it). I have used this with EJB's before so thats not a problem.

      The question is whether to use (the sequence block) within the
      tx=session.beginTransaction
      tx.commit();
      


      block, or before it. Since the sequence block uses a "RequiresNew" within its transaction context, would this create a problem when used inside a hibernate transaction context?

      At the moment I am using it outside of Hibernate's context, so if the hibernate db interaction fails, that particular block of primary keys will be lost.

      Having said that I cannot see how this can be averted even if I were to move the sequence block call within hibernate's transaction context (the sequence block is a lossy algorithm anyway).

      I would appreciate your thoughts.

      Cheers
      -raj