{
if (classNames != null && classNames.size() > 0)
{
// Create a PersistenceManager for this store and create the tables
ObjectManager om = ((AbstractPersistenceManager) pmf.getPersistenceManager()).getObjectManager();
StoreManager storeMgr = om.getStoreManager();
FileWriter ddlFileWriter = null;
if (ddlFilename != null)
{
// Open the DDL file for writing
File ddlFile = StringUtils.getFileForFilename(ddlFilename);
if (ddlFile.exists())
{
// Delete existing file
ddlFile.delete();
}
if (ddlFile.getParentFile() != null && !ddlFile.getParentFile().exists())
{
// Make sure the directory exists
ddlFile.getParentFile().mkdirs();
}
ddlFile.createNewFile();
ddlFileWriter = new FileWriter(ddlFile);
SimpleDateFormat fmt = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
ddlFileWriter.write("------------------------------------------------------------------\n");
ddlFileWriter.write("-- JPOX SchemaTool " +
"(version " + ObjectManagerFactoryImpl.getVersionNumber() + ")" +
" ran at " + fmt.format(new java.util.Date()) +
"\n");
ddlFileWriter.write("------------------------------------------------------------------\n");
if (completeDdl)
{
ddlFileWriter.write("-- Complete schema required for the following classes:-\n");
}
else
{
ddlFileWriter.write("-- Schema diff for " + pmf.getConnectionURL()+ " and the following classes:-\n");
}
Iterator classNameIter = classNames.iterator();
while (classNameIter.hasNext())
{
ddlFileWriter.write("-- " + classNameIter.next() + "\n");
}
ddlFileWriter.write("--\n");
}
try
{
String[] classNameArray = (String[])classNames.toArray(new String[classNames.size()]);
storeMgr.addClasses(classNameArray, om.getClassLoaderResolver(), ddlFileWriter, completeDdl);
}
finally
{
if (ddlFileWriter != null)
{