[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [eclipselink-users] Dynamic DDL_GENERATION and execution at database
|
Thanks this stuff I've tried already. I think you didn't the point of my
problem. ;-)
But I've already found the solution. I can not create different
EntityManagerFactories with same persistence-unit and different
properties passed to Factory constructor.
As James Sutherland wrote an hour ago the Factory is "cached".
Maybe a singleton per persistence-unit?
So if you want to use n Factories concurrently you have also to use n
persistence-units.
Tom Ware wrote on 2009-05-11 21:10:
BTW: To get the 2nd EntityManagerFactory to create the tables, you will
have to call close() on the 1st one.
Tom Ware wrote:
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
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users