Hey all!

I've written an EJB that uses Castor to do most inserts/selects needed.  I 
also wrote a test program.  The gist of the whole affair is as follows:

EJB // this is an entity bean
{
    public PK ejbCreate() 
    {
        // Use Castor to find existing and report dupes or create new one
    }

    public void doSomething()
    {
        // Get DataSource named TestDataSource 
        // (same one named in database.xml for JDO configuration)
        // do some sql
        // do some castor
    }
}

Test
{
    public static void main( String[] args ) throws Exception
    {
        EJBHome home = getEJBHome();
        EJB[] arr = new EJB[30];
        UserTransaction tx = getUserTransactionFromWebLogicJNDI(); // 
        tx.begin()
        try
        {
            for ( int i = 0 ; i < arr.length ; i++ )
            {
                arr[i] = home.create();
            }

            for ( ; ; ) // loop conditions irrelevant
            {
                arr[i].doSomething();
            }

            // NOTE THIS LINE
            tx.commit();
        }
        catch ( Throwable t )
        {
            t.printStackTrace();
            tx.rollback();
        }
    }
}

Note that all the code is encased in one long transaction - client initiated. 
 All involved EJB's have a Required attribute in ALL their methods, and they 
all use (obviously) Container-Managed transactions.

The problem is that even if I change the tx.commit() call to tx.rollback(), 
the inserts into the database are STILL committed - I'm assuming by Castor, 
because I've done this sort of thing in the past with Straight-JDBC, and have 
got the results I expect.

I haven't gotten around to look at the actual Castor sources to try to find 
the problem, but I'm planning to do so in a few minutes.

I'm posting this in hopes someone already knows what's up, and can give me a 
hand before I spend long hours reading through all the source I need to.

I already tried making it a TX datasource instead of a regular one - no 
effect.

Best

Diego

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to