Bugs item #840449, was opened at 2003-11-12 02:52
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=840449&group_id=22866

Category: JBossCMP
Group: v3.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Adrian Price (adrianprice)
Assigned to: Nobody/Anonymous (nobody)
Summary: Exceptions from CMR iterator of NotSupported RO bean

Initial Comment:
Read-Only entity beans are typically deployed with a 
transactional attribute of NotSupported, because there 
is no intention to update the entity, and one wishes to 
leverage the container's caching capabilities across 
multiple transactions.  One does not wish the RO entity 
to be enlisted in a transaction, because this would 
negative impact performance by dramatically increasing 
the size of the cache required to support a given TPS 
throughput.  The same applies when an RO entity has a 
1:n or m:n relationship with other RO beans.  

According to the EJB2.0 Specification 17.6.2.1:

If a client calls with a transaction context, the 
container suspends the association of the transaction 
context with the current thread before invoking the 
enterprise bean�s business method. The container
resumes the suspended association when the business 
method has completed. The suspended transaction
context of the client is not passed to the resource 
managers or other enterprise Bean objects that are
invoked from the business method.

If the business method invokes other enterprise beans, 
the Container passes no transaction context with
the invocation.

However, according to the EJB2.0 Specification 10.3.8:

� It is the responsibility of the Container to throw the 
java.lang.IllegalStateException if an attempt is made to 
use a java.util.Iterator for a container-managed 
collection in a transaction context other than that in 
which the iterator was obtained.

It would seem that JBoss interprets this provision too 
literally, and throws an IllegalStateException even when 
a CMR collection of RO entities is obtained from within 
this same 'transaction suspended' state.  __This 
behaviour completely defeats the purpose of RO 
entities__.

For example, if we have two RO entities A and B, both 
deployed as txn NotSupported, and A has a 1:n 
parent:child relationship with B, the following code 
currently will not work:

public abstract class A implements EntityBean {
    // ejb*() etc...

    // Multi-valued CMR field.
    public abstract Collection getBCmr();
    public abstract void setBCmr(Collection bs);

    public BVO[] getBVO() {
        Collection bs = getBCmr();
        BVO[] bvo = new BVO[bs.size()];
        int i = 0;
        // Next line throws IllegalStateException!!!
        for (Iterator j = bs.iterator(); j.hasNext(); i++) {
            B b = (B)j.next();
            bvo[i] = b.getVO();
        }
        return bvo;
    }
}

BTW, the above code works fine on WebLogic.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=840449&group_id=22866


-------------------------------------------------------
This SF.Net email sponsored by: ApacheCon 2003,
16-19 November in Las Vegas. Learn firsthand the latest
developments in Apache, PHP, Perl, XML, Java, MySQL,
WebDAV, and more! http://www.apachecon.com/
_______________________________________________
JBoss-Development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to