Author: steve.ebersole(a)jboss.com
Date: 2006-11-17 17:15:05 -0500 (Fri, 17 Nov 2006)
New Revision: 10843
Modified:
branches/Branch_3_2/Hibernate3/src/org/hibernate/cfg/Environment.java
branches/Branch_3_2/Hibernate3/src/org/hibernate/cfg/Settings.java
branches/Branch_3_2/Hibernate3/src/org/hibernate/cfg/SettingsFactory.java
branches/Branch_3_2/Hibernate3/src/org/hibernate/impl/SessionFactoryImpl.java
Log:
HHH-2193 : flag to control named query checking
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/cfg/Environment.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/cfg/Environment.java 2006-11-17
18:38:15 UTC (rev 10842)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/cfg/Environment.java 2006-11-17
22:15:05 UTC (rev 10843)
@@ -414,12 +414,21 @@
* The classname of the HQL query parser factory
*/
public static final String QUERY_TRANSLATOR =
"hibernate.query.factory_class";
+
/**
* A comma-seperated list of token substitutions to use when translating a Hibernate
* query to SQL
*/
public static final String QUERY_SUBSTITUTIONS =
"hibernate.query.substitutions";
+
/**
+ * Should named queries be checked during startup (the default is enabled).
+ * <p/>
+ * Mainly intended for test environments.
+ */
+ public static final String QUERY_STARTUP_CHECKING =
"hibernate.query.startup_check";
+
+ /**
* Auto export/update schema using hbm2ddl tool. Valid values are
<tt>update</tt>,
* <tt>create</tt>, <tt>create-drop</tt> and
<tt>validate</tt>.
*/
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/cfg/Settings.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/cfg/Settings.java 2006-11-17 18:38:15
UTC (rev 10842)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/cfg/Settings.java 2006-11-17 22:15:05
UTC (rev 10843)
@@ -65,6 +65,7 @@
private boolean dataDefinitionImplicitCommit;
private boolean dataDefinitionInTransactionSupported;
private boolean strictJPAQLCompliance;
+ private boolean namedQueryStartupCheckingEnabled;
// private BytecodeProvider bytecodeProvider;
/**
@@ -247,7 +248,11 @@
return strictJPAQLCompliance;
}
+ public boolean isNamedQueryStartupCheckingEnabled() {
+ return namedQueryStartupCheckingEnabled;
+ }
+
// package protected setters ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void setDefaultSchemaName(String string) {
@@ -422,6 +427,9 @@
this.strictJPAQLCompliance = strictJPAQLCompliance;
}
+ void setNamedQueryStartupCheckingEnabled(boolean namedQueryStartupCheckingEnabled) {
+ this.namedQueryStartupCheckingEnabled = namedQueryStartupCheckingEnabled;
+ }
// public BytecodeProvider getBytecodeProvider() {
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/cfg/SettingsFactory.java
===================================================================
--- branches/Branch_3_2/Hibernate3/src/org/hibernate/cfg/SettingsFactory.java 2006-11-17
18:38:15 UTC (rev 10842)
+++ branches/Branch_3_2/Hibernate3/src/org/hibernate/cfg/SettingsFactory.java 2006-11-17
22:15:05 UTC (rev 10843)
@@ -296,6 +296,10 @@
log.info( "Default entity-mode: " + defaultEntityMode );
settings.setDefaultEntityMode( defaultEntityMode );
+ boolean namedQueryChecking = PropertiesHelper.getBoolean(
Environment.QUERY_STARTUP_CHECKING, properties, true );
+ log.info( "Named query checking : " + enabledDisabled( namedQueryChecking )
);
+ settings.setNamedQueryStartupCheckingEnabled( namedQueryChecking );
+
// String provider = properties.getProperty( Environment.BYTECODE_PROVIDER );
// log.info( "Bytecode provider name : " + provider );
// BytecodeProvider bytecodeProvider = buildBytecodeProvider( provider );
Modified: branches/Branch_3_2/Hibernate3/src/org/hibernate/impl/SessionFactoryImpl.java
===================================================================
---
branches/Branch_3_2/Hibernate3/src/org/hibernate/impl/SessionFactoryImpl.java 2006-11-17
18:38:15 UTC (rev 10842)
+++
branches/Branch_3_2/Hibernate3/src/org/hibernate/impl/SessionFactoryImpl.java 2006-11-17
22:15:05 UTC (rev 10843)
@@ -348,20 +348,22 @@
}
//checking for named queries
- Map errors = checkNamedQueries();
- if ( !errors.isEmpty() ) {
- Set keys = errors.keySet();
- StringBuffer failingQueries = new StringBuffer( "Errors in named queries: "
);
- for ( Iterator iterator = keys.iterator() ; iterator.hasNext() ; ) {
- String queryName = ( String ) iterator.next();
- HibernateException e = ( HibernateException ) errors.get( queryName );
- failingQueries.append( queryName );
- if ( iterator.hasNext() ) {
- failingQueries.append( ", " );
+ if ( settings.isNamedQueryStartupCheckingEnabled() ) {
+ Map errors = checkNamedQueries();
+ if ( !errors.isEmpty() ) {
+ Set keys = errors.keySet();
+ StringBuffer failingQueries = new StringBuffer( "Errors in named queries: "
);
+ for ( Iterator iterator = keys.iterator() ; iterator.hasNext() ; ) {
+ String queryName = ( String ) iterator.next();
+ HibernateException e = ( HibernateException ) errors.get( queryName );
+ failingQueries.append( queryName );
+ if ( iterator.hasNext() ) {
+ failingQueries.append( ", " );
+ }
+ log.error( "Error in named query: " + queryName, e );
}
- log.error( "Error in named query: " + queryName, e );
+ throw new HibernateException( failingQueries.toString() );
}
- throw new HibernateException( failingQueries.toString() );
}
//stats
Show replies by date