Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support UUID as a primary key #84

Open
nealeu opened this issue Aug 8, 2012 · 0 comments
Open

Support UUID as a primary key #84

nealeu opened this issue Aug 8, 2012 · 0 comments

Comments

@nealeu
Copy link
Member

nealeu commented Aug 8, 2012

We want to supply the same UUID as the @id both in fuzzydb and another database, such as MongoDB, when using fuzzydb as an in memory index backed by MongoDB. Without this, using Repository.save() to update an existing item across both repositories is difficult.

The following should work

@Id 
private UUID id;

This should be the preferred option over the following

@Id 
private String fuzzydbRef; 

Superficially, for a short String, the memory footprint is comparable. UUID has the advantage of a smaller disk footprint, and also being one object, in comparison to String's two (String and char[]).

In reality, UUID is worse as we have to maintain an index in order to be able to find the item.

The short-term preferable workaround is to store the fuzzydb Ref in the mongodb document and either use fuzzydb for all searches, or provide a bi-directional link to allow the mongodb document to be also found from the fuzzydb document.

As an application can populate a UUID, then this would be a case of persisting the fuzzydb item first, and then applying that to the mongodb document.

The problem here is that the ref would also have to be updated when re-populating a fresh fuzzydb instance.

Supporting UUID as the primary key in fuzzydb therefore remains a valuable feature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant