mirror of
https://github.com/google/nomulus
synced 2026-09-29 11:15:45 +00:00
When inserting multiple entities, if sorting isn't enabled, then Hibernate will just add them in the order received. This is suboptimal for batch query execution. Hibernate flushes the batch as soon as it "encounters" a new table, so if we have inserts into tables A, B, A, B in that order, it'll execute each one separately, rather than batching (A,A), (B,B). The downside to enabling ordering is that you need to either have deferred foreign keys (which we have) or Hibernate-style entity references, e.g. `@OneToOne Entity entity` rather than `VKey<String> entityId`. While any future potential migration to Spanner would require that we remove the deferred foreign keys, this change is orthogonal to that -- we'll need to change the references to direct Hibernate references anyway which Hibernate will know how to order properly.