Side note: Ok weird, I didn't get an email from this thread? I only came to google groups to check something and stumbled across this ...
---
Nice answers/options Jens.
Note that IF this was a case of the EAV (Entity Attribute Value) pattern, it is my opinion that the best approach to that is a JSON field assuming that there is good JSON support in the database(s). For example, Postrges JSONB. For myself, I'd be very hesitant to go to the older EAV table approach.
What I'd add, is that a while back if I recall correctly, I was talking to Roland (and others?) about the possibility of entities extended entities without JPA inheritance (which we don't do and isn't strictly valid in JPA). The thought was, would it be good/useful to be able to do:
@Entity
public class CustomUser extends User {
private String datacenterId;
...
}
... which maybe thought of as a variation on the JPA standard @MappedSuperclass approach (a variation that allows us to have more than 1 concrete implementation mapped to the same base table without using JPA inheritance).
So why would we do this rather than the standard JPA @MappedSuperclass (and probably some interface(s))? When we build/design User we might not absolutely know that something later wants to extend it in such a way. So supporting this means we don't need to redesign/retrofit back in some @MappedSuperclass later. For example, we have 20 customers and only 1 of them needs a customization of only 1 extra column on only 1 entity ... (if ebean supported this) this would be a smaller change to make to accommodate/retrofit that need.
So, if we supported this we'd have application code that could use User or CustomUser and they happen to point to the same table. Internally it would be similar to an Ebean @View in terms of invalidating L2 caching appropriately.
// common code ...
@Entity
@Table(name="my_user")
public class User { ... }
// custom code ...
// The Ebean @View mechanism can be used in terms of L2 caching
@Entity
// @View(name="my_user", dependantTables="my_user")
public class CustomUser extends User {
private String datacenterId;
...
}
In case it's not super obvious, this is really for applications that are built by a company and deployed for each customer, and where there is some potential for customization specific to that customer.
Hmmm.