List of usage examples for org.hibernate.tool.hbm2ddl SchemaExport drop
public void drop(EnumSet<TargetType> targetTypes, Metadata metadata)
From source file:org.jbpm.ant.JbpmSchemaTask.java
License:Open Source License
public void execute() throws BuildException { if (actions == null) { // default action is create actions = "create"; }//from w w w. j a v a 2 s . com // we need a configuration Configuration configuration = null; // if there is no jbpm nor hibernate configuration specified if ((jbpmCfg == null) && (hibernateCfg == null)) { // search for the default jbpm.cfg.xml URL defaultJbpmCfgUrl = getClass().getClassLoader().getResource("jbpm.cfg.xml"); if (defaultJbpmCfgUrl != null) { jbpmCfg = "jbpm.cfg.xml"; // if still not found, search for the default hibernate.cfg.xml } else { URL defaultHibernateCfgUrl = getClass().getClassLoader().getResource("hibernate.cfg.xml"); if (defaultHibernateCfgUrl != null) { hibernateCfg = "hibernate.cfg.xml"; } } } // first see if the jbpm cfg is specified cause that implies a hibernate configuration if (jbpmCfg != null) { log("using jbpm configuration " + jbpmCfg); JbpmConfiguration jbpmConfiguration = AntHelper.getJbpmConfiguration(jbpmCfg); JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext(); try { DbPersistenceServiceFactory dbPersistenceServiceFactory = (DbPersistenceServiceFactory) jbpmConfiguration .getServiceFactory(Services.SERVICENAME_PERSISTENCE); configuration = dbPersistenceServiceFactory.getConfiguration(); } finally { jbpmContext.close(); } // if there is no jbpm.cfg.xml specified, check if there is a hibernate.cfg.xml specified } else if (hibernateCfg != null) { log("using hibernate configuration " + hibernateCfg); configuration = AntHelper.getConfiguration(hibernateCfg, hibernateProperties); // no hibernate configuration specified } else { throw new BuildException("couldn't create schema. no jbpm nor hibernate configuration specified."); } JbpmSchema jbpmSchema = new JbpmSchema(configuration); SchemaExport schemaExport = new SchemaExport(configuration); if (output != null) schemaExport.setOutputFile(output); if (delimiter != null) schemaExport.setDelimiter(delimiter); StringTokenizer tokenizer = new StringTokenizer(actions, ","); while (tokenizer.hasMoreTokens()) { String action = tokenizer.nextToken(); if ("drop".equalsIgnoreCase(action)) { schemaExport.drop(!quiet, !text); } else if ("create".equalsIgnoreCase(action)) { schemaExport.create(!quiet, !text); } else if ("clean".equalsIgnoreCase(action)) { jbpmSchema.cleanSchema(); } } }
From source file:org.ow2.bonita.util.DbTool.java
License:Open Source License
public static void dropDb(final String domain, final String configurationName) throws Exception { final EventExecutor eventExecutor = GlobalEnvironmentFactory .getEnvironmentFactory(BonitaConstants.DEFAULT_DOMAIN).get(EventExecutor.class); eventExecutor.stop();//from ww w.j ava 2 s. c o m final Configuration configuration = getConfiguration(domain, configurationName); final SchemaExport schemaExport = getSchemaExport(configuration); schemaExport.drop(false, true); final String indexesDirecoryPath = SearchUtil.getIndexesDirectoryPath(configuration); if (indexesDirecoryPath != null) { Misc.deleteDir(new File(indexesDirecoryPath)); } }
From source file:org.quackbot.dao.hibernate.GenericHbTest.java
License:Open Source License
@BeforeMethod public void setupSchema() { LocalSessionFactoryBean session = (LocalSessionFactoryBean) context.getBean("&sessionFactory"); SchemaExport export = new SchemaExport(session.getConfiguration()); export.drop(false, true); export.create(false, true);//from w w w .j av a2 s . co m }
From source file:org.quackbot.impl.HibernateMain.java
License:Open Source License
public void firstRun() { LocalSessionFactoryBean session = (LocalSessionFactoryBean) context.getBean("&sessionFactory"); SchemaExport export = new SchemaExport(session.getConfiguration()); export.drop(false, true); export.create(false, true);//w ww .j a va 2s . c o m //Start prompting the user for info System.out.println(); System.out.println("--------------------------"); System.out.println("- Quackbot Initial Setup -"); System.out.println("--------------------------"); System.out.println(); if (promptForInput("Do you wish to setup initial servers now? (Y/N)", false, "Y", "y", "N", "n") .equalsIgnoreCase("N")) { System.out.println("Skipping setup. Note: You will have to setup servers manually"); return; } while (true) { String server = promptForInput("What is the address of the server?", false); String portString = promptForInput("What is the server port? [Default: 6667]", true); String password = promptForInput("What is the server password? [Default: none]", true); boolean ssl = promptForInput("Does the server use SSL? [Default: no] (Y/N)", false, "Y", "y", "N", "n") .equalsIgnoreCase("Y"); //Store System.out.println("Storing server"); int port = Integer.parseInt(StringUtils.defaultIfBlank(portString, "6667")); //TODO } }
From source file:org.siberia.binding.impl.db.hibernate.HibernateBindingManager.java
License:Open Source License
/** drop all databases tables */ public void dropAllTables() { SchemaExport export = new SchemaExport(this.configuration); export.drop(false, true); List exceptions = export.getExceptions(); if (exceptions != null) { for (int i = 0; i < exceptions.size(); i++) { Object current = exceptions.get(i); if (current instanceof Throwable) { logger.error("exception occured while droping tables", (Throwable) current); }/*from w w w .j a v a 2s . co m*/ } } }