List of usage examples for org.hibernate.cfg Configuration getProperties
public Properties getProperties()
From source file:org.jboss.hibernate.jmx.Hibernate.java
License:Open Source License
private final Configuration buildConfiguration() throws Exception { log.debug("Building SessionFactory; " + this); Configuration cfg = new Configuration(); cfg.getProperties().clear(); // avoid reading hibernate.properties and Sys-props // Handle custom listeners.... ListenerInjector listenerInjector = generateListenerInjectorInstance(); if (listenerInjector != null) { listenerInjector.injectListeners(getServiceName(), cfg); }// www. j av a 2s .c o m // Handle config settings.... transferSettings(cfg.getProperties()); // Handle mappings.... handleMappings(cfg); // Handle interceptor.... Interceptor interceptorInstance = generateInterceptorInstance(); if (interceptorInstance != null) { cfg.setInterceptor(interceptorInstance); } return cfg; }
From source file:org.jboss.tools.hibernate3_5.console.ConsoleExtension3_5.java
License:Open Source License
private Configuration buildConfiguration(final ExporterAttributes attributes, ConsoleConfiguration cc, IWorkspaceRoot root) {/*from w w w . j av a 2 s . co m*/ final boolean reveng = attributes.isReverseEngineer(); final String reverseEngineeringStrategy = attributes.getRevengStrategy(); final boolean preferBasicCompositeids = attributes.isPreferBasicCompositeIds(); final IResource revengres = PathHelper.findMember(root, attributes.getRevengSettings()); if (reveng) { Configuration configuration = null; if (cc.hasConfiguration()) { configuration = cc.getConfiguration(); } else { configuration = cc.buildWith(null, false); } final JDBCMetaDataConfiguration cfg = new JDBCMetaDataConfiguration(); Properties properties = configuration.getProperties(); cfg.setProperties(properties); cc.buildWith(cfg, false); cfg.setPreferBasicCompositeIds(preferBasicCompositeids); cc.execute(new Command() { // need to execute in the consoleconfiguration to let it handle classpath stuff! public Object execute() { //todo: factor this setup of revengstrategy to core ReverseEngineeringStrategy res = new DefaultReverseEngineeringStrategy(); OverrideRepository repository = null; if (revengres != null) { File file = PathHelper.getLocation(revengres).toFile(); repository = new OverrideRepository(); repository.addFile(file); } if (repository != null) { res = repository.getReverseEngineeringStrategy(res); } if (reverseEngineeringStrategy != null && reverseEngineeringStrategy.trim().length() > 0) { res = loadreverseEngineeringStrategy(reverseEngineeringStrategy, res); } ReverseEngineeringSettings qqsettings = new ReverseEngineeringSettings(res) .setDefaultPackageName(attributes.getPackageName()) .setDetectManyToMany(attributes.detectManyToMany()) .setDetectOneToOne(attributes.detectOneToOne()) .setDetectOptimisticLock(attributes.detectOptimisticLock()); res.setSettings(qqsettings); cfg.setReverseEngineeringStrategy(res); cfg.readFromJDBC(); cfg.buildMappings(); return null; } }); return cfg; } else { cc.build(); cc.buildMappings(); return cc.getConfiguration(); } }
From source file:org.jboss.tools.hibernate3_6.ConfigurationFactory.java
License:Open Source License
private void changeDatasourceProperties(Configuration localCfg) { final Properties invokeProperties = localCfg.getProperties(); // set this property to null! if (invokeProperties.containsKey(Environment.DATASOURCE)) { invokeProperties.setProperty(Environment.TRANSACTION_MANAGER_STRATEGY, FAKE_TM_LOOKUP); invokeProperties.put(Environment.CONNECTION_PROVIDER, DriverManagerConnectionProvider.class.getName()); invokeProperties.remove(Environment.DATASOURCE); localCfg.setProperties(invokeProperties); }//from www . ja v a 2s . c o m }
From source file:org.jboss.tools.hibernate3_6.ConfigurationFactory.java
License:Open Source License
@SuppressWarnings("unused") private void autoConfigureDialect(Configuration localCfg) { if (localCfg.getProperty(Environment.DIALECT) == null) { String dialect = ConnectionProfileUtil.autoDetectDialect(localCfg.getProperties()); if (dialect != null) { localCfg.setProperty(Environment.DIALECT, dialect); }//from ww w .ja v a 2 s . c om } }
From source file:org.jboss.tools.hibernate3_6.console.ConsoleExtension3_6.java
License:Open Source License
private Configuration buildConfiguration(final ExporterAttributes attributes, HibernateExtension3_6 cc, IWorkspaceRoot root) {//from w ww . jav a 2s. com final boolean reveng = attributes.isReverseEngineer(); final String reverseEngineeringStrategy = attributes.getRevengStrategy(); final boolean preferBasicCompositeids = attributes.isPreferBasicCompositeIds(); final IResource revengres = PathHelper.findMember(root, attributes.getRevengSettings()); if (reveng) { Configuration configuration = null; if (cc.hasConfiguration()) { configuration = cc.getConfiguration(); } else { configuration = cc.buildWith(null, false); } final JDBCMetaDataConfiguration cfg = new JDBCMetaDataConfiguration(); Properties properties = configuration.getProperties(); cfg.setProperties(properties); cc.buildWith(cfg, false); cfg.setPreferBasicCompositeIds(preferBasicCompositeids); cc.execute(new Command() { // need to execute in the consoleconfiguration to let it handle classpath stuff! public Object execute() { //todo: factor this setup of revengstrategy to core ReverseEngineeringStrategy res = new DefaultReverseEngineeringStrategy(); OverrideRepository repository = null; if (revengres != null) { File file = PathHelper.getLocation(revengres).toFile(); repository = new OverrideRepository(); repository.addFile(file); } if (repository != null) { res = repository.getReverseEngineeringStrategy(res); } if (reverseEngineeringStrategy != null && reverseEngineeringStrategy.trim().length() > 0) { res = loadreverseEngineeringStrategy(reverseEngineeringStrategy, res); } ReverseEngineeringSettings qqsettings = new ReverseEngineeringSettings(res) .setDefaultPackageName(attributes.getPackageName()) .setDetectManyToMany(attributes.detectManyToMany()) //.setDetectOneToOne( attributes.detectOneToOne() ) .setDetectOptimisticLock(attributes.detectOptimisticLock()); res.setSettings(qqsettings); cfg.setReverseEngineeringStrategy(res); cfg.readFromJDBC(); cfg.buildMappings(); return null; } }); return cfg; } else { cc.build(); final Configuration configuration = cc.getConfiguration(); cc.execute(new Command() { public Object execute() { configuration.buildMappings(); return configuration; } }); return configuration; } }
From source file:org.jboss.tools.hibernate4_0.ConfigurationFactory.java
License:Open Source License
@SuppressWarnings("unused") private void autoConfigureDialect(Configuration localCfg, ServiceRegistry serviceRegistry) { if (localCfg.getProperty(Environment.DIALECT) == null) { String dialect = ConnectionProfileUtil.autoDetectDialect(localCfg.getProperties()); if (dialect != null) { localCfg.setProperty(Environment.DIALECT, dialect); }/*from w ww .ja va 2 s . c o m*/ } }
From source file:org.jboss.tools.hibernate4_0.ConfigurationFactory.java
License:Open Source License
private void changeDatasourceProperties(Configuration localCfg) { final Properties invokeProperties = localCfg.getProperties(); // set this property to null! if (invokeProperties.containsKey(Environment.DATASOURCE)) { invokeProperties.setProperty(Environment.TRANSACTION_MANAGER_STRATEGY, FAKE_TM_LOOKUP); //invokeProperties.put(Environment.CONNECTION_PROVIDER, DriverManagerConnectionProvider.class.getName()); invokeProperties.remove(Environment.DATASOURCE); localCfg.setProperties(invokeProperties); }//from w ww .j ava 2 s . com }
From source file:org.jboss.tools.hibernate4_0.console.ConsoleExtension4_0.java
License:Open Source License
private Configuration buildConfiguration(final ExporterAttributes attributes, HibernateExtension4_0 cc, IWorkspaceRoot root) {//from ww w .ja v a 2s .c om final boolean reveng = attributes.isReverseEngineer(); final String reverseEngineeringStrategy = attributes.getRevengStrategy(); final boolean preferBasicCompositeids = attributes.isPreferBasicCompositeIds(); final IResource revengres = PathHelper.findMember(root, attributes.getRevengSettings()); if (reveng) { Configuration configuration = null; if (cc.hasConfiguration()) { configuration = cc.getConfiguration(); } else { configuration = cc.buildWith(null, false); } final JDBCMetaDataConfiguration cfg = new JDBCMetaDataConfiguration(); Properties properties = configuration.getProperties(); cfg.setProperties(properties); cc.buildWith(cfg, false); cfg.setPreferBasicCompositeIds(preferBasicCompositeids); cc.execute(new Command() { // need to execute in the consoleconfiguration to let it handle classpath stuff! public Object execute() { //todo: factor this setup of revengstrategy to core ReverseEngineeringStrategy res = new DefaultReverseEngineeringStrategy(); OverrideRepository repository = null; if (revengres != null) { File file = PathHelper.getLocation(revengres).toFile(); repository = new OverrideRepository(); repository.addFile(file); } if (repository != null) { res = repository.getReverseEngineeringStrategy(res); } if (reverseEngineeringStrategy != null && reverseEngineeringStrategy.trim().length() > 0) { res = loadreverseEngineeringStrategy(reverseEngineeringStrategy, res); } ReverseEngineeringSettings qqsettings = new ReverseEngineeringSettings(res) .setDefaultPackageName(attributes.getPackageName()) .setDetectManyToMany(attributes.detectManyToMany()) //.setDetectOneToOne( attributes.detectOneToOne() ) .setDetectOptimisticLock(attributes.detectOptimisticLock()); res.setSettings(qqsettings); cfg.setReverseEngineeringStrategy(res); cfg.readFromJDBC(); cfg.buildMappings(); return null; } }); return cfg; } else { cc.build(); final Configuration configuration = cc.getConfiguration(); cc.execute(new Command() { public Object execute() { configuration.buildMappings(); return configuration; } }); return configuration; } }
From source file:org.jbpm.ant.HibernatePropertiesTask.java
License:Open Source License
public void execute() throws BuildException { log("loading hibernate properties from " + config); Configuration configuration = AntHelper.getConfiguration(config, null); Properties properties = configuration.getProperties(); if (properties.isEmpty()) return;// w w w. j a va 2 s.c om StringBuffer nameBuf = new StringBuffer(prefix); int prefixLength = prefix.length(); Project project = getProject(); for (Iterator i = properties.entrySet().iterator(); i.hasNext();) { Map.Entry property = (Entry) i.next(); String name = (String) property.getKey(); if (include(name) && !exclude(name)) { name = nameBuf.append(name).toString(); String value = (String) property.getValue(); log("setting '" + name + "' to: " + value); project.setNewProperty(name, value); // drop key from prefix nameBuf.setLength(prefixLength); } } }
From source file:org.jbpm.db.JbpmSchema.java
License:Open Source License
public JbpmSchema(Configuration configuration) { this.configuration = configuration; this.properties = configuration.getProperties(); this.dialect = Dialect.getDialect(properties); try {/* w w w. ja v a 2s .c om*/ // get the mapping field via reflection :-( Field mappingField = Configuration.class.getDeclaredField("mapping"); mappingField.setAccessible(true); this.mapping = (Mapping) mappingField.get(configuration); } catch (Exception e) { throw new JbpmException("couldn't get the hibernate mapping", e); } }