use of org.hibernate.service.internal.StandardServiceRegistryImpl in project jbosstools-hibernate by jbosstools.
the class SchemaExport method createServiceRegistry.
private static StandardServiceRegistryImpl createServiceRegistry(Properties properties) {
Environment.verifyProperties(properties);
ConfigurationHelper.resolvePlaceHolders(properties);
return (StandardServiceRegistryImpl) new ServiceRegistryBuilder().applySettings(properties).buildServiceRegistry();
}
use of org.hibernate.service.internal.StandardServiceRegistryImpl in project jbosstools-hibernate by jbosstools.
the class SchemaExport method main.
public static void main(String[] args) {
try {
Configuration cfg = new Configuration();
boolean script = true;
boolean drop = false;
boolean create = false;
boolean halt = false;
boolean export = true;
String outFile = null;
String importFile = DEFAULT_IMPORT_FILE;
String propFile = null;
boolean format = false;
String delim = null;
for (int i = 0; i < args.length; i++) {
if (args[i].startsWith("--")) {
if (args[i].equals("--quiet")) {
script = false;
} else if (args[i].equals("--drop")) {
drop = true;
} else if (args[i].equals("--create")) {
create = true;
} else if (args[i].equals("--haltonerror")) {
halt = true;
} else if (args[i].equals("--text")) {
export = false;
} else if (args[i].startsWith("--output=")) {
outFile = args[i].substring(9);
} else if (args[i].startsWith("--import=")) {
importFile = args[i].substring(9);
} else if (args[i].startsWith("--properties=")) {
propFile = args[i].substring(13);
} else if (args[i].equals("--format")) {
format = true;
} else if (args[i].startsWith("--delimiter=")) {
delim = args[i].substring(12);
} else if (args[i].startsWith("--config=")) {
cfg.configure(args[i].substring(9));
} else if (args[i].startsWith("--naming=")) {
cfg.setNamingStrategy((NamingStrategy) ReflectHelper.classForName(args[i].substring(9)).newInstance());
}
} else {
String filename = args[i];
if (filename.endsWith(".jar")) {
cfg.addJar(new File(filename));
} else {
cfg.addFile(filename);
}
}
}
if (propFile != null) {
Properties props = new Properties();
props.putAll(cfg.getProperties());
props.load(new FileInputStream(propFile));
cfg.setProperties(props);
}
if (importFile != null) {
cfg.setProperty(AvailableSettings.HBM2DDL_IMPORT_FILES, importFile);
}
StandardServiceRegistryImpl serviceRegistry = createServiceRegistry(cfg.getProperties());
try {
SchemaExport se = new SchemaExport(serviceRegistry, cfg).setHaltOnError(halt).setOutputFile(outFile).setDelimiter(delim).setImportSqlCommandExtractor(serviceRegistry.getService(ImportSqlCommandExtractor.class));
if (format) {
se.setFormat(true);
}
se.execute(script, export, drop, create);
} finally {
serviceRegistry.destroy();
}
} catch (Exception e) {
LOG.unableToCreateSchema(e);
e.printStackTrace();
}
}
Aggregations