I am using EMF and Teneo. I have an Employee class with a derived attribute. I also defined a Hibernate @Formula annotation for it as follows:
* @model
* default="0" transient="true" changeable="false"
* derived="true" ordered="false"
* annotation="teneo.jpa
* appinfo=' @Formula(\"select count(*) from Employee o where o.parent_e_id =e_id\")'"
I was expecting the query to fire whenever I load the Employee object by a call to .list().
However, the query to calculate the derived attribute never fires (checked the mysql log).
Any ideas on what I am doing wrong or any pointers on where to look?
I am answering to my own question since I have found the solution and someone else might need it
The attribute has to be defined as follows:
In other words, the attribute
Also the SQL statement should be in brackets since hibernate will generate a statement such as