|
@@ -17,7 +17,6 @@ import javax.ws.rs.Produces;
|
|
|
import javax.ws.rs.QueryParam;
|
|
|
import javax.ws.rs.core.Context;
|
|
|
|
|
|
-import org.hibernate.IdentifierLoadAccess;
|
|
|
import org.hibernate.Session;
|
|
|
import org.hibernate.SessionFactory;
|
|
|
|
|
@@ -40,9 +39,6 @@ public class DbResource {
|
|
|
final int queries = getQueries(queriesParam);
|
|
|
final World[] worlds = new World[queries];
|
|
|
final Random random = ThreadLocalRandom.current();
|
|
|
- final Session session = sessionFactory.openSession();
|
|
|
- session.setDefaultReadOnly(true);
|
|
|
- final IdentifierLoadAccess accessor = session.byId(World.class);
|
|
|
|
|
|
Map<Integer, Future<World>> futureWorlds = new ConcurrentHashMap<>();
|
|
|
for (int i = 0; i < queries; i++) {
|
|
@@ -50,7 +46,10 @@ public class DbResource {
|
|
|
new Callable<World>() {
|
|
|
@Override
|
|
|
public World call() throws Exception {
|
|
|
- return (World) accessor.load(random.nextInt(DB_ROWS) + 1);
|
|
|
+ Session session = sessionFactory.openSession();
|
|
|
+ session.setDefaultReadOnly(true);
|
|
|
+
|
|
|
+ return (World) session.byId(World.class).load(random.nextInt(DB_ROWS) + 1);
|
|
|
}
|
|
|
}
|
|
|
));
|