This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes EJB and other Java EE Technologies and the fly likes Any idea what's going on? NoSuchObjectLocalException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Any idea what Watch "Any idea what New topic
Author

Any idea what's going on? NoSuchObjectLocalException

Dan Bizman
Ranch Hand

Joined: Feb 25, 2003
Posts: 387
I have a bean "Orders" which has a collection of OrderItem beans. The OrderItem has a compound primary key of: OrderId + ProductId. It also has a quantity attribute.

When i create the orders in an init method, and then check them in that same method, everything is fine.

When I call a "findOrdersByCustomer" method, it finds a collection of orders and then when I'm looping through the OrderItems for the first order, the following occurs:

1. I get the item via iterator.next();
2. I pull the product out of the orderitem via orderItem.getProduct();
3. I print out the primary key for the item via orderItem.getPrimaryKey();
3a. It prints out (for primary key): OrderId[3],ProductId[2]
4. I call orderItem.getQuantity()

At #4, it throws:
javax.ejb.NoSuchObjectLocalException: Entity not found: primaryKey=OrderId[3],ProductId[2]

What's going on? Just one method call earlier, the object returned that same exact primary key! Does anyone have any idea what I might be doing wrong?

Plus, if I do findByPrimaryKey(), it finds the OrderItem, but again, if I call getQuantity() it throws that same exception! What could be going on here?
[ September 22, 2005: Message edited by: Dan Bizman ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Any idea what's going on? NoSuchObjectLocalException