Benefit of implementing HasUuid interface?

Currently all my entities inherit from BaseIdentityIdEntity and implement the HasUuid interface. According to the Documentation “implementing HasUuid is highly recommended, as it enables some optimizations and allows you to identify your instances uniquely in a distributed environment”.

I dont have the use case of a distributed environment and thinking about to remove the HasUuid implementations. What is the benefit of the UUIDs ? What are “some optimizations”?

5 Likes

First, let me explain what are “some optimizations”. Currently the difference between handling of Identity-ID entities with and without UUID exists only for newly created in memory instances. If the entity has no UUID, all its new instances will have the same hash code =0, which makes storing such instances in hashtable-based collections inefficient. As the case of creating large collections of new instances is quite rare, this difference can be ignored.

Also, in platform version 6.4 there are some restrictions on using entities without UUID in common mechanisms. You cannot use such entities in:

  • dynamic attributes
  • entity log
  • entity snapshots
  • security constraints checked in memory

We are going to overcome these limitations in platform 6.5 for all types of single-field primary key. So HasUUID will be required only for composite-key entities to be supported by these mechanisms.