|
@@ -49,15 +49,17 @@ public class Query
|
|
else if (queries > 500) {
|
|
else if (queries > 500) {
|
|
queries = 500;
|
|
queries = 500;
|
|
}
|
|
}
|
|
- final World[] worlds = new World[queries];
|
|
|
|
|
|
|
|
- // For generating a random row ID
|
|
|
|
- final Random rand = ThreadLocalRandom.current();
|
|
|
|
-
|
|
|
|
- for (int i = 0; i < queries; i++) {
|
|
|
|
- // Read object from database
|
|
|
|
- worlds[i] = (World)session.get(World.class, new Integer(rand.nextInt(DB_ROWS) + 1));
|
|
|
|
- }
|
|
|
|
|
|
+ // Since we're using hibernate ORM which has a 1st level cache
|
|
|
|
+ // that can't be turned off, we instead pick distinct random numbers
|
|
|
|
+ // to avoid failing query verification
|
|
|
|
+ final World[] worlds = ThreadLocalRandom
|
|
|
|
+ .current()
|
|
|
|
+ .ints(1, DB_ROWS + 1)
|
|
|
|
+ .distinct()
|
|
|
|
+ .limit(queries)
|
|
|
|
+ .mapToObj(id -> session.get(World.class, id))
|
|
|
|
+ .toArray(World[]::new);
|
|
|
|
|
|
// Send reponse
|
|
// Send reponse
|
|
String response = "";
|
|
String response = "";
|