Title: RE: [jBoss-User] Finder Methods are slower when nothing is returned
I tried changing the beans to reentrant = true. I did have them marked as non-reentrant. Unfortunately it did not fix the problem. My create methods are setting all of the attribute data.
 
Here's the basic issue. It looks like the connection pool is giving me different connections for each of my beans. As a result the SQL in the beans is isolated transactionally from the other beans. I guess the basic question is this. If I have BMP entity beans, running under container-managed transactions. And if I have beans that have dependency relationships (For example a foreign-key relationship in the DB) in the back-end database. How do I write my SQL and connection pool code so that the beans work properly in the EJB transaction context. Is my only option to choose a isolation level that allows dirty reads?
 
How do I set the isolation level in my jboss configuration? (Since the JBOSS web site is down, I can't look at the docs)
Do I have to do it manually via the Connection setTransactionIsolation method any time I lookup a connection?
What if I have a mix of BMP, CMP, and (horror) SQL in a SessionBean?
 
Thanks
Dave
-----Original Message-----
From: Nortje, Andrew [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 18, 2001 10:20 AM
To: 'jBoss'
Subject: RE: [jBoss-User] BMP and Container Managed Transactions was "Find er Methods are sl ower when nothing is returned"

Dave
 
I am doing something similar to what you are and it works after much struggling i.e. I create and use beans under a single transaction context. If something fails created rows are rolled back etc.
 
Anyway I recognize the timeout error, I also had this error. It turned out I was making reentrant calls to my entity beans and they were not marked reentrant. You may have a similar problem. Try make your entity beans reentrant (ejb-jar.xml) then test your code. If it then works then you are making reentrant calls, you can then take it from there.
 
Also make sure your create() method correctly populates all the bean data (attributes), i.e. after create() the bean instance is taken out the pool and is assigned.
-----Original Message-----
From: Bolt, Dave [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 18, 2001 9:21 AM
To: jBoss
Subject: [jBoss-User] BMP and Container Managed Transactions was "Finder Methods are sl ower 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