In a simple inheritance tree, an abstract superclass has two subclasses.
The subclasses both store a key-value pair, but but one will be holding a type Encrypted String, and the other one a plain old String.
Now, my question is can I do this:
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public abstract Attribute {
@Id
private Integer id;
@Column(name="attribute_key")
private String key;
}
@Entity
public EncryptedAttribute extends Attribute {
@Column(name="attribute_value")
private EncryptedString encryptedValue;
}
@Entity
public UnEncryptedAttribute extends Attribute {
@Column(name="attribute_value")
private String plainValue;
}
The Encrypted String and plain String should both end up as varchars in the db, but can I store persistent attributes associated with different sub-classes in the same column? This would avoid the "swiss-cheese" side-effect of storing null values in columns which aren't used in a particular row.