|
|
|
|
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 |
Martin Taal 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
|
|
|
Powered by
FUDForum. Page generated in 0.02731 seconds