Storing superclass with inheritance JOINED strategy (Hibernate migration)

Description

I have migrated from Hibernate 4.2.2 to 5.1.2 and now I have a problem storing superclass with @Inheritance(strategy = InheritanceType.JOINED).

My Promotion entity is:

One of the extended classes is PromotionEvent:

In Hibernate 4.2.2 all was working, but now with Hibernate 5.1.2 when a promotion is stored I get the following exception: *ERROR pool-2-thread-2 SqlExceptionHelper.logExceptions - Parameter index out of range (16 > number of parameters, which is 15).
*
With the insert: insert into promotion (amount, client_id, description, end_datetime, event_end_datetime, event_start_datetime, hide_amount_at_ticket, name, percentage, promotion_type, requires_pda_alert, short_name, show_amount_original_at_ticket, start_datetime, state, status) values (?, ?, ?, ?, ?, ?, ?, ?, ?, 'event', ?, ?, ?, ?, ?, ?)

So, seems that is trying to insert de @DisciminatorValue of PromotionEvent in the assigned @DiscriminatorColumn, but @DisicriminatorColumn is @Basic and then persisted. So, here is the problem. But, why in Hibernate 4.x this was not happening?, Is it a 4.x or 5.1.2 version bug?.

I can see that it works if I make

That’s to say, insertable=false, then it works and @DiscriminatorValue is inserted in promotion_type.

Moreover, if I remove @DiscriminatorColumn from Promotion, it seems that all is working, but in this case I do not know how Hibernate knows the class type (with JOINED strategy I guess).

  • Should it be recommended to put insertable=false?.

  • Should it be better remove @DiscriminatorColumn if all it’s working?.

  • Can not be @DiscriminatorColumn a @Basic and insertable attribute?, so why in H4.2.2 there was no problem?

Environment

Mysql 5.6.21

Activity

Show:
Gail Badner
November 28, 2016, 9:38 PM

Please see HHH-6911.

Assignee

Gail Badner

Reporter

Raul Sanchez Florit

Fix versions

None

Labels

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure