1

Is it possible to set custom generated String ID for a Entity?

i.e jetbrains.exodus.entitystore.Entity

Say application generates a alerady unique key using Java UUID or some kind of Object ID can it be used as value of EntityId.toString()

quarks
  • 33,478
  • 73
  • 290
  • 513

1 Answers1

2

EntityId is an internal id used for managing links under the hood. If it doesn't meet your requirements just use your own app-level id as a property assigned to an entity. You can easily find entities by property values (searching by property value).

Vyacheslav Lukianov
  • 1,913
  • 8
  • 12
  • Hi, the ID is fine, it's just a bit exposed, the counts, anyhow we can just hash it on the service layer, however I have another concern which is during migration of data, does the ID retains, for example we backup the whole database then restore it, would the ID change of the restored entities? – quarks Aug 15 '18 at 12:09
  • 1
    @xybrek It depends on what kind of migration or backup procedure do you mean. An entity gets its id on creation, and it no longer changes. Moreover, ids are not re-used, newly created entities don't get ids of deleted ones. – Vyacheslav Lukianov Aug 15 '18 at 15:08
  • Just to add something here, the way I have worked out this, is to essentially back up the whole folder (file-level backup) and restore. Since there is no facility for Xodus to restore from backup. The only problem with my "hack" approach is that it is impossible to back up a production server without fully shutting down the service layer that uses the Xodus database first. @vyacheslav-lukianov is it safe to do file copy of a live Xodus database and also is it safe to overwrite live Xodus database? – quarks Jul 01 '19 at 00:52
  • @xybrek It is safe to prepare backup files on-the-fly using built-in backup facility as it is described here: https://github.com/JetBrains/xodus/wiki/Backup#full-backup. To recover from a backup, you have to shut down the database though. – Vyacheslav Lukianov Jul 01 '19 at 09:06