Home » Support » Forum » Adding multi part path index on non-embedable object member

Adding multi part path index on non-embedable object member

#1

Is there a way to add single member index on members of a object member which is not configured embedable but is/are mapped by id like the two members below. 

@Entity public class Customer {

    @MapsId
    @ManyToOne(fetch = FetchType.LAZY)
    private Merchant merchant;


    @MapsId
    @ManyToOne(fetch = FetchType.LAZY)
    private List<Store> stores;

    // Setter/Getter

}

So I wanted to add index on Customer for merchant.name or on stores.name given those merchant and Store class has the corresponding fields.

e.g. 

@Entity
@Indices({
    @Index(members={"merchant.name"}),
    @Index(members={"stores.name", ...etc... })
}
public class Customer { ... }

There is a documentation says it works on embedded objects only. So since it reference only, what is suggested way of doing this?

Hope to hear your advice and solutions.

#2

The index definition is invalid, since a multi path index is limited to one entity class (and additional embeddable classes) but cannot spread over multiple entity classes.

You may split a multi path index to two separate indexes, e.g.

  • A simple index on the collection of stores.
  • A composite index on the fields in Store.

ObjectDB will maintain each index separately but will join them together in relevant queries.

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

Post Reply

To post a reply and/or subscribe to update notifications - please login