Bugs item #840449, was opened at 2003-11-12 04:52
Message generated for change (Comment added) made by loubyansky
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=840449&group_id=22866
Category: JBossCMP
Group: v3.2
>Status: Closed
>Resolution: Rejected
Priority: 5
Submitted By: Adrian Price (adrianprice)
>Assigned to: Alexey Loubyansky (loubyansky)
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.
----------------------------------------------------------------------
>Comment By: Alexey Loubyansky (loubyansky)
Date: 2003-11-12 13:15
Message:
Logged In: YES
user_id=543482
17.4.1 Transaction attributes
...For entity beans that use EJB 2.0 container-managed
persistence, only the Required,
RequiresNew, or Mandatory transaction attributes should be
used for the methods defined in the
bean�s component interface and all the direct and indirect
superinterfaces of the component interface,
excluding the getEJBHome, getEJBLocalHome, getHandle,
getPrimaryKey, and isIdentical
methods; and for the methods defined in the bean�s home
interface and all the direct and
indirect superinterfaces of the home interface, excluding
the getEJBMetaData and getHomeHandle
methods specific to the remote home interface. Containers
may optionally support the use of the
NotSupported, Supports, and Never transaction attributes for
the methods of entity beans with
container-managed persistence. However, entity beans with
container-managed persistence that use
these transaction attributes will not be portable.
Containers may optionally support the use of the
NotSupported, Supports, and Never
transaction attributes for the methods of entity beans with
container-managed persistence
because the use of these transaction modes may be needed to
make use of container-managed
persistence with non-transactional data stores. In general,
however, the Application Assembler
should avoid use of the NotSupported, Supports, and Never
transaction attributes for
the methods of entity beans with container-managed
persistence because it may lead to inconsistent
results or to the inconsistent and/or to the partial
updating of persistent state and relationships
in the event of concurrent use...
read-only (jboss.xml) entity beans are not associated with
transactions and are not invalidated and thrown out of the
cache when the tx commits. But CMR collections are tied to
the tx in which they were created. And when the tx commits,
the collection is invalidated. It is specification compliant
behaviour.
----------------------------------------------------------------------
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