Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Dynamic DDL_GENERATION and execution at database

Hi Markus,

The EclipseLink DDL generation feature does not do any checks to see if the tables exist. It simply tries to execute the SQL and reports any exceptions to you.

  If the tables potentially already exist, you can do one of the following:

- Set the eclipselink.ddl-generation to drop-and-create-tables. This will execute drop statements before the create statements
- Write some logic of your own that makes use of the following:
- The eclipselink.ddl-generation property can be provided in the map of arguments to createEntityManagerFactory(String, Map) and therefore you can decide (potentially based on an exception) whether to use it. - EclipseLink can be instructed to produce text files with the SQL instead. These files can then be used by your application. To do that, use the eclipselink.ddl-generation.output-mode property and set it to "sql-script" and set eclipselink.create-ddl-jdbc-file-name and eclipselink.drop-ddl-jdbc-file-name to point to the location the files should be generated to.

-Tom

Markus Kolb wrote:
Hi,

I've some questions to the automatic DDL generation and execution at database. As it seems the DDL statements are checked with database layout at first connection after application startup.
If the tables doesn't exist in DB they are created as it is supposed to be.
If the tables already exist and the application is restarted there is always an ugly exception message in eclipselink log that the tables already exist.
First I've thought it is possible to check the DB first with an SELECT.
On Exception I wanted to use another EntityManagerFactory, with enabled DDL_GENERATION property set, to create the tables. But then the DDL_GENERATION is not enabled during first connection to DB after application start and there won't be created any tables.

Do you know any solution for this?
Is this DDL_GENERATION limitation on _first_ connection like it ought to be, do I anything wrong or is it a bug?

Thanks
Markus
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top