Title: RE: [jBoss-User] Finder Methods are slower when nothing is returned
It turns out that it is a database thing, but then again it isn't. Here's a better description.
 
I have three EJBs, a session bean and two entity beans. The entity beans have a one-to-many relationship. If I had EJB 2.0 I would use the container managed relationship features to handle all of this. Right now, it's being done the hard way with BMP code. Anyway, the session bean has a business method marked with a RequiresNew transaction attribute and it calls the create method of first the master bean and then the entity bean. In the database (Oracle 8i) the detail records can only exist if the master record exists (foreign key constraint).
 
Each of the entity beans obtains a connection from the connection pool with the following code.
 
    private Connection getConnection()
    {
        Context ctx = null;
        Connection con = null;
        DataSource ds = null;
        try
        {
            ctx = new InitialContext();
 
            ds = (DataSource)ctx.lookup(JNDINames.DB_POOL);
            con = ds.getConnection();
 
            return con;
        }
        catch(NamingException ne)
        {
            System.out.println(ne.getMessage());
            System.out.println(ne.getExplanation());
            ne.printStackTrace();
            throw new EJBException(ne);
        }
        catch(SQLException se)
        {
            System.out.println(se.getMessage());
            se.printStackTrace();
            throw new EJBException(se);
        }
 
    }
 
The problem that I am having is that the create method of the master bean is adding records to the database, but the changes are not visible to the detail bean via it's connection. It could be an isolation level thing (I haven't found in JBOSS were you set the isolation level for an Oracle connection pool).
 
What I want to have happen is that the Session bean will start a transaction (RequiresNew) which will include the create methods of the Master and Detail beans (Requires), but it looks like since I am getting different connections from the connection pool that the ability of the container to manage the transactions is being
compromised. The error that I finally get in my code is ORA-02049: timeout: distributed transaction waiting for lock.
 
Any ideas?
 
Dave
 
 
 
-----Original Message-----
From: Cook, Thomas [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 17, 2001 6:24 PM
To: 'jBoss'
Subject: RE: [jBoss-User] Finder Methods are slower when nothing is return ed

Possible a database thing?  If nothing is returned, maybe it is doing a sequential search?

Tom
--
Tom Cook
Systems Development
Australian Submarine Corporation
Mersey Road
Outer Harbour

+61 8 8348 7645

"From the instant I picked your book up, until the moment I put it down, I was convulsed with laughter.  I fully intend to read it one day."

        - Groucho Marx

    -----Original Message-----
    From:   Bolt, Dave [SMTP:[EMAIL PROTECTED]]
    Sent:   Thursday, January 18, 2001 5:01 AM
    To:     [EMAIL PROTECTED]
    Subject:        [jBoss-User] Finder Methods are slower when nothing is returned

    I'm trying to write some code to use BMP Entity beans to update an Oracle 8i database.

    I have a session bean that is doing the data loading from an XML file. I want to use the Entity
    bean to see if the data exists (via a Finder method) and then either create or update the
    record depending on the status.

    I am seeing that performance is very fast if the record already exists, whereas it is very slow if no
    records can be found. Has anyone else noticed a difference in performance in the Finder's thanks

    Dave Bolt
    There is always bandwidth, just none for you.

Reply via email to