Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Texo] Best way to add JPA implementor specific annotation to generated entities
[Texo] Best way to add JPA implementor specific annotation to generated entities [message #799749] Thu, 16 February 2012 09:14 Go to next message
Benoit Cantin is currently offline Benoit CantinFriend
Messages: 34
Registered: January 2012
Member
Hi all,

I need to add Hibernate specific content to the code of the generated
entities.

With Texo, to customize the id generation, I can get :

     @Id()
     @GeneratedValue(generator = "CustomIdGenerator", strategy = 
GenerationType.AUTO)
     private Long id = null;


What I want is :

     @Id()
     @GeneratedValue(generator = "CustomIdGenerator", strategy = 
GenerationType.AUTO)
     @GenericGenerator(name = "CustomIdGenerator", strategy = 
"com.my.company.entities.CustomIdGenerator")
     private Long id = null;


(GenericGenerator being Hibernate specific)

What is the best solution to achieve this ? Do I have to use
@generatedNOT on my property called id ?

Thank you.
Re: [Texo] Best way to add JPA implementor specific annotation to generated entities [message #799914 is a reply to message #799749] Thu, 16 February 2012 13:12 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5340
Registered: July 2009
Senior Member
Hi Benoit,
Yes generatedNot indeed. Or afaik hibernate allows you to add extra mappings through the orm.xml. So in this case let
Texo generate the code as in your first example and then add the GenericGenerator using a separate manual orm.xml. The
hibernate docs can tell you more if this is possible (I believe so).

gr. Martin

On 02/16/2012 10:14 AM, Benoit Cantin wrote:
> Hi all,
>
> I need to add Hibernate specific content to the code of the generated entities.
>
> With Texo, to customize the id generation, I can get :
>
>
> @Id()
> @GeneratedValue(generator = "CustomIdGenerator", strategy = GenerationType.AUTO)
> private Long id = null;
> 

>
> What I want is :
>
>
> @Id()
> @GeneratedValue(generator = "CustomIdGenerator", strategy = GenerationType.AUTO)
> @GenericGenerator(name = "CustomIdGenerator", strategy = "com.my.company.entities.CustomIdGenerator")
> private Long id = null;
> 

>
> (GenericGenerator being Hibernate specific)
>
> What is the best solution to achieve this ? Do I have to use @generatedNOT on my property called id ?
>
> Thank you.


--

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] Best way to add JPA implementor specific annotation to generated entities [message #799930 is a reply to message #799914] Thu, 16 February 2012 13:26 Go to previous message
Benoit Cantin is currently offline Benoit CantinFriend
Messages: 34
Registered: January 2012
Member
On 02/16/2012 02:12 PM, Martin Taal wrote:
> Hi Benoit,
> Yes generatedNot indeed. Or afaik hibernate allows you to add extra
> mappings through the orm.xml. So in this case let Texo generate the code
> as in your first example and then add the GenericGenerator using a
> separate manual orm.xml. The hibernate docs can tell you more if this is
> possible (I believe so).

Thank you Martin. generatedNOT, will be set on a part of the code that
won't change much in the near future. So I am going to use it here.

--
Benoit

>
> gr. Martin
>
> On 02/16/2012 10:14 AM, Benoit Cantin wrote:
>> Hi all,
>>
>> I need to add Hibernate specific content to the code of the generated
>> entities.
>>
>> With Texo, to customize the id generation, I can get :
>>
>>
>> @Id()
>> @GeneratedValue(generator = "CustomIdGenerator", strategy =
>> GenerationType.AUTO)
>> private Long id = null;
>> 

>>
>> What I want is :
>>
>>
>> @Id()
>> @GeneratedValue(generator = "CustomIdGenerator", strategy =
>> GenerationType.AUTO)
>> @GenericGenerator(name = "CustomIdGenerator", strategy =
>> "com.my.company.entities.CustomIdGenerator")
>> private Long id = null;
>> 

>>
>> (GenericGenerator being Hibernate specific)
>>
>> What is the best solution to achieve this ? Do I have to use
>> @generatedNOT on my property called id ?
>>
>> Thank you.
>
>
Previous Topic:[FIXED][Texo] ORM Annotation -> Basic -> Enumerated : wrong JPA generation result
Next Topic:[XCORE] Feedback from tutorial
Goto Forum:
  


Current Time: Sat Dec 20 13:09:43 GMT 2014

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

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