You are here: Platform Specific Issues > Disconnected Objects > Comparison Of Different IDs

Comparison Of Different IDs

There are a lot of possibilities for additional ids to identify objects across the object container boundary.

Internal db4o ids

db4o has internal ids to identify each object in the database. You can access these ids and use them yourself. See "Internal IDs". Take a look at the example. See "Example Internal Id"

Advantages Disadvantages
  • Internal ids are fast.
  • No additional field on the class required.
  • No additional configuration required.
  • The id may change when defragmentating the database.

db4o UUIDs

db4o supports special UUIDs. You can enable them by configuration. See "Unique Universal IDs". Take a look at the example. See "Example db4o UUID"

Advantages Disadvantages
  • A UUID is a worldwide unique id.
  • No additional field on the class required.
  • db4o UUIDs are large.
  • db4o UUID is db4o-specific type.

Guid-Fields on Classes

You can add Guid-fields to your classes. In the constructor of the object you assign a new Guid to the object. Then you can find the object by a regular query. . Don't forget to index the id-field. Take a look at the example. See "Example Guid"

Advantages Disadvantages
  • A Guid is a worldwide unique id .
  • Guid are easy to generate and portable.
  • You need an id-field on your objects.
  • Guids are quite large.
  • Additional index required.

ID-Field On Classes With a ID-Generator

You can add a id-field to your classes and then use an ID-Generator to assign new ids to stored objects. Don't forget to index the id-field. Take a look at the example. See "Example ID-Generator"

Advantages Disadvantages
  • A simple id on objects.
  • Familiar model from the RDBMS-world.
  • You need an id-field on your objects.
  • You need to implement an ID-Generator. Which isn't trivial.
  • Additional index required.