persistence@glassfish.java.net

toplink.ddl-generation set to create-tables, but tables are also being dropped!

From: David Harrigan <dharrigan_at_gmail.com>
Date: Mon, 2 Apr 2007 10:28:36 +0100

Hi,

Currently tracking GF v2 on CVS (so I'm up past version 41).

I'm noticing something that I wouldn't expect, so I hope someone can
help. In my persistence.xml I have the following properties set:

<property name="toplink.logging.level" value="FINEST"/>
<property name="toplink.ddl-generation" value="create-tables"/>
<property name="toplink.application-location" value="/tmp"/>
<property name="toplink.create-ddl-jdbc-file-name" value="create.sql"/>
<property name="toplink.ddl-generation.output-mode" value="both"/>

Yet, I notice that toplink (or GF) is generating this file (apart from
the create.sql) :

mediaservice_mediaservice-ejb_mediaPu_dropDDL.jdbc

(mediaservice is the name of my ear/ejb) and contained within it are
various drop statements:

for example:

ALTER TABLE ITEM DROP CONSTRAINT FK_ITEM_PROVIDER_PROVIDERID
ALTER TABLE ITEM DROP CONSTRAINT FK_ITEM_TAGS_TAGSID
ALTER TABLE ITEM DROP CONSTRAINT ITEM_RESTRICTION_RESTRICTIONID
DROP TABLE TAGS
DROP TABLE ITEMITEM
...
...


and so on.

This is wiping out my test database each time. Obviously, I'm *very*
nervous that if in production I release my EAR our production
databases will be dropped....

According to the JPA spec, create-tables should:

create-tables - create DDL for non-existent tables; leave existing
tables unchanged

(this is from http://www.oracle.com/technology/products/ias/toplink/jpa/resources/toplink-jpa-extensions.html#Java2DBSchemaGen)

Is this a bug? Or something that I'm not quite understanding...

Thanks.

-=david=-

-- 
PGP Key Id: E2BE72FC
Public Key: http://www.harrigan.info/public.asc