I have an entity Promotion, which has 3 simple fields (id, name, description) and all 3 will be mapped to DB. So far so good. Problem is with the 4th field, ruleModel, which is an instance of RuleModel and when constructed at runtime, it will contain object instances of a dozen other classes. I don't want to map RuleModel to a DB table, because that is a lot extra work and also unnecessary. I just want to store the ruleModel object instance into DB and then be able to load ruleModel from DB and restore the object instance in memory.
Code:
@Entity
public class Promotion {
@Id
@GeneratedValue
private Long id;
private String name;
private String description;
private RuleModel ruleModel;
}