Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [Teneo] Auto adding an annotation for every column and table
[Teneo] Auto adding an annotation for every column and table [message #427448] Wed, 18 February 2009 11:45 Go to next message
David Wynter is currently offline David WynterFriend
Messages: 4624
Registered: July 2009
Senior Member
Hi Martin,

My xsd is already 10,000 lines long. If I was to add an annotation for
every attribute specifying the column name with back ticks and similar
for table names it will be over 30,000 lines long.

I have asked if there is a way to force Hibernate to always use quoted
names and prefix the schema name to the tables names in generated SQL on
their forum.

But it occurred to me I might be able to add some code to Teneo to get
it to insert these annotations for me. Any pointers as to were I should
start?

Thanks,

David
Re: [Teneo] Auto adding an annotation for every column and table [message #427456 is a reply to message #427448] Wed, 18 February 2009 12:10 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
David,

Comments below.

David Wynter wrote:
> Hi Martin,
>
> My xsd is already 10,000 lines long. If I was to add an annotation for
> every attribute specifying the column name with back ticks and similar
> for table names it will be over 30,000 lines long.
Did you know that an annotation of the form abc:def="foo" transforms to
an EAnnotation whose "source" is the value of xmlns:abc="..." and that
contains a def -> foo details entry? Likely that could be used to just
make your lines longer... :-P
>
> I have asked if there is a way to force Hibernate to always use quoted
> names and prefix the schema name to the tables names in generated SQL
> on their forum.
>
> But it occurred to me I might be able to add some code to Teneo to get
> it to insert these annotations for me. Any pointers as to were I
> should start?
>
> Thanks,
>
> David


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [Teneo] Auto adding an annotation for every column and table [message #427465 is a reply to message #427456] Wed, 18 February 2009 14:54 Go to previous messageGo to next message
David Wynter is currently offline David WynterFriend
Messages: 4624
Registered: July 2009
Senior Member
Hi,

Your comment passed in the airspace just above my head.

Here is an attribute without annotation

<xsd:attribute name="id" type="xsd:int" />


Here is one with annotation.

<xsd:attribute name="id" default="-1" type="xsd:int">
<xsd:annotation>
<xsd:appinfo source="teneo.jpa">@Id
@GeneratedValue(strategy=IDENTITY)</xsd:appinfo>
</xsd:annotation>
</xsd:attribute>

Do you mean this is equivalent?

<xsd:attribute teneo.jpa:Id
teneo.jpa:GenerateValue="strategy=IDENTITY" name="id" type="xsd:int" />

Thx.

David


Ed Merks wrote:
> David,
>
> Comments below.
>
> David Wynter wrote:
>> Hi Martin,
>>
>> My xsd is already 10,000 lines long. If I was to add an annotation for
>> every attribute specifying the column name with back ticks and similar
>> for table names it will be over 30,000 lines long.
> Did you know that an annotation of the form abc:def="foo" transforms to
> an EAnnotation whose "source" is the value of xmlns:abc="..." and that
> contains a def -> foo details entry? Likely that could be used to just
> make your lines longer... :-P
>>
>> I have asked if there is a way to force Hibernate to always use quoted
>> names and prefix the schema name to the tables names in generated SQL
>> on their forum.
>>
>> But it occurred to me I might be able to add some code to Teneo to get
>> it to insert these annotations for me. Any pointers as to were I
>> should start?
>>
>> Thanks,
>>
>> David
Re: [Teneo] Auto adding an annotation for every column and table [message #427469 is a reply to message #427465] Wed, 18 February 2009 15:24 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
David,

Like this I think:

<xsd:attribute xmlns:foo="teneo.jpa" foo:appinfo="@Id
@GeneratedValue(strategy=IDENTITY)" name="id" type="xsd:int" />

The prefix foo doesn't matter and obviously you can declare it once at
the top of the schema. Just experiment till it works out right...


David Wynter wrote:
> Hi,
>
> Your comment passed in the airspace just above my head.
>
> Here is an attribute without annotation
>
> <xsd:attribute name="id" type="xsd:int" />
>
>
> Here is one with annotation.
>
> <xsd:attribute name="id" default="-1" type="xsd:int">
> <xsd:annotation>
> <xsd:appinfo source="teneo.jpa">@Id
> @GeneratedValue(strategy=IDENTITY)</xsd:appinfo>
> </xsd:annotation>
> </xsd:attribute>
>
> Do you mean this is equivalent?
>
> <xsd:attribute teneo.jpa:Id
> teneo.jpa:GenerateValue="strategy=IDENTITY" name="id" type="xsd:int" />
>
> Thx.
>
> David
>
>
> Ed Merks wrote:
>> David,
>>
>> Comments below.
>>
>> David Wynter wrote:
>>> Hi Martin,
>>>
>>> My xsd is already 10,000 lines long. If I was to add an annotation
>>> for every attribute specifying the column name with back ticks and
>>> similar for table names it will be over 30,000 lines long.
>> Did you know that an annotation of the form abc:def="foo" transforms
>> to an EAnnotation whose "source" is the value of xmlns:abc="..." and
>> that contains a def -> foo details entry? Likely that could be used
>> to just make your lines longer... :-P
>>>
>>> I have asked if there is a way to force Hibernate to always use
>>> quoted names and prefix the schema name to the tables names in
>>> generated SQL on their forum.
>>>
>>> But it occurred to me I might be able to add some code to Teneo to
>>> get it to insert these annotations for me. Any pointers as to were I
>>> should start?
>>>
>>> Thanks,
>>>
>>> David


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [Teneo] Auto adding an annotation for every column and table [message #427476 is a reply to message #427469] Wed, 18 February 2009 21:06 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi David,
There are several other options available to you:
- You can specify the annotations in a separate xml file.
- You can also implement your own SQLNameStrategy class and tell Teneo to use that (see the extension mechanism
described on elver.org).
- Or you can override the default annotators to do this for you (also using the extension mechanism). The default
annotators for hibernate are all present in the org.eclipse.emf.teneo.hibernate.annotations package.

Note, you can override many Teneo classes, to find out which one do ctrl-shft-T and search for ExtensionPoint and then
find all subclasses/implementors of this interface, there are about 40 classes.

gr. Martin

Ed Merks wrote:
> David,
>
> Like this I think:
>
> <xsd:attribute xmlns:foo="teneo.jpa" foo:appinfo="@Id
> @GeneratedValue(strategy=IDENTITY)" name="id" type="xsd:int" />
>
> The prefix foo doesn't matter and obviously you can declare it once at
> the top of the schema. Just experiment till it works out right...
>
>
> David Wynter wrote:
>> Hi,
>>
>> Your comment passed in the airspace just above my head.
>>
>> Here is an attribute without annotation
>>
>> <xsd:attribute name="id" type="xsd:int" />
>>
>>
>> Here is one with annotation.
>>
>> <xsd:attribute name="id" default="-1" type="xsd:int">
>> <xsd:annotation>
>> <xsd:appinfo source="teneo.jpa">@Id
>> @GeneratedValue(strategy=IDENTITY)</xsd:appinfo>
>> </xsd:annotation>
>> </xsd:attribute>
>>
>> Do you mean this is equivalent?
>>
>> <xsd:attribute teneo.jpa:Id
>> teneo.jpa:GenerateValue="strategy=IDENTITY" name="id" type="xsd:int" />
>>
>> Thx.
>>
>> David
>>
>>
>> Ed Merks wrote:
>>> David,
>>>
>>> Comments below.
>>>
>>> David Wynter wrote:
>>>> Hi Martin,
>>>>
>>>> My xsd is already 10,000 lines long. If I was to add an annotation
>>>> for every attribute specifying the column name with back ticks and
>>>> similar for table names it will be over 30,000 lines long.
>>> Did you know that an annotation of the form abc:def="foo" transforms
>>> to an EAnnotation whose "source" is the value of xmlns:abc="..." and
>>> that contains a def -> foo details entry? Likely that could be used
>>> to just make your lines longer... :-P
>>>>
>>>> I have asked if there is a way to force Hibernate to always use
>>>> quoted names and prefix the schema name to the tables names in
>>>> generated SQL on their forum.
>>>>
>>>> But it occurred to me I might be able to add some code to Teneo to
>>>> get it to insert these annotations for me. Any pointers as to were I
>>>> should start?
>>>>
>>>> Thanks,
>>>>
>>>> David


--

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:[Teneo] Mapping creation failed
Next Topic:Synchronize to EObjects completely
Goto Forum:
  


Current Time: Thu Apr 25 21:38:49 GMT 2024

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

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

Back to the top