Hi,
I like hibernate formulas in domain property mapping, because they enables
domain filtering/ordering (with formula-property).
On the other hand, this can be resource consuming and in many usecases unnecessary.
So I search pattern, how to permit "caller" determine, if in this
concrete usecase needs or not this formula-properties.
Say we have Person class and extension PersonX with formula-property.
Code:
class Person {
String name;
String email;
}
class PersonX extends Person {
/* online computed value from many other domain/tables info */
int rating;
}
Now, I want to determine, if rating property is needed or not.
So I create dao
Code:
public interface PersonDao <T extends Person> {
T load (String name);
}
and in code I will write
Code:
PersonDao<Person> dao;
PersonDao<PersonX> daoX;
Person adam = dao.load("adam"); // name, email
PersonX adamX = daoX.load("adam"); // name, email, rating
So. I can not find pattern, how arrange it in hibernate mapping.
Code:
<class name="Person" table="PERSON" dynamic-update="true">
<property name="name" column="NAME" />
<property name="email" column="EMAIL"/>
</class>
but what for PersonX?? where and how to declare
Code:
<property name="rating" formula=" (select blabla ... )"/>
I do not want two independency mapping one for Person and second for PersonX.
This is redundant code and not ideal for cache.
Classic hib inheritance depends on discriminator but this is not my case.
Can you please direct me to solution?
Regard
Jara