Ok... this is what I have on the Transactions not working issue.
Looks like it isn't Torque (as I erroneously thought) thats causing the
problem , but probably the way my environment is set up.
I'm using JNDI datasource factory to access two different connections...

My environment:
      App Server: Jboss
      Two database schema connections using JNDI datasource factory
Whats Happening:
      executing the code below yields proper results until I kill my app
server.

  public static void testTorque(){
    Connection conn = null;

    try{

        //conn = BasePeer.beginTransaction("OracleUser2");
        conn = Transaction.begin("OracleUser2");

        //do criteria
        Criteria crit = new Criteria();
        crit.add(TEcommCategoryPeer.STATUS,"Pending");
        List cats = TEcommCategoryPeer.doSelect(crit);
        Iterator i = cats.iterator();
        while(i.hasNext()){
          TEcommCategory cat = (TEcommCategory)i.next();
          cat.setStatus("Tanay");
          cat.save(conn);
        }

        //do items
        crit.clear();
        crit.add(TEcommItemPeer.STATUS,"Pending");
        List items = TEcommItemPeer.doSelect(crit);

        if(items.size()<1000){
          throw new Exception("Test Torque Exception");
        }

        Iterator j = items.iterator();
        while(j.hasNext()){
          TEcommItem item = (TEcommItem)j.next();
          item.setStatus("Tanay");
          item.save(conn);
        }

        //BasePeer.commitTransaction(conn);
        Transaction.commit(conn);

        System.out.println("COMMMITED SUCSESSFULLY");
    }
    catch(Exception e){
      e.printStackTrace(System.out);
      //do a roll back
      try {
        //BasePeer.rollBackTransaction(conn);
        Transaction.rollback(conn);

        System.out.println("ROLLED BACK SUCSESSFULLY");

        //code for unbinding "OracleUser2" JNDI context comes here

      }
      catch (Exception ex) {
        ex.printStackTrace(System.out);
      }

    }

  }


      The moment I kill my app server the rollback fails and the database
gets updated.(this accounts for the visible delay I was experiencing in
getting records updated)
      I included some code right after the rollback() operation to remove
the "OracleUser2" JNDI resource by unbinding it . Killing the app server
then  does not update the database.

So my conclusion is that probably my JNDI configuration isn't done properly
for two differnet connections and somewhere during
stopping/cleaning/unbinding  the database resource its updating the
database as well. A copy of my properties file follows.



web.xml

<!-- JDBC Datasource Configuration -->
    <resource-ref>
            <description>
                    Resource reference to a factory for java.sql.Connection
                    instances that may be used for talking to a particular
                    database that is configured in the server.xml file.
            </description>
            <res-ref-name>jdbc/oracle</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <res-auth>Container</res-auth>
    </resource-ref>


jboss-web.xml

<jboss-web>
    <resource-ref>
            <res-ref-name>jdbc/oracle</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <jndi-name>java:/Oracle</jndi-name>
    </resource-ref>

    <resource-ref>
            <res-ref-name>jdbc/oracle</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <jndi-name>java:/OracleUser2</jndi-name>
    </resource-ref>
</jboss-web>


Torque.properties

## Using jndi
torque.dsfactory.Oracle.factory=org.apache.torque.dsfactory.JndiDataSourceFactory

torque.dsfactory.Oracle.jndi.path=java:/Oracle

torque.dsfactory.OracleUser2.factory=org.apache.torque.dsfactory.JndiDataSourceFactory

torque.dsfactory.OracleUser2.jndi.path=java:/OracleUser2

If anyone can come up with any inputs or point out what I'm doing wrong
here.. it'll be greatly appreciated.

thanks

Tanay













                                                                                       
                                                
                      tsjuday@checkfree                                                
                                                
                      .com                     To:       "Turbine Torque Users List" 
<[EMAIL PROTECTED]>          
                                               cc:                                     
                                                
                      08/27/02 11:24 AM        Subject:  RE: Transaction               
                                                
                      Please respond to                                                
                                                
                      "Turbine Torque                                                  
                                                
                      Users List"                                                      
                                                
                                                                                       
                                                
                                                                                       
                                                





That could be.  That was just the only difference I saw between our code.
I'll look over your code closer in a little bit.


Tobin Juday
Software Engineer
proud graduate of The Ohio State University
[EMAIL PROTECTED]
Phone: 614.564.4192
Pager: 877.546.0103

The #1 Way to Pay Online
http://www.checkfree.com/paybillsonline




                      [EMAIL PROTECTED]

                      om                       To:       "Turbine Torque
Users List" <[EMAIL PROTECTED]>
                                               cc:

                      08/27/2002 02:20         Subject:  RE: Transaction

                      PM

                      Please respond to

                      "Turbine Torque

                      Users List"








Actually the "Oracle" in my code is the name with which my database is
configured in the properties file.

Also if that were an issue, I wouldn't get the connection object in the
first place.





                      tsjuday@checkfree

                      .com                     To:       "Turbine Torque
Users List" <[EMAIL PROTECTED]>
                                               cc:

                      08/27/02 11:15 AM        Subject:  RE: Transaction

                      Please respond to

                      "Turbine Torque

                      Users List"








I don't know if this is the issue, but I think you're supposed to have

      conn = Transaction.begin(OneOfYourTablesPeer.DATABASE_NAME);

instead of

      conn = Transaction.begin("Oracle");

I am using Oracle also, and that is how I have it working.


Tobin Juday
Software Engineer
proud graduate of The Ohio State University
[EMAIL PROTECTED]
Phone: 614.564.4192
Pager: 877.546.0103

The #1 Way to Pay Online
http://www.checkfree.com/paybillsonline




                      [EMAIL PROTECTED]

                      om                       To:       "Turbine Torque
Users List" <[EMAIL PROTECTED]>
                                               cc:

                      08/27/2002 02:10         Subject:  RE: Transaction

                      PM

                      Please respond to

                      "Turbine Torque

                      Users List"








actually that was another user on the list....

here's the code I am using for beta 4

  public static void testTorque(){
    Connection conn = null;

    try{

        //conn = BasePeer.beginTransaction("Oracle");
        conn = Transaction.begin("Oracle");

        //do criteria
        Criteria crit = new Criteria();
        crit.add(TEcommCategoryPeer.STATUS,"Pending");
        List cats = TEcommCategoryPeer.doSelect(crit);
        Iterator i = cats.iterator();
        while(i.hasNext()){
          TEcommCategory cat = (TEcommCategory)i.next();
          cat.setStatus("Tanay");
          cat.save(conn);
        }

        //do items
        crit.clear();
        crit.add(TEcommItemPeer.STATUS,"Pending");
        List items = TEcommItemPeer.doSelect(crit);

        if(items.size()<1000){
          throw new Exception("Test Torque Exception");
        }

        Iterator j = items.iterator();
        while(j.hasNext()){
          TEcommItem item = (TEcommItem)j.next();
          item.setStatus("Tanay");
          item.save(conn);
        }

        //BasePeer.commitTransaction(conn);
        Transaction.commit(conn);

        System.out.println("COMMMITED SUCSESSFULLY");
    }
    catch(Exception e){
      e.printStackTrace(System.out);
      //do a roll back
      try {
        //BasePeer.rollBackTransaction(conn);
        Transaction.rollback(conn);

        System.out.println("ROLLED BACK SUCSESSFULLY");
      }
      catch (Exception ex) {
        ex.printStackTrace(System.out);
      }

    }

  }



Everything appears to work as expected - I get the "ROLLED BACK
SUCSESSFULLY" message printed on the console...
however when I check the database..I see that the updates did get committed
to the tables.

Note: However one quirky thing that I do notice is that the commits don't
happen instantly.. when I run this code and immediately go and check the
database..it appears that the rollbacks DID happen and the database did not
get updated..... however when I go and check again after a few minutes..the
database seems to have got updated which means that the rollbacks didn't
work....
I'm not sure why the delay is there...

thanks












                      "Stephen

                      Haberman"                To:       "'Turbine Torque
Users List'" <[EMAIL PROTECTED]>
                      <stephenh@chase30        cc:

                      00.com>                  Subject:  RE: Transaction


                      08/27/02 10:43 AM
                      Please respond to

                      "Turbine Torque

                      Users List"







You replied to a message that just said it worked (unless they were not
using b4, but I will assume they were). How are you using the
transaction and why does it not work?

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, August 27, 2002 12:40 PM
> To: Turbine Torque Users List
> Subject: Re: Transaction
>
>
> Did transaction work for you in beta 4 ??
> It still does not for me....
>
> has anyone else tried any transaction related stuff with beta 4 ?
>
> thanks
>
>
>


--
To unsubscribe, e-mail:   <
mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <
mailto:[EMAIL PROTECTED]>







--
To unsubscribe, e-mail:   <
mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <
mailto:[EMAIL PROTECTED]>







--
To unsubscribe, e-mail:   <
mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <
mailto:[EMAIL PROTECTED]>







--
To unsubscribe, e-mail:   <
mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <
mailto:[EMAIL PROTECTED]>







--
To unsubscribe, e-mail:   <
mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <
mailto:[EMAIL PROTECTED]>







--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to