Skip to content

Commit

Permalink
Java/ninja revert transactional change so data persists (#3217)
Browse files Browse the repository at this point in the history
* Java/ninja revert transactional change so data persists

* Use transactional to persist but only once per update

* Update HelloDbController.java
  • Loading branch information
NateBrady23 committed Jan 31, 2018
1 parent 1cee232 commit 979f2ef
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.google.inject.persist.Transactional;
import ninja.jpa.UnitOfWork;
import ninja.params.Param;

Expand Down Expand Up @@ -62,12 +63,17 @@ public Result update(@Param("queries") Integer queries) {
// now update stuff:
for (World world : worlds) {
world.randomNumber = ThreadLocalRandom.current().nextInt(DB_ROWS) + 1;
worldDao.put(world);
this.updateWorld(world);
}

return Results.json().render(worlds);
}

@Transactional
public void updateWorld(World world) {
worldDao.put(world);
}

private World getRandomWorld() {
return worldDao.get(ThreadLocalRandom.current().nextInt(DB_ROWS) + 1);
}
Expand Down

0 comments on commit 979f2ef

Please sign in to comment.