Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Hibernate annotation ignored in teneo(Annotations in EMF/Teneo models)
Hibernate annotation ignored in teneo [message #1691196] Fri, 03 April 2015 06:59 Go to next message
Victor Roy is currently offline Victor RoyFriend
Messages: 3
Registered: May 2013
Junior Member
Hi,
I am having problems with a @Formula annotation in Teneo.
I have an Employee class and a derived attribute that shows the number of employees this employee is handling. The generated code results into this
* @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 would expect that whenever I queried the database to get a list of employees, that another query would kick in to calculate the attribute.

However, this does not seem to happen, and the derived attribute always returns its default value (I have checked the mysql logs that indeed no SQL query is generated for the @Formula annotation)

I am using Teneo 2.0.1

I would like to get *any* guidelines on how to use the formula annotation or at least any indication of why this is not working as expected.

Also, can someone point me to where I can see the generated hibernate mappings?

Thanks in advance,
VRoy

PS: I have also submitted a question to stackoverflow but I got no answer there
(see stackoverflow topic: how-to-use-formula-annotation-in-teneo-emf)
Re: Hibernate annotation ignored in teneo [message #1691210 is a reply to message #1691196] Fri, 03 April 2015 11:47 Go to previous message
Victor Roy is currently offline Victor RoyFriend
Messages: 3
Registered: May 2013
Junior Member
I am replying to my own question, because I solved the problem and I thought that someone else might need it.

1. The attribute has to be defined as follows:
	 * @model default="0" derived="true" ordered="false"
	 *        annotation="teneo.jpa appinfo=' @Formula(\"(select count(*) from Employee o where o.parent_e_id=e_id)\")'"



In other words, the attribute

must not be transient (false), for otherwise it is completely ignored when teneo generates the mapping (this is why the annotation is ignored)

must be changeable (so that the value of the attribute can be set)

Also the SQL statement should be in brackets since hibernate will generate a statement such as
select field1, field2, (select count (*) from Employe o where o.parent_e_id_e_id) as fieldname from table1 ....

[Updated on: Fri, 03 April 2015 11:48]

Report message to a moderator

Previous Topic:read a xml file
Next Topic:GMF with vaadin
Goto Forum:
  


Current Time: Fri Mar 29 00:42:24 GMT 2024

Powered by FUDForum. Page generated in 0.03606 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top