[jbosstools-commits] JBoss Tools SVN: r43112 - trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Mon Aug 20 09:53:22 EDT 2012


Author: dgeraskov
Date: 2012-08-20 09:53:22 -0400 (Mon, 20 Aug 2012)
New Revision: 43112

Modified:
   trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaProject.java
   trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJptPlugin.java
Log:
https://issues.jboss.org/browse/JBIDE-9535

Update logic of getting default schema/catalog

Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaProject.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaProject.java	2012-08-20 13:38:35 UTC (rev 43111)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJpaProject.java	2012-08-20 13:53:22 UTC (rev 43112)
@@ -83,41 +83,75 @@
 		return null;
 	}
 	
+	/*
+	 * The sequence is(from biggest priority to lowest):
+	 * 1) Configuration.getProperty() (if cc.hasConfiguration())
+	 * 2) ConsoleConfiguration.getPreference().getProperty()-uses hibernate.properties
+	 * 3) JpaProject user overrides
+	 * 4) persistence.xml
+	 * 5) logic from superclass
+	 */
 	@Override
 	public String getDefaultSchema() {
+		String schema = null;
 		ConsoleConfiguration cc = getDefaultConsoleConfiguration();
 		if (cc != null){
+			if (cc.hasConfiguration()){//was not build yet
+				Configuration configuration = cc.getConfiguration();
+				if (configuration.getProperties().containsKey(Environment.DEFAULT_SCHEMA)){
+					schema = configuration.getProperty(Environment.DEFAULT_SCHEMA);
+				}
+			}
 			Properties properties = cc.getPreferences().getProperties();
 			if (properties != null && properties.containsKey(Environment.DEFAULT_SCHEMA)){
-				return properties.getProperty(Environment.DEFAULT_SCHEMA);
+				schema = properties.getProperty(Environment.DEFAULT_SCHEMA);
 			}
 		}
-		String schema = null;
-		BasicHibernateProperties prop = getBasicHibernateProperties();
-		if (getUserOverrideDefaultSchema() != null){
-			schema = getUserOverrideDefaultSchema();
-		} else if (prop != null && prop.getSchemaDefault() != null){
-			schema = prop.getSchemaDefault(); 
+		if (schema == null){
+			BasicHibernateProperties prop = getBasicHibernateProperties();
+			if (getUserOverrideDefaultSchema() != null){
+				schema = getUserOverrideDefaultSchema();
+			} else if (prop != null && prop.getSchemaDefault() != null){
+				schema = prop.getSchemaDefault(); 
+			}
 		}
 		
 		return schema != null ? schema : super.getDefaultSchema();
 	}
 	
+	/*
+	 * The sequence is(from biggest priority to lowest):
+	 * 1) Configuration.getProperty() (if cc.hasConfiguration())
+	 * 2) ConsoleConfiguration.getPreference().getProperty()-uses hibernate.properties
+	 * 3) JpaProject user overrides
+	 * 4) persistence.xml
+	 * 5) logic from superclass
+	 */
 	@Override
 	public String getDefaultCatalog() {
 		String catalog = null;
 		BasicHibernateProperties prop = getBasicHibernateProperties();
 		ConsoleConfiguration cc = getDefaultConsoleConfiguration();
 		if (cc != null){
+			if (cc.hasConfiguration()){//was not build yet
+				Configuration configuration = cc.getConfiguration();
+				if (configuration.getProperties().containsKey(Environment.DEFAULT_CATALOG)){
+					catalog = configuration.getProperty(Environment.DEFAULT_CATALOG);
+				}
+				
+			}
 			Properties properties = cc.getPreferences().getProperties();
 			if (properties != null && properties.containsKey(Environment.DEFAULT_CATALOG)){
-				return properties.getProperty(Environment.DEFAULT_CATALOG);
+				catalog = properties.getProperty(Environment.DEFAULT_CATALOG);
 			}
-		} else if (getUserOverrideDefaultCatalog() != null){
-			catalog = getUserOverrideDefaultCatalog();
-		} else if (prop != null && prop.getCatalogDefault() != null){
-			catalog = prop.getCatalogDefault(); 
 		}
+		if (catalog == null){
+			if (getUserOverrideDefaultCatalog() != null){
+				catalog = getUserOverrideDefaultCatalog();
+			} else if (prop != null && prop.getCatalogDefault() != null){
+				catalog = prop.getCatalogDefault(); 
+			}
+		}
 		
 		return catalog != null ? catalog : super.getDefaultCatalog();
 	}

Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJptPlugin.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJptPlugin.java	2012-08-20 13:38:35 UTC (rev 43111)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.core/src/org/jboss/tools/hibernate/jpt/core/internal/HibernateJptPlugin.java	2012-08-20 13:53:22 UTC (rev 43112)
@@ -122,8 +122,7 @@
 
 			@Override
 			public void configurationBuilt(ConsoleConfiguration ccfg) {
-				if (ccfg.getConfiguration() == null
-						|| ccfg.getConfiguration().getNamingStrategy() == null){
+				if (ccfg.getConfiguration() == null){
 					return;
 				}
 				revalidateProjects(ccfg);



More information about the jbosstools-commits mailing list