I have been hunting around this morning trying to mitigate some issues of our 
schema and JPA mapping and https://hibernate.atlassian.net/browse/HHH-6221 
seems most related.

 

This is a specific case following on §2.4.1 and the other bugs I have worked 
with recently.

 

Is there any more history on this bug than is in the comments of it and the 
related tickets? We are going to have to dive in and fix and was hoping to have 
a good survey of the landscape first.

 

We will make test case(s) along with some patches.

 

--- BREAK ---

 

Tracking internally as https://projects.pdinc.us/show_bug.cgi?id=2115 .

 

In our codebase we got here because of (edited for clarity)

 

    @ManyToOne

    @JoinColumns

    ({

            @JoinColumn(name = "id", referencedColumnName = "request_id", 
insertable = false, updatable = false),

            @JoinColumn(name = "head", referencedColumnName = "id")

    })

    Signature head;

 

    @Id

    @GeneratedValue(strategy = GenerationType.SEQUENCE)

    Long id;

 

 

Repeated column in mapping for entity: Entity column: column (should be mapped 
with insert="false" update="false")

 

Which then leads to

 

Mixing insertable and non insertable columns in a property is not allowed: 
Entity.column

     at 
org.hibernate.cfg.Ejb3Column.checkPropertyConsistency(Ejb3Column.java:718)

 

At this moment, using the following workaround:

    @ManyToOne

    @JoinColumns

    ({

            @JoinColumn(name = "id", referencedColumnName = "request_id", 
insertable = false, updatable = false),

            @JoinColumn(name = "head", referencedColumnName = "id", insertable 
= false, updatable = false)

    })

    Signature head;

 

    public void setHead(Signature head)

    {

        this.head = head;

        // https://stackoverflow.com/a/49019669/58794 

        head2115 = head == null ? null : head.getId();

    }

 

    private Long head2115;

 

    @Column(name = "head")

    private Long getHead2115()

    {

        return head2115;

    }

 

Note: JoinFormula workaround is doubly not acceptable – 1. Nonstandard, 2. 
org.hibernate.mapping.Formula cannot be cast to org.hibernate.mapping.Column

_______________________________________________
hibernate-dev mailing list
hibernate-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hibernate-dev

Reply via email to