| It seems that bytecode enhancement has changed from 5.2 to 5.3:
@Entity
@Cache(usage = CacheConcurrencyStrategy.NONE)
public class Generic extends AbstractGeneric<Generic.Type> {
public enum Type implements Marker {
ONE
}
}
@MappedSuperclass
@Cache(usage = CacheConcurrencyStrategy.NONE)
public class AbstractGeneric<T extends Marker> {
@Id
@GeneratedValue
public int id;
@Access(AccessType.PROPERTY)
private T entity;
private T getEntity() {
return entity;
}
private void setEntity(T entity) {
this.entity = entity;
}
}
public interface Marker {
}
Using bytecode enhancement and bootstrapping Hibernate results in:
This is because bytecode enhancement creates:
public Generic.Type $$_hibernate_read_entity() {
if (this.$$_hibernate_getInterceptor() != null) {
super.$$_hibernate_write_entity((Marker)this.$$_hibernate_getInterceptor().readObject(this, "entity", super.$$_hibernate_read_entity()));
}
return super.$$_hibernate_read_entity();
}
Prior 5.3, it looked like
public Marker $$_hibernate_read_entity() {
if (this.$$_hibernate_getInterceptor() != null) {
super.$$_hibernate_write_entity((Marker)this.$$_hibernate_getInterceptor().readObject(this, "entity", super.$$_hibernate_read_entity()));
}
return super.$$_hibernate_read_entity();
}
Removing the generic return type from the field and casting to the generic in getEntity() does not work in the test case, but solved the issues in our code stack. |