由于 JBPM 的较新版本之一添加了索引内部类:
@Entity
@Table(name="Attachment",
indexes = {@Index(name = "IDX_Attachment_Id",
columnList="attachedBy_id"),
@Index(name = "IDX_Attachment_DataId",
columnList="TaskData_Attachments_Id")})
@SequenceGenerator(name="attachmentIdSeq",
sequenceName="ATTACHMENT_ID_SEQ", allocationSize=1)
public class AttachmentImpl implements InternalAttachment {
...
@ManyToOne()
private UserImpl attachedBy;
...
}
attachBy_id列来自数据库中名为attach_by_id的索引 columnList 。Hibernate 无法识别正确的物理列名并抛出异常:
org.hibernate.AnnotationException:无法在表附件上创建唯一键约束(attachedBy_id):找不到数据库列“attachedBy_id”。确保使用正确的列名称,这取决于使用的命名策略(它可能与实体中的属性名称不同,尤其是关系类型)
我无法更改 JBPM 的代码。我也不想更改数据库中的列名(无论如何也无济于事),但我需要以某种方式将 @Index columnList中的 attachBy_id映射到attach_by_id。是否可以对索引 columnList 应用相同的命名策略?