Hello,
I have found a weird behavior that might be unintended.
The documentation for java.persistence.Index
notes that the physical column names should be used. When I use it in a spring / hibernate application that works nicely.
Unless the column in question also has a javax.persistence.Convert
annotation. In that case the physical column name produces an exception but the Java field name works.
Example:
@Entity
@Table(name = "API_TASKS",
indexes = {
@Index(name = "idx_project_action", columnList = "project_id, actionType, deleted"), // doesn't want action_type for some reason
@Index(name = "idx_customer_action", columnList = "customer_id, actionType, deleted"),
@Index(name = "idx_group_action", columnList = "project_group_id, actionType, deleted"),
@Index(name = "idx_scheduler", columnList = "invalid, paused, deleted"),
})
@Where(clause = "deleted = false")
public class ApiTask extends MetaDataEntity implements Plannable, ActionTyped {
@Convert(converter = ApiActionTypeConverter.class)
@Column(length=40)
ApiActionType actionType;
@ManyToOne
@JoinColumn(name = "project_id", referencedColumnName = "id")
Project project;
boolean deleted
...
}
Note how it is project_id
, but actionType
. The physical column name is action_type
in line with:
spring.jpa.hibernate.naming_strategy=org.hibernate.cfg.ImprovedNamingStrategy