1

我尝试在 enttiy 中添加复合索引,但在出现错误后不起作用:

[error] application - message= Unexpected database state: BTree 49 is not found, cause=  [ObjectDB 2.5.4] javax.persistence.PersistenceException 
Unexpected database state: BTree 49 is not found (error 147

模型类:

@Entity
@Table(name = Customer.TABLE_NAME)
@javax.jdo.annotations.Index(members=            
     {"addresses.firstName,addresses.lastName,addresses.company"})
public class Customer extends ObjectDBBaseModel<Customer> {
    List<Address> addresses;
}


@Entity
@Table(name = Address.TABLE_NAME)
public class Address<T extends ObjectDBBaseModel> extends ObjectDBBaseModel<T> {

    public static final String TABLE_NAME = "address";
    public static final Address NULL = new Address();
    public static ODBFinder<Address> find = new ODBFinder<>(Address.class, NULL);

    public Address() {
        super((Class<T>) Address.class);
    }

    @Column(name = "address_type_enum")
    @Enumerated(EnumType.STRING)
    private AddressTypeEnum addressTypeEnum;

    @Column(name = "gender_enum")
    @Enumerated(EnumType.STRING)
    private GenderEnum genderEnum;

    private String title;

    private String firstName;

    private String lastName;

    private String company;

    private String street1;
}
4

1 回答 1

1

索引定义无效,因为多路径索引仅限于一个实体类(和其他可嵌入类),但不能分布在多个实体类上。

在这种情况下,您应该使用两个单独的索引:

  • 地址集合的简单索引。
  • Address 中三个字段的复合索引。

ObjectDB 将分别维护每个索引,但会在相关查询中将它们连接在一起。

于 2014-10-17T11:00:37.757 回答