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

EclipseLink/UserGuide/JPA/Advanced JPA Development/Schema Generation/Appending strings to CREATE TABLE statements

< EclipseLink‎ | UserGuide‎ | JPA‎ | Advanced JPA Development‎ | Schema Generation
Revision as of 12:53, 1 March 2011 by James.sutherland.oracle.com (Talk | contribs) (Persistence Unit Properties and Session Properties)

EclipseLink JPA

Eclipselink-logo.gif
EclipseLink
Website
Download
Community
Mailing ListForumsIRCmattermost
Issues
OpenHelp WantedBug Day
Contribute
Browse Source


Appending Strings to CREATE TABLE Statements

You can append a string to the end of a CREATE TABLE statement when generating a DDL. This can be useful, for example, to create tables that are transactional, by appending engine=InnoDB to the end of the creation statement to specify that the MySQL InnoDB storage engine will be used.

Appending the string only affects the DDL generation. It does not affect any other runtime behavior.

You can specify strings using persistence unit properties or session properties to apply to every table in that context. Specify strings in eclipselink-orm.xml to apply to individual tables.

Persistence Unit Properties and Session Properties

For persistence units and sessions, use the property eclipselink.ddl-generation.table-creation-suffix to append a string to all tables defined in the persistence unit.

eclispelink-orm.xml

For individual tables, use the creation-suffix attribute for table creation elements in eclipelink-orm.xml. This following elements can take this attribute:

  • table
  • secondary-table
  • JoinTable
  • join-table
  • collection-table
  • table-generator

Annotations

This feature is not currently supported through annotations.

Example

Assuming it has an ID annotated, an eclipselink-orm.xml file containing...

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

...results in the following creation statement:

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

If it is coupled with the following persistence property...

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

it results in the following creation statement:

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

Eclipselink-logo.gif
Version: 2.2.0 DRAFT
Other versions...

Back to the top