Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Texo: how to annotate all tables: prefix for tables in db
Texo: how to annotate all tables: prefix for tables in db [message #871517] Mon, 14 May 2012 10:03 Go to next message
Olaf Burdziakowski is currently offline Olaf BurdziakowskiFriend
Messages: 46
Registered: April 2012
Member
How to define annotation to define prefix for all tables for my package?
I would like to use JPA annotation for Hibernate but not trough ORM file. I would like Texo generate table prefixes for all classes in my package. How to define this?

Example:

@Entity(name = "MyPrefix_FileType")
public class FileType {
Re: Texo: how to annotate all tables: prefix for tables in db [message #871541 is a reply to message #871517] Mon, 14 May 2012 11:14 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Olaf,
For this you need an annotations model, see my other answer also.

For ORM specific annotations see here:
http://wiki.eclipse.org/Texo/ORM_JPA_Annotations_Details#Introduction

The table prefix is defined in the epackage ORM annotation, see the attached file.

gr. Martin

On 05/14/2012 12:03 PM, Olaf Burdziakowski wrote:
> How to define annotation to define prefix for all tables for my package?
> I would like to use JPA annotation for Hibernate but not trough ORM file. I would like Texo generate table prefixes for
> all classes in my package. How to define this?
> Example:
>
> @Entity(name = "MyPrefix_FileType")
> public class FileType {


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: Texo: how to annotate all tables: prefix for tables in db [message #871569 is a reply to message #871541] Mon, 14 May 2012 12:49 Go to previous messageGo to next message
Olaf Burdziakowski is currently offline Olaf BurdziakowskiFriend
Messages: 46
Registered: April 2012
Member
@Martin,
I tried this first before I asked question on the forum:

I set annotation:
<annotatedEPackages>
<ePackage href="config_dir.ecore#/"/>
<ePackageAnnotations xsi:type="ormannotations:EPackageORMAnnotation" nameDictionaryPropertyFile="" tableNamePrefix="ABC"/>
</annotatedEPackages>

Then I run Generate JPA Annotated model code but still there is:

package model.configdir;
...
@Entity(name = "FilesType")
public class FilesType

I expected get this:

@Entity(name = "ABCFilesType")
public class FilesType

What is wrong?
Re: Texo: how to annotate all tables: prefix for tables in db [message #871571 is a reply to message #871569] Mon, 14 May 2012 12:53 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Olaf,
Ha sorry there is also this property on the epackage orm annotation:
generate Full Db Schema Names

it should be set to true. This should result in an extra @Table annotation on the generated class.

gr. Martin

On 05/14/2012 02:49 PM, Olaf Burdziakowski wrote:
> @Martin,
> I tried this first before I asked question on the forum:
>
> I set annotation:
> <annotatedEPackages>
> <ePackage href="config_dir.ecore#/"/>
> <ePackageAnnotations xsi:type="ormannotations:EPackageORMAnnotation" nameDictionaryPropertyFile="" tableNamePrefix="ABC"/>
> </annotatedEPackages>
>
> Then I run Generate JPA Annotated model code but still there is:
>
> package model.configdir;
> ...
> @Entity(name = "FilesType")
> public class FilesType
>
> I expected get this:
>
> @Entity(name = "ABCFilesType")
> public class FilesType
>
> What is wrong?


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: Texo: how to annotate all tables: prefix for tables in db [message #871590 is a reply to message #871571] Mon, 14 May 2012 13:35 Go to previous messageGo to next message
Olaf Burdziakowski is currently offline Olaf BurdziakowskiFriend
Messages: 46
Registered: April 2012
Member
Hi Martin,
it helped, thank you. Now I have:

@Entity(name = "FileType")
@Table(name = "ABCFileType")
public class FileType

But I wanted prefix due to another schema with the same element: FileType.
So to really have different Entity name (Hibernate complains about duplicates) I had to define an extra annotation for my class:
<ePackage href="config_dir.ecore#/"/>
<ePackageAnnotations xsi:type="ormannotations:EPackageORMAnnotation" generateFullDbSchemaNames="true" nameDictionaryPropertyFile="" tableNamePrefix="ABC"/>
<ePackageAnnotations xsi:type="modelannotations:EPackageModelGenAnnotation" javaFileHeader="" rootClassExtends="model.identifiable.Identifiable"/>
<annotatedEClassifiers xsi:type="annotationsmodel:AnnotatedEClass">
<eClass href="config_dir.ecore#//FileType"/>
<eClassAnnotations xsi:type="ormannotations:EClassORMAnnotation">
<entity class="" name="ABCFileType"/>
</eClassAnnotations>

</annotatedEClassifiers>

Now I have what I wanted:
@Entity(name = "ABCFileType")
@Table(name = "ABCFileType")
public class FileType

Is this designed solution? Can I have the same result with some common assignment?
I would like to get this for all classes in my package:

@Entity(name = "ABCFileType")
public class FileType

[Updated on: Mon, 14 May 2012 13:36]

Report message to a moderator

Re: Texo: how to annotate all tables: prefix for tables in db [message #871618 is a reply to message #871590] Mon, 14 May 2012 14:29 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Olaf,
There is another property on the epackage orm annotation: enforceUniqueNames
set it to true, then your entitynames will be prefixed with the xsd schema prefix which gives more uniqueness.

gr. Martin

On 05/14/2012 03:35 PM, Olaf Burdziakowski wrote:
> Hi Martin,
> it helped, thank you. Now I have:
>
> @Entity(name = "FileType")
> @Table(name = "ABCFileType")
> public class FileType
>
> But I wanted prefix due to another schema with the same element: FileType.
> So to really have different Entity name (Hibernate complains about duplicates) I had to define an extra annotation for
> my class:
> <ePackage href="config_dir.ecore#/"/>
> <ePackageAnnotations xsi:type="ormannotations:EPackageORMAnnotation" generateFullDbSchemaNames="true"
> nameDictionaryPropertyFile="" tableNamePrefix="ABC"/>
> <ePackageAnnotations xsi:type="modelannotations:EPackageModelGenAnnotation" javaFileHeader=""
> rootClassExtends="model.identifiable.Identifiable"/>
> <annotatedEClassifiers xsi:type="annotationsmodel:AnnotatedEClass">
> <eClass href="config_dir.ecore#//FileType"/>
> <eClassAnnotations xsi:type="ormannotations:EClassORMAnnotation">
> <entity class="" name="ABCFileType"/>
> </eClassAnnotations>
> </annotatedEClassifiers>
>
> Now I have what I wanted:
> @Entity(name = "ABCFileType")
> @Table(name = "ABCFileType")
> public class FileType
>
> Is this designed solution? Can I have the same result with some common assignment?
> I would like to get this:
>
> @Entity(name = "ABCFileType")
> public class FileType


--

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@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Previous Topic:EMF extension mechanisms
Next Topic:[CDO/Hibernate/Teneo] java.lang.String cannot be cast to java.lang.Long
Goto Forum:
  


Current Time: Thu Apr 18 19:57:40 GMT 2024

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

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

Back to the top