4 Replies Latest reply on Jun 2, 2004 5:00 AM by puneetjains

    Problem with DAO Design Pattern

    prasanna_vashisht


      There is the famous SingletonMessageDrivenBean -- take a look at standardjboss.xml in JBoss 3.2.5. Or, store your crap in a MBean, which is effectively a singleton.

        • 1. Re: Problem with DAO Design Pattern

          Hope this reply is not too late! ;)

          Your problem has nothing to do with DAO pattern. You need to set the autocommit property to false on the Connection.

          • 2. Re: Problem with DAO Design Pattern
            mikeydavison

            How exactly are you getting your connection? If you've configured your connection in a manner similar to the example (oracle-ds.xml) and you're getting the connection from a DataSource stored in the JNDI tree, there's no need to touch the autocommit property of the connection.

            Are you throwing a RemoteException or RuntimeException from your bean method call? Doing so should trigger a rollback provided that the connection is obtained properly.

            • 3. Re: Problem with DAO Design Pattern
              puneetjains

              if u r using session beans to call dao then the transaction initialtor is ur session bean

              write mySessionCtx.setRollbackOnly(); in the catch block of the method inside the session bean

              it will roll back any modifications int he database.
              make sure that the method invicoition on the session bean has requeired transaction atribute

              • 4. Re: Problem with DAO Design Pattern
                puneetjains

                if u r using session beans to call dao then the transaction initialtor is ur session bean

                write mySessionCtx.setRollbackOnly(); in the catch block of the method inside the session bean

                it will roll back any modifications int he database.
                make sure that the method invicoition on the session bean has requeired transaction atribute