Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Texo] How difficult would it be to add JPA implementors annotation models ?
[Texo] How difficult would it be to add JPA implementors annotation models ? [message #803380] Tue, 21 February 2012 09:09 Go to next message
Benoit Cantin is currently offline Benoit CantinFriend
Messages: 34
Registered: January 2012
Member
Hi all,

I've already mentioned here my need to add hibernate specific annotations to the Texo generated JPA code. I wanted to add a @GenericGenerator, on the field id. Because it was a single annotation in a very specific part of my entity model, I decided to add @generatedNOT on that field, and to manually add @GenericGenerator.

But now, I am facing the same kind of problem with another annotation (@Audited to be precised) that is not part of JPA, and this time, @Audited has to be generated on all my entities, along with @Entity. Of course, in this case, I can't make use of @generatedNOT.

I can see 3 ways to achieve this :
1) make use of orm.xml as explained by Martin here
2) Wait for that feature (separated code source generation) : here
3) Propose an enhancement of Texo that would consist of new possibilities in the annotation model. By default, Texo would act as now, I mean, in the annotation model, it would allow the user to specify pure JPA. And by a system of extension (maybe in the Texo configuration), Texo would allow the user to add in his annotation models, JPA implementors specific annotations (like @GenericGenerator, @Audited, etc). I guess that it would make sense for Hibernate, but I don't know much about other ones.

Because my JPA entities are the heart of my application, I am reluctant to use orm.xml. I really would like to put everything in my entities.

From that point of view, solutions 2 and 3 seem to be better. And from those ones, solution 3 seems to be the best (I took the example of @Audited along with @Entity, but there are other use cases like @OnDelete on one to many relations (a single query is generated instead of a query for each object in the relation to delete when this annotation is absent).

Thanks

[Updated on: Tue, 21 February 2012 09:22]

Report message to a moderator

Re: [Texo] How difficult would it be to add JPA implementors annotation models ? [message #804620 is a reply to message #803380] Wed, 22 February 2012 20:40 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Benoit,
As often the case the nicest solution is more work :-). I agree that 3) is the best. Texo has been developed to allow
adding new annotations models and annotation generators (the orm annotations is an example of this). But I have never
documented it, and it requires probably covering several details.

I am now on holiday but am interested to solve 2) (sometime the upcoming month) and maybe create an example of an
annotation model for 3), then using this example annotation model (1-2 plugins) others can create their own specific
annotations model.

Btw, if you are interested to contribute here, let me know!

In any case, can you enter a bugzilla for adding an example of an annotation model and a tutorial? Then I can start there.

gr. Martin

On 02/21/2012 10:09 AM, Benoit Cantin wrote:
> Hi all,
>
> I've already mentioned here my need to add hibernate
> specific annotations to the Texo generated JPA code. I wanted to add a @GenericGenerator, on the field id. Because it
> was a single annotation in a very specific part of my entity model, I decided to add @generatedNOT on that field, and to
> manually add @GenericGenerator.
>
> But now, I am facing the same kind of problem with another annotation (@Audited to be precised) that is not part of JPA,
> and this time, @Audited has to be generated on all my entities, along with @Entity. Of course, in this case, I can't
> make use of @generatedNOT.
>
> I can see 3 ways to achieve this :
> 1) make use of orm.xml as explained by Martin
> here
> 2) Wait for that feature (separated code source generation) :
> here
> 3) Propose an enhancement of Texo that would consist of new possibilities in the annotation model. By default, Texo
> would act as now, I mean, in the annotation model, it would allow the user to specify pure JPA. And by a system of
> extension (maybe in the Texo configuration), Texo would allow the user to add in his annotation models, JPA implementors
> specific annotations (like @GenericGenerator, @Audited, etc). I guess that it would make sens for Hibernate, but I don't
> know much about other ones.
>
> Because my JPA entities are the heart of my application, I am reluctant to use orm.xml. I really would like to put
> everything in my entities.
>
> From that point of view, solutions 2 and 3 seem to be better. And from those ones, solution 3 seems to be the best (I
> took the example of @Audited along with @Entity, but there are other use cases like @OnDelete on one to many relations
> (a single query is generated instead of a query for each object in the relation to delete when this annotation is absent).
>
> Thanks


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [Texo] How difficult would it be to add JPA implementors annotation models ? [message #805326 is a reply to message #804620] Thu, 23 February 2012 16:34 Go to previous messageGo to next message
Benoit Cantin is currently offline Benoit CantinFriend
Messages: 34
Registered: January 2012
Member
Hi Martin,

Done : https://bugs.eclipse.org/bugs/show_bug.cgi?id=372368

I've also created a couple of other bugzillas for various code generation things.

I am really interested in contributing. Please just let me some times to study source code, developing conventions here at eclipse, etc... Any entry point on the source code to understand the global architecture of texo will be greatly appreciated. Note that I can't promise much more. That would be taken on my free time as you I guess.

Re: [Texo] How difficult would it be to add JPA implementors annotation models ? [message #805494 is a reply to message #805326] Thu, 23 February 2012 20:46 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Benoit,
Yes saw the bugzillas, I am on holiday but will do my best to take a look at them, I always tend to do the easiest one
first (shortest-processing-time first approach), this gives the least average waiting time :-).

I will answer to this post again with some pointers (hopefully tomorrow).

gr. Martin

On 02/23/2012 05:34 PM, Benoit Cantin wrote:
> Hi Martin,
>
> Done : https://bugs.eclipse.org/bugs/show_bug.cgi?id=372368
>
> I've also created a couple of other bugzillas for various code generation things.
>
> I am really interested in contributing. Please just let me some times to study source code, developing conventions here
> at eclipse, etc... Any entry point on the source code to understand the global architecture of texo will be greatly
> appreciated. Note that I can't promise much more. That would be taken on my free time as you I guess.
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [Texo] How difficult would it be to add JPA implementors annotation models ? [message #805850 is a reply to message #805494] Fri, 24 February 2012 08:01 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Benoit,
Here is some pointers, after cloning the git repository, you can see a number of main directories:
core --> contains the core plugins used both at runtime and during code/artifact generation
features --> not important, used during build
generator --> contains the plugins related to artifact generation
infra --> not important, used during build
runtime --> used at runtime, this includes some developments I am doing for webservice support
tests --> contains all the test plugins, test models etc.

The generator plugins are the most interesting ones. Let's take the orm one as an example. It has 2 plugins:
org.eclipse.emf.texo.orm.edit --> adds new properties to the annotations model ui
org.eclipse.emf.texo.orm --> contains the orm model, links the orm annotations to model elements (eclass,
estructuralfeature) and the annotator code which is used to generate annotations, the annotator code tries to preserve
current/manual annotations and only add new annotations if applicable.

The annotator code is the most interesting, for each model element (eclass, eattribute, ereference) there is an
annotator, for example: EReferenceORMAnnotator.

During the annotation process (which happens before generating the code) the following 2 methods are called:
setAnnotationFeatures: this method is called so that new annotations can be added to the model element, this takes care
of automatic annotation
postAnnotating: is called after setAnnotationFeatures have been called on all model elements, can be used for post
processing

For more information see the javadoc of the org.eclipse.emf.texo.generator.Annotator class.

If you want to try something, the issue you entered is a good first try:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=371509

For this one the EReferenceORMAnnotator should be checked.

gr. Martin

On 02/23/2012 09:46 PM, Martin Taal wrote:
> Hi Benoit,
> Yes saw the bugzillas, I am on holiday but will do my best to take a look at them, I always tend to do the easiest one
> first (shortest-processing-time first approach), this gives the least average waiting time :-).
>
> I will answer to this post again with some pointers (hopefully tomorrow).
>
> gr. Martin
>
> On 02/23/2012 05:34 PM, Benoit Cantin wrote:
>> Hi Martin,
>>
>> Done : https://bugs.eclipse.org/bugs/show_bug.cgi?id=372368
>>
>> I've also created a couple of other bugzillas for various code generation things.
>>
>> I am really interested in contributing. Please just let me some times to study source code, developing conventions here
>> at eclipse, etc... Any entry point on the source code to understand the global architecture of texo will be greatly
>> appreciated. Note that I can't promise much more. That would be taken on my free time as you I guess.
>>
>>
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Re: [Texo] How difficult would it be to add JPA implementors annotation models ? [message #815993 is a reply to message #805850] Thu, 08 March 2012 09:39 Go to previous messageGo to next message
Benoit Cantin is currently offline Benoit CantinFriend
Messages: 34
Registered: January 2012
Member
Hi Martin,

I'm sorry to not be able to contribute until now. I've checked out Texo,
and I think that one blocking point is that I don't understand how to
test the code I could write. Moreover, I am missing some dependencies so
that Texo does not compile. For example, things like this :

Description : AnalysationIssueType not found:Type not found: EClass
Resource : util.ext
Path :
/org.eclipse.emf.texo.modelgenerator/src/org/eclipse/emf/texo/modelgenerator/templates
Location line: 14
Type : Xtend/Xpand Problem

Or :

Description : AnalysationIssueType not found:Couldn't find type
EReferenceModelGenAnnotation
Resource : modelobject.xpt
Path :
/org.eclipse.emf.texo.modelgenerator/src/org/eclipse/emf/texo/modelgenerator/templates
Location : line: 125
Type : Xtend/Xpand Problem

I guess that sounds like a newbie question... Sorry for this too.


On 02/24/2012 09:01 AM, Martin Taal wrote:
> Hi Benoit,
> Here is some pointers, after cloning the git repository, you can see a
> number of main directories:
> core --> contains the core plugins used both at runtime and during
> code/artifact generation
> features --> not important, used during build
> generator --> contains the plugins related to artifact generation
> infra --> not important, used during build
> runtime --> used at runtime, this includes some developments I am doing
> for webservice support
> tests --> contains all the test plugins, test models etc.
>
> The generator plugins are the most interesting ones. Let's take the orm
> one as an example. It has 2 plugins:
> org.eclipse.emf.texo.orm.edit --> adds new properties to the annotations
> model ui
> org.eclipse.emf.texo.orm --> contains the orm model, links the orm
> annotations to model elements (eclass, estructuralfeature) and the
> annotator code which is used to generate annotations, the annotator code
> tries to preserve current/manual annotations and only add new
> annotations if applicable.
>
> The annotator code is the most interesting, for each model element
> (eclass, eattribute, ereference) there is an annotator, for example:
> EReferenceORMAnnotator.
>
> During the annotation process (which happens before generating the code)
> the following 2 methods are called:
> setAnnotationFeatures: this method is called so that new annotations can
> be added to the model element, this takes care of automatic annotation
> postAnnotating: is called after setAnnotationFeatures have been called
> on all model elements, can be used for post processing
>
> For more information see the javadoc of the
> org.eclipse.emf.texo.generator.Annotator class.
>
> If you want to try something, the issue you entered is a good first try:
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=371509
>
> For this one the EReferenceORMAnnotator should be checked.
>
> gr. Martin
>
> On 02/23/2012 09:46 PM, Martin Taal wrote:
>> Hi Benoit,
>> Yes saw the bugzillas, I am on holiday but will do my best to take a
>> look at them, I always tend to do the easiest one
>> first (shortest-processing-time first approach), this gives the least
>> average waiting time :-).
>>
>> I will answer to this post again with some pointers (hopefully tomorrow).
>>
>> gr. Martin
>>
>> On 02/23/2012 05:34 PM, Benoit Cantin wrote:
>>> Hi Martin,
>>>
>>> Done : https://bugs.eclipse.org/bugs/show_bug.cgi?id=372368
>>>
>>> I've also created a couple of other bugzillas for various code
>>> generation things.
>>>
>>> I am really interested in contributing. Please just let me some times
>>> to study source code, developing conventions here
>>> at eclipse, etc... Any entry point on the source code to understand
>>> the global architecture of texo will be greatly
>>> appreciated. Note that I can't promise much more. That would be taken
>>> on my free time as you I guess.
>>>
>>>
>>
>>
>
>
Re: [Texo] How difficult would it be to add JPA implementors annotation models ? [message #816091 is a reply to message #815993] Thu, 08 March 2012 12:14 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Benoit,
No problem, did you install the xpand toolset in your ide? It can be found in the modeling category in indigo.

For testing code generation:
- in the org.eclipse.emf.texo.modelgenerator.test there in the src directory inside the
org.eclipse.emf.texo.modelgenerator.test.models package you can put your own test models
- then to generate code for your testmodel, go to the EclipseModelGeneratorSingleModelTest.java then inside the method
in that class add your model file to the modelFiles list (comment out all the other ones so that you only test one model)
- then run/debug the launch config (located in that same project):
EclipseModelGeneratorSingleModelTest
this should hopefully generate code inside this plugin/project: I expect problems here as paths maybe hard coded somehow
in this launch config, but let's first try it out!
org.eclipse.emf.texo.test.model in the src-gen folder.
(maybe you have to refresh the project)

The code generation uses a second workspace which imports the org.eclipse.emf.texo.test.model project.

If you want to add your model to the overall testsuite, add in the
org.eclipse.emf.texo.modelgenerator.test.models.TestModel class

gr. Martin

On 03/08/2012 10:39 AM, Benoit Cantin wrote:
> Hi Martin,
>
> I'm sorry to not be able to contribute until now. I've checked out Texo, and I think that one blocking point is that I
> don't understand how to test the code I could write. Moreover, I am missing some dependencies so that Texo does not
> compile. For example, things like this :
>
> Description : AnalysationIssueType not found:Type not found: EClass
> Resource : util.ext
> Path : /org.eclipse.emf.texo.modelgenerator/src/org/eclipse/emf/texo/modelgenerator/templates
> Location line: 14
> Type : Xtend/Xpand Problem
>
> Or :
>
> Description : AnalysationIssueType not found:Couldn't find type EReferenceModelGenAnnotation
> Resource : modelobject.xpt
> Path : /org.eclipse.emf.texo.modelgenerator/src/org/eclipse/emf/texo/modelgenerator/templates
> Location : line: 125
> Type : Xtend/Xpand Problem
>
> I guess that sounds like a newbie question... Sorry for this too.
>
>
> On 02/24/2012 09:01 AM, Martin Taal wrote:
>> Hi Benoit,
>> Here is some pointers, after cloning the git repository, you can see a
>> number of main directories:
>> core --> contains the core plugins used both at runtime and during
>> code/artifact generation
>> features --> not important, used during build
>> generator --> contains the plugins related to artifact generation
>> infra --> not important, used during build
>> runtime --> used at runtime, this includes some developments I am doing
>> for webservice support
>> tests --> contains all the test plugins, test models etc.
>>
>> The generator plugins are the most interesting ones. Let's take the orm
>> one as an example. It has 2 plugins:
>> org.eclipse.emf.texo.orm.edit --> adds new properties to the annotations
>> model ui
>> org.eclipse.emf.texo.orm --> contains the orm model, links the orm
>> annotations to model elements (eclass, estructuralfeature) and the
>> annotator code which is used to generate annotations, the annotator code
>> tries to preserve current/manual annotations and only add new
>> annotations if applicable.
>>
>> The annotator code is the most interesting, for each model element
>> (eclass, eattribute, ereference) there is an annotator, for example:
>> EReferenceORMAnnotator.
>>
>> During the annotation process (which happens before generating the code)
>> the following 2 methods are called:
>> setAnnotationFeatures: this method is called so that new annotations can
>> be added to the model element, this takes care of automatic annotation
>> postAnnotating: is called after setAnnotationFeatures have been called
>> on all model elements, can be used for post processing
>>
>> For more information see the javadoc of the
>> org.eclipse.emf.texo.generator.Annotator class.
>>
>> If you want to try something, the issue you entered is a good first try:
>> https://bugs.eclipse.org/bugs/show_bug.cgi?id=371509
>>
>> For this one the EReferenceORMAnnotator should be checked.
>>
>> gr. Martin
>>
>> On 02/23/2012 09:46 PM, Martin Taal wrote:
>>> Hi Benoit,
>>> Yes saw the bugzillas, I am on holiday but will do my best to take a
>>> look at them, I always tend to do the easiest one
>>> first (shortest-processing-time first approach), this gives the least
>>> average waiting time :-).
>>>
>>> I will answer to this post again with some pointers (hopefully tomorrow).
>>>
>>> gr. Martin
>>>
>>> On 02/23/2012 05:34 PM, Benoit Cantin wrote:
>>>> Hi Martin,
>>>>
>>>> Done : https://bugs.eclipse.org/bugs/show_bug.cgi?id=372368
>>>>
>>>> I've also created a couple of other bugzillas for various code
>>>> generation things.
>>>>
>>>> I am really interested in contributing. Please just let me some times
>>>> to study source code, developing conventions here
>>>> at eclipse, etc... Any entry point on the source code to understand
>>>> the global architecture of texo will be greatly
>>>> appreciated. Note that I can't promise much more. That would be taken
>>>> on my free time as you I guess.
>>>>
>>>>
>>>
>>>
>>
>>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@springsite.com - mtaal@elver.org
Web: www.springsite.com - www.elver.org
Previous Topic:safe bi-directional association API for many to many association
Next Topic:rolling back a transaction manually
Goto Forum:
  


Current Time: Thu Apr 25 00:31:18 GMT 2024

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

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

Back to the top