Forums Register Login

Problem with CMR : please help

+Pie Number of slices to send: Send
I am facing a strange problem with CMR. I have an one-to-many relationship established between a branch bean and customer bean. i.e. one branch has multiple customers.I am trying to retrieve the collection of all customers names for a specific branch. The API, getBranchCustomers(String branchName) is defined a stateless session bean. In this method, firstly, i find the branch. Secondly, I get the collection of customers using getCustometrs () method where 'customers' is a CMR field. Then when i try to access the collection, I get the exception,
java.lang.IllegalStateException: Attempted to access the collection valued cmr-field, 'customers', for bean, 'BranchEJB', outside the scope of a transaction. All access to the collection must be performed during the transaction in which the collection was initially retrieved.
The code goes like this.................


public Collection getBranchCustomers(String branchName)
{
Vector vCustomers = null;
try
{
//look up branch home
...
Branch objBranch = objBranchHome.findByName(branchName);
if (objBranch != null)
{
//get customers
//'customers' is a CMR field, one-many CMR is defined between branch and customer
Collection cCustomers = objBranch.getCustomers();

vCustomers = new Vector(cCustomers.size()); //I get the exception at this line
Iterator itr = vCustomers.iterator();
//customer name collection to be returned
while (itr.hasNext())
...
...
...


both branch and customer EJB's have local interfaces only and all methods have tx attributes as 'NotSupported' . The API getBranchCustomers in session bean has the same tx attribute. so what is the problem here???
[ December 29, 2003: Message edited by: Rashmi Tambe ]
+Pie Number of slices to send: Send
can anybody answer this???
+Pie Number of slices to send: Send
 

Originally posted by Rashmi Tambe:
can anybody answer this???


Isn't it vacation time ?
You can find the following in the spec pg # 155

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.


Why have you set the transaction attribute to 'NotSuppported'? Set it to 'Reauired'
+Pie Number of slices to send: Send
Thanks Pradeep !
I posted this and got the answer in SCBCD forum ...Anyways, thanks
and yess...i forgot..x'mas holidays r going on !
+Pie Number of slices to send: Send
 

Originally posted by Rashmi Tambe:
Thanks Pradeep !
I posted this and got the answer in SCBCD forum ...Anyways, thanks
and yess...i forgot..x'mas holidays r going on !


I did not see your post in SCBCD? Where is it?
And why are studying during holdays?
+Pie Number of slices to send: Send
hi pradeep,
refer to this Post by Keith Rosenfield.
And yess, holidays r going on...but not for me
In india, we dont get a week holiday for x'mas...u must be knowing that !
So i have to work,,,and in between study too
[ December 30, 2003: Message edited by: Rashmi Tambe ]
+Pie Number of slices to send: Send
 

In india, we dont get a week holiday for x'mas...u must be knowing that !


Oh! Good luck
Try 100 things. 2 will work out, but you will never know in advance which 2. This tiny ad might be one:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 733 times.
Similar Threads
Odd exception
My Study Notes
CMP 2.0 Relationships and Null Pointer Error
One to Many Bidirectional Relationship
How to access CMR-fields in SessionBeans
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 22:48:41.