Author: dgeraskov
Date: 2010-12-15 08:08:33 -0500 (Wed, 15 Dec 2010)
New Revision: 27502
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConfigurationFactory.java
Log:
https://issues.jboss.org/browse/JBIDE-7884
Logic changed back
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConfigurationFactory.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConfigurationFactory.java 2010-12-15
11:06:55 UTC (rev 27501)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConfigurationFactory.java 2010-12-15
13:08:33 UTC (rev 27502)
@@ -156,15 +156,10 @@
// TODO: delegate to some extension point
private Configuration buildConfiguration(Properties properties, boolean includeMappings)
{
Configuration localCfg = null;
- Properties overrides = new Properties();
- overrides.put("javax.persistence.validation.mode", "none");
//$NON-NLS-1$//$NON-NLS-2$
- if (properties != null) {
- overrides.putAll(properties);
- }
if (prefs.getConfigurationMode().equals(ConfigurationMode.ANNOTATIONS)) {
try {
localCfg = buildAnnotationConfiguration();
- localCfg = configureStandardConfiguration(includeMappings, localCfg, overrides);
+ localCfg = configureStandardConfiguration(includeMappings, localCfg, properties);
} catch (HibernateConsoleRuntimeException he) {
throw he;
} catch (Exception e) {
@@ -175,7 +170,7 @@
} else if (prefs.getConfigurationMode().equals(ConfigurationMode.JPA)) {
try {
localCfg = buildJPAConfiguration(getPreferences().getPersistenceUnitName(),
- overrides, prefs.getEntityResolverName(), includeMappings);
+ properties, prefs.getEntityResolverName(), includeMappings);
} catch (HibernateConsoleRuntimeException he) {
throw he;
} catch (Exception e) {
@@ -184,7 +179,7 @@
}
} else {
localCfg = new Configuration();
- localCfg = configureStandardConfiguration(includeMappings, localCfg, overrides);
+ localCfg = configureStandardConfiguration(includeMappings, localCfg, properties);
}
return localCfg;
}
@@ -205,8 +200,9 @@
}
try {
Map<Object, Object> overrides = new HashMap<Object, Object>();
- overrides.putAll(properties);
-
+ if (properties != null) {
+ overrides.putAll(properties);
+ }
if (StringHelper.isNotEmpty(prefs.getNamingStrategy())) {
overrides.put("hibernate.ejb.naming_strategy", prefs.getNamingStrategy());
//$NON-NLS-1$
}
@@ -216,6 +212,9 @@
if (!includeMappings) {
overrides.put("hibernate.archive.autodetection", "none");
//$NON-NLS-1$//$NON-NLS-2$
}
+ if (StringHelper.isEmpty((String)
overrides.get("javax.persistence.validation.mode"))) {//$NON-NLS-1$
+ overrides.put("javax.persistence.validation.mode", "none");
//$NON-NLS-1$//$NON-NLS-2$
+ }
Class<?> clazz = ReflectHelper.classForName(
"org.hibernate.ejb.Ejb3Configuration", ConsoleConfiguration.class);
//$NON-NLS-1$
Object ejb3cfg = clazz.newInstance();
@@ -248,8 +247,9 @@
private Configuration configureStandardConfiguration(final boolean includeMappings,
Configuration localCfg, Properties properties) {
- localCfg = localCfg.setProperties(properties);
-
+ if (properties != null) {
+ localCfg = localCfg.setProperties(properties);
+ }
EntityResolver entityResolver = XMLHelper.DEFAULT_DTD_RESOLVER;
if (StringHelper.isNotEmpty(prefs.getEntityResolverName())) {
try {
@@ -279,6 +279,9 @@
if (StringHelper.isNotEmpty(prefs.getDialectName())) {
localCfg.setProperty(Environment.DIALECT, prefs.getDialectName());
}
+ if
(StringHelper.isEmpty(localCfg.getProperty("javax.persistence.validation.mode")))
{//$NON-NLS-1$
+ localCfg.setProperty("javax.persistence.validation.mode", "none");
//$NON-NLS-1$//$NON-NLS-2$
+ }
return localCfg;
}