object db add composite index doen n#39; t work

时间:2014-10-17 06:32:49

标签: java jpa objectdb

我尝试在实体中添加复合索引但不起作用 得到以下错误:

[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;
}

1 个答案:

答案 0 :(得分:1)

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

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

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

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