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.
Difference between revisions of "EclipseLink/UserGuide/JPA/Advanced JPA Development/Schema Generation/Appending strings to CREATE TABLE statements"
m |
|||
(11 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | ---- | ||
+ | |||
+ | |||
+ | '''[[Image:Elug_draft_icon.png|Warning]] This page is now obsolete. ''' | ||
+ | |||
+ | For current information, please see "ddl-generation" in the ''Java Persistence API (JPA) Extensions Reference for EclipseLink'': | ||
+ | http://eclipse.org/eclipselink/documentation/latest/jpa/extensions/p_ddl_generation.htm | ||
+ | |||
+ | |||
+ | ---- | ||
+ | |||
+ | |||
+ | |||
+ | |||
{{EclipseLink_UserGuide | {{EclipseLink_UserGuide | ||
|info=y | |info=y | ||
Line 4: | Line 18: | ||
|eclipselink=y | |eclipselink=y | ||
|eclipselinktype=JPA | |eclipselinktype=JPA | ||
+ | |api=y | ||
+ | |apis= | ||
+ | *[http://www.eclipse.org/eclipselink/api/latest/org/eclipse/persistence/sessions/Project Project] | ||
+ | *[http://www.eclipse.org/eclipselink/api/latest/org/eclipse/persistence/tools/schemaframework/TableDefinition TableDefinition] | ||
+ | |||
}} | }} | ||
= Appending Strings to CREATE TABLE Statements = | = 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 <tt>engine=InnoDB</tt> 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 <tt>eclipselink-orm.xml</tt> to apply to individual tables. | ||
+ | |||
+ | == Persistence Unit Properties == | ||
+ | |||
+ | For a persistence unit, use the property <tt>eclipselink.ddl-generation.table-creation-suffix</tt> to append a string to all tables defined in the persistence unit. | ||
+ | |||
+ | == eclipselink-orm.xml == | ||
+ | |||
+ | For individual tables, use the <tt>creation-suffix</tt> attribute for table creation elements in <tt>eclipelink-orm.xml</tt>. This following elements can take this attribute: | ||
+ | |||
+ | * table | ||
+ | * secondary-table | ||
+ | * join-table | ||
+ | * collection-table | ||
+ | * table-generator | ||
+ | |||
+ | == Annotations == | ||
+ | |||
+ | This feature is not currently supported through annotations. | ||
− | |||
===Example=== | ===Example=== | ||
Assuming it has an ID annotated, an <tt>eclipselink-orm.xml</tt> file containing... | Assuming it has an ID annotated, an <tt>eclipselink-orm.xml</tt> file containing... | ||
Line 33: | Line 74: | ||
|previous =[[EclipseLink/UserGuide/JPA/Advanced_JPA_Development/Schema_Generation/CascadeOnDelete|@CascadeOnDelete]] | |previous =[[EclipseLink/UserGuide/JPA/Advanced_JPA_Development/Schema_Generation/CascadeOnDelete|@CascadeOnDelete]] | ||
|up =[[EclipseLink/UserGuide/JPA/Advanced_JPA_Development/Schema_Generation|Schema Generation]] | |up =[[EclipseLink/UserGuide/JPA/Advanced_JPA_Development/Schema_Generation|Schema Generation]] | ||
− | |next =[[EclipseLink/UserGuide/JPA/Advanced_JPA_Development/ | + | |next=[[EclipseLink/UserGuide/JPA/Advanced_JPA_Development/Data Partitioning|Data Partitioning]] |
|version=2.2.0 DRAFT}} | |version=2.2.0 DRAFT}} |
Latest revision as of 07:31, 17 April 2013
For current information, please see "ddl-generation" in the Java Persistence API (JPA) Extensions Reference for EclipseLink: http://eclipse.org/eclipselink/documentation/latest/jpa/extensions/p_ddl_generation.htm
EclipseLink JPA
EclipseLink | |
Website | |
Download | |
Community | |
Mailing List • Forums • IRC • mattermost | |
Issues | |
Open • Help Wanted • Bug Day | |
Contribute | |
Browse Source |
Key API
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
For a persistence unit, use the property eclipselink.ddl-generation.table-creation-suffix to append a string to all tables defined in the persistence unit.
eclipselink-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
- 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