On Jan 2, 2009, at 1:51 AM, Debarshi Sanyal wrote:
Hi All,
New Year greetings!
Happy new year to you too!
I was trying to execute the example on EJB entity-manager provided
at *
http://openejb.apache.org/3.0/injection-of-entitymanager-
example.html.*
I have replaced the test case with a standalone client that, however,
performs exactly the same steps. However, I observed that while
insertion to
the database is occurring perfectly, the deletion does not take place.
Movies movies = (Movies) context.lookup("MoviesLocal");
movies.addMovie(new Movie("Quentin Tarantino", "Reservoir
Dogs", 1992));
movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
movies.addMovie(new Movie("Joel Coen", "The Big Lebowski",
1998));
List<Movie> list = movies.getMovies();
assertEquals("List.size()", 3, list.size());
*for (Movie movie : list) {
movies.deleteMovie(movie);
}*
Even after the previous steps, *movies.getMovies().size()* returns 3
which
is very strange.
That is very strange. I'm not sure what could be happening. When in
doubt add a entityManager.flush() statement and hope for an error
message :) (useful debug tactic with JPA -- just make sure to remove
it in production as it will affect performance) In this case I'd add
it right after the entityManager.remove(movie); call.
Hopefully that will dig up something.
Also double check that one of your modifications did not involve
deleting "PersistenceContextType.EXTENDED" from the example. That
could cause the issue as well -- entityManager.remove(foo) only works
if the object passed in is still "attached" [1].
-David
[1] Attached/Detached explained here
http://openejb.apache.org/3.0/jpa-concepts.html