Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "EclipseLink/DesignDocs/214519"

(Design)
Line 53: Line 53:
 
will result in the creation statement:
 
will result in the creation statement:
  
<source>
+
<pre>
 
   CREATE TABLE DDL_EMPLOYEE (ID INTEGER) engine=InnoDB
 
   CREATE TABLE DDL_EMPLOYEE (ID INTEGER) engine=InnoDB
</source>
+
</pre>
  
 
= Testing =
 
= Testing =

Revision as of 09:53, 5 October 2010

Design Specification: Appending strings to CREATE TABLE statements

Enhancement Request bug 214519

Feedback

Document History

Date Author Version Description & Notes
2010-09-30 Chris Delahunt 0.1 Draft

Summary

Allow appending strings to CREATE TABLE statements for DDL generation

Requirements

Support specifying strings through persistence unit/session properties that apply to all tables, as well as strings on individual tables. At the persistence unit/session level, this allows appending strings such as "engine=InnoDB" that would apply to every table and still have strings defined in annotations and eclipselink-orm.xml that apply to individual tables.

Feature is only for DDL generation purposes and affects no other runtime behavior.

Design

API changes: org.eclipse.persistence.sessions.Project will have a public set/getDefaultTableCreationSuffix accessors to allow setting a default in native EclipseLink projects. SchemaManager will append the value from the project on the passed in session when creating all tables. org.eclipse.persistence.tools.schemaframework.TableDefinition and org.eclipse.persistence.internal.helper.DatabaseTable both will have set/getCreationSuffix methods to allow specifying a string to be appended to the create table statement. Creation suffix strings on the TableDefinition/DatabaseTable will be applied before the default string at the project level.

JPA accessibility: eclipselink.ddl.default-table-suffix property added for persistence unit properties corresponding to the project's DefaultTableCreationSuffix

in EclipseLink-orm.xml, everywhere a table can be specified, the table definition will be expanded to include a create-suffix attribute that will be applied to resulting table's CreationSuffix In annotations, because annotations cannot be overriden, a new ELTable annotation will be added with a name and creationSuffix. This new annotation can be added to anywhere that an annotation exists, and will be used to merge into the created table data. This allows it to be expanded upon in the future (suchas if a deletion suffix or other type properties need to be added) Annotation/XML processing rules will remain the same, such that the same mapping defined in both xml and through annotations, the values specified in XML trump the annotation values.

XML tags that need to be expanded upon to include creation-suffix consist of table, secondary-table, JoinTable join-table, collection-table and table-generator. Annotation processing that currently allows for similar tags will need to be expanded to also factor in the ELTable annotation and merge into the table. For instance:

@Entity
@Table(name="DDL_EMPLOYEE")
@ELTable(name="DDL_EMPLOYEE" creationSuffix=" engine=InnoDB")
public class Employee {
    @Id
    private int id;
}

will result in the creation statement:

  CREATE TABLE DDL_EMPLOYEE (ID INTEGER) engine=InnoDB

Testing

A new persistence unit will be need to be added as well as classes to test the new annotation processing, defaults and extended xml tags. Because the ddl generation is very database specific, testing will involve generating the DDL creation file and reading it in to verify create table strings have suffixes appended appropriately.

Documentation

Should be documented under extended annotations, and schema generation.

Open Issues

  • Naming
  • Testing and where it should go

Back to the top