Meaningless Drivel is fun!*
The moose likes EJB and other Java EE Technologies and the fly likes EJB Transaction Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB Transaction" Watch "EJB Transaction" New topic
Author

EJB Transaction

Anurag Bhatia
Greenhorn

Joined: May 12, 2009
Posts: 27
In one EJB I am doing the following operations -
1. Create entity A with primary key - id and persist A into the database.
2. Look for entity A with primary key - id.

When I do operation 2 I get a an ObjectNotFound exception. I am unable to understand why?
Should'nt the entity manager be aware of the created entity A with primary key - id.

--Anurag
Witold Koszulinski
Greenhorn

Joined: Aug 12, 2007
Posts: 3
You got an exception because your are not sharing the same persistence context.

Witold


SCJP 5, SCWCD 5, SCBCD 5
Anurag Bhatia
Greenhorn

Joined: May 12, 2009
Posts: 27
Thanks. That sorted it out.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EJB Transaction
 
Similar Threads
Target Unreachable, 'null' returned null
ID Generator
primary key class of entity beans?
Bean in Entity bean pool lost identity?
entity with auto-generated primary key