ObjectDB ObjectDB

How do handle fields with java.net.URI class


We are migrating an existing application to use ObjectDB as primary database. In this case it's necessary to be backward compatible and a change of class definitions isn't possible. So we have some fields like this:

URI id;
Set<URI> ids;

These fields are very important for querying and we need an index for both. But neither I can create an @Index for this nor I can define the URI class as an @Entity.

How can I deal with it?

PS: The only solution I found is to use @PrePersits + @PreUpdate and store a copy of URI as string also. But this consumes a lot of additional space.


URI is not a supported type. You can still use it by enabling serialization in the configuration, but this is far from optimal, indexes are not supported, and queries can be even much slower than with unindexed String fields.

Therefore, maintaining separate String fields, as you suggested, seems to be the current best solution.

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)


To post on this website please sign in.