Hi Stefan,
In article <[EMAIL PROTECTED]>,
Wed, 18 Aug 2004 18:36:31 +0200,
Stefan Groschupf <[EMAIL PROTECTED]> wrote:
sg> [junit] Caused an ERROR
sg> [junit] [EJB:010116]Attempted to access the collection valued
sg> cmr-field, 'subscribers', for bean, 'Kit', outside the scope of a
sg> transaction. All access to the collection must be performed during the
sg> transaction in which the collection was initially retrieved.
As the error message says, you need to begin transaction
to access to the collection (retrived for n:n relation).
For example, I have used codes for CMR test with JBoss like follows:
public class CmrTestCase
extends ServletTestCase
{
protected UserTransaction transaction = null;
protected beginTransaction(){
if(transaction==null){
transaction =
(UserTransaction)context.lookup("java:comp/env/UserTransaction");
}
transaction.begin();
}
protected commitTransaction(){
if(transaction==null){
return;
}
if(transaction.getStatus()==Status.STATUS_ACTIVE){
transaction.commit();
}
}
public void testXXX(){
beginTransaction();
// test codes for CMR etc.
commitTransaction();
}
}
Hope this helps.
----
Kazuhito SUGURI
mailto:[EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]