[GLASSFISH-20651] EclipseLink Generates DDL Statements Without Trailing Semicolon Created: 20/Jun/13  Updated: 03/Jul/14

Status: Open
Project: glassfish
Component/s: entity-persistence
Affects Version/s: 4.0_b89_RC5
Fix Version/s: None

Type: Bug Priority: Major
Reporter: abien Assignee: Mitesh Meswani
Resolution: Unresolved Votes: 2
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

All


Tags: eclipselink, fishcat, persistence

 Description   

EclipseLink generates DDL statements (CREATE TABLE, DROP Table etc.) without the trailing semicolon. The statements are so no directly usable in a CI enviromnent.

Expected:

CREATE TABLE SEQUENCE (SEQ_NAME VARCHAR(50) NOT NULL, SEQ_COUNT DECIMAL(15), PRIMARY KEY (SEQ_NAME));

is

CREATE TABLE SEQUENCE (SEQ_NAME VARCHAR(50) NOT NULL, SEQ_COUNT DECIMAL(15), PRIMARY KEY (SEQ_NAME))

Seems like all target databases are effected.



 Comments   
Comment by guypelletier [ 03/Jul/13 ]

EclipseLink currently does not generate platform dependent terminators in DDL generation. It does however have the capability to do so and it could be achieve through a new property setting.

Can you please enter an EclipseLink bug to include this functionality?

Comment by alexeev_net [ 06/Dec/13 ]

I traced the problem down to the field createSQLFiles in the class SchemaManager:

org.eclipse.persistence.tools.schemaframework.SchemaManager
 
  protected boolean createSQLFiles = true; //if true, schema writer will add terminator string.

In order to generate platform dependent terminators in DDL generation, this field shall be true. Unfortunately, EntityManagerFactoryProvider explicitly turns this flag to false:

org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider
 
  protected static void writeDDLsToFiles(SchemaManager mgr,  String appLocation, String createDDLJdbc, String dropDDLJdbc) {
    //..
    mgr.setCreateSQLFiles(false); // BUG!
    //..

As a result, every DDL statement in SQL-File is terminated with "\n" instead of platform dependent terminator.

To me it seems like there is a trivial bugfix for EntityManagerFactoryProvider, replacing mgr.setCreateSQLFiles(false) by mgr.setCreateSQLFiles(true).
I already tested it locally with EL 2.3.2 and EL 2.4.2.

Comment by Alessandro Brandimarti [ 03/Jul/14 ]

EclipseLink bug report:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=438871

Generated at Sat Jul 04 14:40:08 UTC 2015 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.