@Index for @Convert column


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.


@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)
    ApiActionType actionType;

   @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:


Are you using the latest Hibernate version 5.4.30? If so, and you still have the problem, please create an issue in the issue tracker(https://hibernate.atlassian.net) with a test case(https://github.com/hibernate/hibernate-test-case-templates/blob/master/orm/hibernate-orm-5/src/test/java/org/hibernate/bugs/JPAUnitTestCase.java) that reproduces the issue.