Search code examples
javajpaobjectdb

how to adding index on Map fields in entity using object db


i want to add index in map attribute i doen't have any idea about adding index in map attribute

i have refer objectdb site link but i doesn't find soultion @index is enough for added index

for example:

@Entity
@Table(name = Customer.TABLE_NAME)
public class Country {

    @index
    @OneToMany(fetch = FetchType.LAZY)
    @JoinTable(name = Country.TABLE_TRANSLATION_NAME,
        joinColumns = @JoinColumn(name = Country.TABLE_NAME),
        inverseJoinColumns = @JoinColumn(name = NameTranslation.TABLE_NAME))
    @MapKeyJoinColumn(name = Language.TABLE_NAME)
    private Map<Language, NameTranslation> names;

}

language and nametranslation has seperate entity


Solution

  • See this forum thread on ObjectDB website regarding indexing map keys, and this forum thread about indexing map values.

    You can set an index on keys using the @Key(index="true") annotation, and on values using the @Value(index="true") annotation, but as explained above, an index on keys will not be useful in queries in the current ObjectDB version (2.5.7).