Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with CMR : please help  RSS feed

 
Rashmi Tambe
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Rashmi Tambe
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can anybody answer this???
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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'
 
Rashmi Tambe
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Pradeep !
I posted this and got the answer in SCBCD forum ...Anyways, thanks
and yess...i forgot..x'mas holidays r going on !
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Rashmi Tambe
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In india, we dont get a week holiday for x'mas...u must be knowing that !

Oh! Good luck
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!