[TEXO] JPA join table naming [message #946918] |
Tue, 16 October 2012 16:28 |
Gary Godfrey 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 |
Martin Taal 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
|
|
|
|
Powered by
FUDForum. Page generated in 0.03425 seconds