Author: steve.ebersole(a)jboss.com
Date: 2006-11-21 16:57:42 -0500 (Tue, 21 Nov 2006)
New Revision: 10856
Modified:
trunk/Hibernate3/src/org/hibernate/impl/AbstractQueryImpl.java
Log:
HHH-2250 : Query.setEntity() with null entity
Modified: trunk/Hibernate3/src/org/hibernate/impl/AbstractQueryImpl.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/impl/AbstractQueryImpl.java 2006-11-21 21:57:32 UTC
(rev 10855)
+++ trunk/Hibernate3/src/org/hibernate/impl/AbstractQueryImpl.java 2006-11-21 21:57:42 UTC
(rev 10856)
@@ -531,10 +531,17 @@
}
public Query setEntity(int position, Object val) {
- setParameter( position, val, Hibernate.entity( session.bestGuessEntityName(val) ) );
+ setParameter( position, val, Hibernate.entity( resolveEntityName( val ) ) );
return this;
}
+ private String resolveEntityName(Object val) {
+ if ( val == null ) {
+ throw new IllegalArgumentException( "entity for parameter binding cannot be
null" );
+ }
+ return session.bestGuessEntityName( val );
+ }
+
public Query setLocale(int position, Locale locale) {
setParameter(position, locale, Hibernate.LOCALE);
return this;
@@ -588,7 +595,7 @@
}
public Query setEntity(String name, Object val) {
- setParameter( name, val, Hibernate.entity( session.bestGuessEntityName(val) ) );
+ setParameter( name, val, Hibernate.entity( resolveEntityName( val ) ) );
return this;
}
Show replies by date