Skip to content

Commit

Permalink
Fixed jpa clearState()
Browse files Browse the repository at this point in the history
  • Loading branch information
quilombodigital committed Apr 13, 2015
1 parent e03da8f commit 1d63188
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Expand Up @@ -61,8 +61,10 @@ public synchronized Task<Void> clearState(final ActorReference<?> reference, fin
{ {
try try
{ {
String stateId = getIdentity(reference);
EntityManager em = emf.createEntityManager(); EntityManager em = emf.createEntityManager();
Query query = em.createQuery("delete from " + state.getClass().getSimpleName()); Query query = em.createQuery("delete from " + state.getClass().getSimpleName() + " s where s.stateId=:stateId");
query.setParameter("stateId", stateId);
em.getTransaction().begin(); em.getTransaction().begin();
query.executeUpdate(); query.executeUpdate();
em.getTransaction().commit(); em.getTransaction().commit();
Expand Down
Expand Up @@ -78,10 +78,14 @@ public void checkClearTest() throws Exception
{ {
OrbitStage stage = createStage(); OrbitStage stage = createStage();
assertEquals(0, count(IHelloActor.class)); assertEquals(0, count(IHelloActor.class));
IHelloActor helloActor = IActor.getReference(IHelloActor.class, "300"); IHelloActor helloActor1 = IActor.getReference(IHelloActor.class, "300");
helloActor.sayHello("Meep Meep").join(); helloActor1.sayHello("Meep Meep").join();
IHelloActor helloActor2 = IActor.getReference(IHelloActor.class, "301");
helloActor2.sayHello("Meep Meep").join();
assertEquals(2, count(IHelloActor.class));
helloActor1.clear().join();
assertEquals(1, count(IHelloActor.class)); assertEquals(1, count(IHelloActor.class));
helloActor.clear().join(); helloActor2.clear().join();
assertEquals(0, count(IHelloActor.class)); assertEquals(0, count(IHelloActor.class));
} }


Expand Down

0 comments on commit 1d63188

Please sign in to comment.