I am having problems generating DDL using DALI and EclipseLink 1.2.
I have been setting the required XML properties
<property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
<property name="eclipselink.ddl-generation.output-mode" value="sql-script"/>
<property name="eclipselink.application-location" value="C:\Dev\Workspaces\..."/>
But when I run Generate Tables from Entities, Dali generates a login.properties file with eclipselink.ddl-generation.output-mode set to database (not sql-script for some reason). No idea why it does this - I would have assumed it would just copy the value in the persistence.xml.
Searching the web suggests that EclipseLink requires a Java system property called INTERACT_WITH_DB to be set to false in order to generate the DDL scripts as opposed to actually connecting to the target database. Question is - how should I set this property?
I have tried starting Eclipse with -DINTERACT_WITH_DB=false but when I click 'Generate Tables from Entities" it still tries to connect to the database.
When using Dali to generate DDL, we actually ignore the settings in the persistence.xml so that the user doesn't have to concern themselves with these properties at design-time. Generally a user wouldn't have any DDL Gen properties in their persistence.xml and the tool would simply tell EclipseLink what to do. The downside is that we currently don't offer a way for the user to only generate the script. For this we should offer two paths for DDL generation, database and script, giving you a choice in a wizard. The other option would be to have generation properties override our passed in setting if they are present. I think the wizard offers a better user experience all around though.
I'll enter an enhancement request for this. In the meantime, the workaround is to generate the script outside of Dali, where simply setting the output mode to sql-script should be sufficient.
I think DDL generation is useful in terms of being able to (a) verify what the JPA provider "thinks" the schema will "look like" (helps with learning JPA), (b) and being given the basic DDL scripts to enhance with db specific clauses.
I do not "buy" the notion of directly creating the database (outside of JUnit tests with some in-memory db, or initial dev prototyping) as in reality people will want to customise the DDL with database specific features (eg, Oracle STORAGE clauses).
There seems to be a bug where if you reverse generate a table EclipseLink will mark the primary key column as "Unique", but when you forward generate it puts "UNIQUE" into the column definition ("UNIQUE NOT NULL") which Oracle errors on. If the id is assumed to be unique - then perhaps it is the reverse generation that is at fault.