Hello,
We are facing an issue here where the Ebean don't update the column in database described by @DiscriminatorColumn in a scenario where the entities are using @Inheritance with single table strategy whenever the entity class change.
To explain this better, consider this following classes (abbreviated to save space):
Super class
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "attribute_type", length = 50)
public abstract class MetaAttribute {
private UUID id;
}
Entity implementation 1
@Entity
@DiscriminatorValue(AttributeType.BOOLEAN_ATTRIBUTE)
public class BooleanAttribute extends MetaAttribute {
private boolean defaultBooleanValue;
}
Entity implementation 2
@Entity
@DiscriminatorValue(AttributeType.TEXT_ATTRIBUTE)
public class TextAttribute extends MetaAttribute {
private String defaultTextValue;
private Long maxLenght;
}
Theses classes describe attributes of a dynamic entity where each row in MetaAttribute table represents one attribute metadata (like it's type, default value and more). These attributes can be changed from one type to another (like from BooleanAttribute to TextAttribute), but whenever this happens Ebean don't update the column attribute_type in database and when the row is fetched again it is returned with the wrong implementation.
To reproduce this scenario these are the required steps:
- Create an instance of BooleanAttribute and insert it in the database.
- Convert the BooleanAttribute instance to TextAttribute keeping the same entity ID.
- Save the changes in database using Ebean update.
- Retrieve the entity from the database. It will be returned as an instance of BooleanAttribute.
Is there anything that we are missing (like some configuration, annotation or even misuse of the Ebean)? Or this isn't supported by Ebean for now?