Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [TEXO] JPA join table naming
[TEXO] JPA join table naming [message #946918] Tue, 16 October 2012 16:28 Go to next message
Gary Godfrey is currently offline Gary GodfreyFriend
Messages: 31
Registered: February 2012
Member
Hi,

We need to provide a DDL to allow the customers to install the database schema. When I run DDL generator it reads the JPA annotations and applies standard JPA naming conventions:

e.g. code snippet
@Entity(name = "Applicant")
public class Applicant extends JPAIdentifier {

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	@OneToMany(cascade = { CascadeType.ALL })
	@OrderColumn()
	private List<Telephone> telephones = new ArrayList<Telephone>();

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	@OneToMany(cascade = { CascadeType.ALL })
	@OrderColumn()
	private List<Address> addresses = new ArrayList<Address>();


The Oracle DDL:
    create table Applicant_Address (
        Applicant_id bigint not null,
        addresses_id bigint not null,
        addresses_ORDER integer not null,
        primary key (Applicant_id, addresses_ORDER),
        unique (addresses_id)
    );

    create table Applicant_Telephone (
        Applicant_id bigint not null,
        telephones_id bigint not null,
        telephones_ORDER integer not null,
        primary key (Applicant_id, telephones_ORDER),
        unique (telephones_id)
    );


The tables generated via TEXO are named:
Applicant_Addresses
Applicant_Telephones



http://wiki.eclipse.org/Texo/ORM_JPA_Annotations_Details Texo Mapping Decisions explains the reasons for the naming strategy. Is there a way to change the behaviour so it uses the JPA default please?

Regards,
Gary
Re: [TEXO] JPA join table naming [message #946966 is a reply to message #946918] Tue, 16 October 2012 17:29 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Gary,
Maybe my confusion, but afaics in your examples the annotations do not contain db schema names (like table names). So I
guess the table names are decided on by the ORM you are using and not by Texo. So then you should check the ORM layer's
documentation.

You can also generate the annotations with all the db schema names. I think what you mean is that in this case the DDL
generator does not use the db schema names defined in the annotations.

The reason that Texo uses a different naming strategy is that the standard JPA approach easily gives name clashes as it
fails when there are 2 associations between 2 classes.

gr. Martin

On 10/16/2012 06:28 PM, Gary Godfrey wrote:
> Hi,
>
> We need to provide a DDL to allow the customers to install the database schema. When I run DDL generator it reads the
> JPA annotations and applies standard JPA naming conventions:
>
> e.g. code snippet
>
> @Entity(name = "Applicant")
> public class Applicant extends JPAIdentifier {
>
> /**
> * <!-- begin-user-doc --> <!-- end-user-doc -->
> * * @generated
> */
> @OneToMany(cascade = { CascadeType.ALL })
> @OrderColumn()
> private List<Telephone> telephones = new ArrayList<Telephone>();
>
> /**
> * <!-- begin-user-doc --> <!-- end-user-doc -->
> * * @generated
> */
> @OneToMany(cascade = { CascadeType.ALL })
> @OrderColumn()
> private List<Address> addresses = new ArrayList<Address>();
>
>
> The Oracle DDL:
>
> create table Applicant_Address (
> Applicant_id bigint not null,
> addresses_id bigint not null,
> addresses_ORDER integer not null,
> primary key (Applicant_id, addresses_ORDER),
> unique (addresses_id)
> );
>
> create table Applicant_Telephone (
> Applicant_id bigint not null,
> telephones_id bigint not null,
> telephones_ORDER integer not null,
> primary key (Applicant_id, telephones_ORDER),
> unique (telephones_id)
> );
>
>
> The tables generated via TEXO are named:
>
> Applicant_Addresses
> Applicant_Telephones
>
>
>
> http://wiki.eclipse.org/Texo/ORM_JPA_Annotations_Details Texo Mapping Decisions explains the reasons for the naming
> strategy. Is there a way to change the behaviour so it uses the JPA default please?
>
> Regards,
> Gary


--

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] JPA join table naming [message #947817 is a reply to message #946966] Wed, 17 October 2012 13:18 Go to previous message
Gary Godfrey is currently offline Gary GodfreyFriend
Messages: 31
Registered: February 2012
Member
Thanks Martin.

My mistake, JPA and SchemaExport utility using different naming strategies.
Previous Topic:Teneo Entity manager for Texo generated model
Next Topic:produce high quality diagram output of some ecore models
Goto Forum:
  


Current Time: Thu Apr 25 19:29:26 GMT 2024

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

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

Back to the top