xtea service: fix bulk query returning duplicates
Some rows have backfilled times that are duplicates, causing the join to join multiple rows. Assume ids only increment and fetch the row with the highest id instead, and join on id.
This commit is contained in:
@@ -184,9 +184,9 @@ public class XteaService
|
||||
try (Connection con = sql2o.open())
|
||||
{
|
||||
return con.createQuery(
|
||||
"select t1.region, t1.time, t2.rev, t2.key1, t2.key2, t2.key3, t2.key4 from " +
|
||||
"(select region,max(time) as time from xtea group by region) t1 " +
|
||||
"join xtea t2 on t1.region = t2.region and t1.time = t2.time")
|
||||
"select t1.region, t2.time, t2.rev, t2.key1, t2.key2, t2.key3, t2.key4 from " +
|
||||
"(select region,max(id) as id from xtea group by region) t1 " +
|
||||
"join xtea t2 on t1.id = t2.id")
|
||||
.executeAndFetch(XteaEntry.class);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user