|
From: <hib...@li...> - 2006-06-02 18:07:14
|
Author: epbernard
Date: 2006-06-02 14:07:08 -0400 (Fri, 02 Jun 2006)
New Revision: 9979
Added:
trunk/Hibernate3/src/org/hibernate/QueryParameterException.java
Modified:
trunk/Hibernate3/src/org/hibernate/engine/query/ParameterMetadata.java
trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/QueryImpl.java
Log:
EJB-190 catch QueryParameterException and raise an IAE
Added: trunk/Hibernate3/src/org/hibernate/QueryParameterException.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/QueryParameterException.java 2006-06-02 16:28:06 UTC (rev 9978)
+++ trunk/Hibernate3/src/org/hibernate/QueryParameterException.java 2006-06-02 18:07:08 UTC (rev 9979)
@@ -0,0 +1,26 @@
+//$Id: $
+package org.hibernate;
+
+/**
+ * Parameter invalid or not found in the query
+ *
+ * @author Emmanuel Bernard
+ */
+public class QueryParameterException extends QueryException {
+
+ public QueryParameterException(Exception e) {
+ super( e );
+ }
+
+ public QueryParameterException(String message) {
+ super( message );
+ }
+
+ public QueryParameterException(String message, Throwable e) {
+ super( message, e );
+ }
+
+ public QueryParameterException(String message, String queryString) {
+ super( message, queryString );
+ }
+}
Modified: trunk/Hibernate3/src/org/hibernate/engine/query/ParameterMetadata.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/engine/query/ParameterMetadata.java 2006-06-02 16:28:06 UTC (rev 9978)
+++ trunk/Hibernate3/src/org/hibernate/engine/query/ParameterMetadata.java 2006-06-02 18:07:08 UTC (rev 9979)
@@ -1,13 +1,13 @@
package org.hibernate.engine.query;
-import org.hibernate.type.Type;
-import org.hibernate.HibernateException;
-
import java.io.Serializable;
+import java.util.HashMap;
import java.util.Map;
import java.util.Set;
-import java.util.HashMap;
+import org.hibernate.QueryParameterException;
+import org.hibernate.type.Type;
+
/**
* Encapsulates metadata about parameters encountered within a query.
*
@@ -72,7 +72,7 @@
public NamedParameterDescriptor getNamedParameterDescriptor(String name) {
NamedParameterDescriptor meta = ( NamedParameterDescriptor ) namedDescriptorMap.get( name );
if ( meta == null ) {
- throw new HibernateException( "could not locate named parameter [" + name + "]" );
+ throw new QueryParameterException( "could not locate named parameter [" + name + "]" );
}
return meta;
}
Modified: trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/QueryImpl.java
===================================================================
--- trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/QueryImpl.java 2006-06-02 16:28:06 UTC (rev 9978)
+++ trunk/HibernateExt/ejb/src/java/org/hibernate/ejb/QueryImpl.java 2006-06-02 18:07:08 UTC (rev 9979)
@@ -16,6 +16,7 @@
import org.hibernate.FlushMode;
import org.hibernate.HibernateException;
import org.hibernate.SQLQuery;
+import org.hibernate.QueryParameterException;
/**
* @author <a href="mailto:ga...@hi...">Gavin King</a>
@@ -46,6 +47,10 @@
em.throwPersistenceException( he );
return 0;
}
+ catch( ClassCastException cce ) {
+ //TODO fix that when the TypeMismatchException is used by the core
+ throw new IllegalArgumentException(cce);
+ }
}
public List getResultList() {
@@ -56,6 +61,10 @@
em.throwPersistenceException( he );
return null;
}
+ catch( ClassCastException cce ) {
+ //TODO fix that when the TypeMismatchException is used by the core
+ throw new IllegalArgumentException(cce);
+ }
}
public Object getSingleResult() {
@@ -72,6 +81,10 @@
em.throwPersistenceException( he );
return null;
}
+ catch( ClassCastException cce ) {
+ //TODO fix that when the TypeMismatchException is used by the core
+ throw new IllegalArgumentException(cce);
+ }
}
public Query setMaxResults(int maxResult) {
@@ -145,6 +158,9 @@
}
return this;
}
+ catch (QueryParameterException e) {
+ throw new IllegalArgumentException( e );
+ }
catch (HibernateException he) {
em.throwPersistenceException( he );
return null;
@@ -164,6 +180,9 @@
}
return this;
}
+ catch (QueryParameterException e) {
+ throw new IllegalArgumentException( e );
+ }
catch (HibernateException he) {
em.throwPersistenceException( he );
return null;
@@ -183,6 +202,9 @@
}
return this;
}
+ catch (QueryParameterException e) {
+ throw new IllegalArgumentException( e );
+ }
catch (HibernateException he) {
em.throwPersistenceException( he );
return null;
@@ -199,6 +221,9 @@
}
return this;
}
+ catch (QueryParameterException e) {
+ throw new IllegalArgumentException( e );
+ }
catch (HibernateException he) {
em.throwPersistenceException( he );
return null;
@@ -228,6 +253,9 @@
}
return this;
}
+ catch (QueryParameterException e) {
+ throw new IllegalArgumentException( e );
+ }
catch (HibernateException he) {
em.throwPersistenceException( he );
return null;
@@ -253,6 +281,9 @@
}
return this;
}
+ catch (QueryParameterException e) {
+ throw new IllegalArgumentException( e );
+ }
catch (HibernateException he) {
em.throwPersistenceException( he );
return null;
|