Hi,

I'm typing this while offline, so don't have access to the OpenJPA docs
URL, so can't include any links. Much of this is discussed in the
documentation, however.

> be nice to add java2db support for OpenJPA as well, and I'm 
> wondering if we need 
> to do anything special, or it'll all work just by itself?

OpenJPA does already have features that generally do what you're
mentioning.

> 1. Which API would trigger the process, assuming the correct 
> values are 
> specified in the persistence.xml file? Is it:
> a) <provider>.createContainerEntityManagerFactory(...)? or
> b) the 1st call to emf.createEntityManager() in this VM?
> c) something else?

When using the openjpa.jdbc.SynchronizeMappings property in the
persistence.xml file, I believe that it's the first call to
emf.createEntityManager().  You can also directly interact with the
MappingTool and SchemaTool programmatically.

> 2. How would a user drop the tables in such environment?

The MappingTool and SchemaTool provide table drop capabilities. However,
why do you want to drop the tables in such an environment? Typically,
I've found that what people want is to clean out their tables so that at
the beginning of a test run, they're working with empty tables. OpenJPA
supports an option to automatically synchronize the database tables with
what's in the current mappings, and then issue a DELETE statement
against each table. In a test environment, this is often much faster
than doing schema mutation. Additionally, it is more common to have
permission to delete all rows in the database than to do schema
manipulation. See https://issues.apache.org/jira/browse/OPENJPA-94 for
details about how to do this.

> 3. If the answer to either 1a or 1b is yes, how does the code 
> distinguish 
> between the server startup time and the application being 
> loaded for the 1st time?

It doesn't.

> 4. Is there a mode that allows creating a file with the jdbc 
> statements to 
> create or drop the tables and constraints?

Yes.

-Patrick

-- 
Patrick Linskey
BEA Systems, Inc. 

_______________________________________________________________________
Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it. 

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, March 15, 2007 5:01 PM
> To: open-jpa-dev@incubator.apache.org
> Subject: Using DDL generation in a Java EE environment?
> 
> Hi,
> 
> I am part of the GlassFish persistence team and was wondering 
> how does OpenJPA 
> support JPA auto DDL generation (we call it "java2db") in a 
> Java EE application 
> server.
> 
> Our application server supports java2db via creating two sets 
> of files for each 
> PU: a ...dropDDL.jdbc and a ...createDDL.jdbc file on deploy 
> (i.e. before the 
> application  is actually loaded into the container) and then 
> executing 'create' 
> file as the last step in deployment, and 'drop' file on 
> undeploy or the 1st step 
> in redeploy. This allows us to drop tables created by the 
> previous deploy operation.
> 
> This approach is done for both, the CMP and the default JPA 
> provider. It would 
> be nice to add java2db support for OpenJPA as well, and I'm 
> wondering if we need 
> to do anything special, or it'll all work just by itself?
> 
> Here are my 1st set of questions:
> 
> 1. Which API would trigger the process, assuming the correct 
> values are 
> specified in the persistence.xml file? Is it:
> a) <provider>.createContainerEntityManagerFactory(...)? or
> b) the 1st call to emf.createEntityManager() in this VM?
> c) something else?
> 
> 2. How would a user drop the tables in such environment?
> 
> 3. If the answer to either 1a or 1b is yes, how does the code 
> distinguish 
> between the server startup time and the application being 
> loaded for the 1st time?
> 
> 4. Is there a mode that allows creating a file with the jdbc 
> statements to 
> create or drop the tables and constraints?
> 
> thank you,
> -marina
> 
> 

Reply via email to