Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

EclipseLink/DesignDocs/214519

Design Specification: Appending strings to CREATE TABLE statements

Enhancement Request bug 214519

Feedback

Document History

Date Author Version Description & Notes
Chris Delahunt 0.2 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 eclipselink-orm.xml that apply to individual tables.

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

Design

Native API

  • 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 PU Property

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

<property name="eclipselink.ddl-generation.table-creation-suffix" value="engine=InnoDB" />

XML (eclipselink-orm.xml)

In EclipseLink-orm.xml, everywhere a table can be specified, the table definition will be expanded to include a creation-suffix attribute that will be applied to resulting table's CreationSuffix 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.

Annotations

There will be no support for adding strings to DDL table creation statements through custom annotations. Users should find setting at the context level through a persistence property or if required at the table level, using an eclipselink-orm.xml sufficient. This can be revisited if there is demand in the future, but does not seem to warrant adding an additional table annotation at this time.

Example

An EclipseLink-orm.xml file with the following tag (assuming it has an id annotated):

<entity class="Comment">
  <table name="DDL_COMMENT" creation-suffix="COMMENT='User Comment Table'"/>
</entity>

will result in the creation statement:

  CREATE TABLE DDL_COMMENT (ID INTEGER) COMMENT='User Comment Table'

Coupled with persistence property:

<property name="eclipselink.ddl.default-table-suffix" value="engine=InnoDB"/>

will result in the creation statement:

  CREATE TABLE DDL_COMMENT (ID INTEGER) COMMENT='User Comment Table' 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

Back to the top