@@ -70,7 +70,7 @@ public void LookupConstant(DotNode node)
7070 }
7171 else
7272 {
73- Object value = ReflectHelper . GetConstantValue ( text ) ;
73+ var value = ReflectHelper . GetConstantValue ( text , _walker . SessionFactoryHelper . Factory ) ;
7474 if ( value == null )
7575 {
7676 throw new InvalidPathException ( "Invalid path: '" + text + "'" ) ;
@@ -149,6 +149,7 @@ public void ProcessConstant(SqlNode constant, bool resolveIdent)
149149 if ( isIdent && queryable != null )
150150 {
151151 constant . Text = queryable . DiscriminatorSQLValue ;
152+ constant . DataType = queryable . DiscriminatorType ;
152153 }
153154 // Otherwise, it's a literal.
154155 else
@@ -275,74 +276,9 @@ private void SetConstantValue(DotNode node, string text, object value)
275276
276277 node . ClearChildren ( ) ; // Chop off the rest of the tree.
277278
278- if ( value is string )
279- {
280- node . Type = HqlSqlWalker . QUOTED_String ;
281- }
282- else if ( value is char )
283- {
284- node . Type = HqlSqlWalker . QUOTED_String ;
285- }
286- else if ( value is byte )
287- {
288- node . Type = HqlSqlWalker . NUM_INT ;
289- }
290- else if ( value is short )
291- {
292- node . Type = HqlSqlWalker . NUM_INT ;
293- }
294- else if ( value is int )
295- {
296- node . Type = HqlSqlWalker . NUM_INT ;
297- }
298- else if ( value is long )
299- {
300- node . Type = HqlSqlWalker . NUM_LONG ;
301- }
302- else if ( value is double )
303- {
304- node . Type = HqlSqlWalker . NUM_DOUBLE ;
305- }
306- else if ( value is decimal )
307- {
308- node . Type = HqlSqlWalker . NUM_DECIMAL ;
309- }
310- else if ( value is float )
311- {
312- node . Type = HqlSqlWalker . NUM_FLOAT ;
313- }
314- else
315- {
316- node . Type = HqlSqlWalker . CONSTANT ;
317- }
318-
319- IType type ;
320- try
321- {
322- type = TypeFactory . HeuristicType ( value . GetType ( ) . Name ) ;
323- }
324- catch ( MappingException me )
325- {
326- throw new QueryException ( me ) ;
327- }
328-
329- if ( type == null )
330- {
331- throw new QueryException ( LiteralProcessor . ErrorCannotDetermineType + node . Text ) ;
332- }
333- try
334- {
335- ILiteralType literalType = ( ILiteralType ) type ;
336- NHibernate . Dialect . Dialect dialect = _walker . SessionFactoryHelper . Factory . Dialect ;
337- node . Text = literalType . ObjectToSQLString ( value , dialect ) ;
338- }
339- catch ( Exception e )
340- {
341- throw new QueryException ( LiteralProcessor . ErrorCannotFormatLiteral + node . Text , e ) ;
342- }
343-
344- node . DataType = type ;
345- node . SetResolvedConstant ( text ) ;
279+ node . Type = HqlSqlWalker . JAVA_CONSTANT ;
280+ node . DataType = TypeFactory . HeuristicType ( value . GetType ( ) . Name ) ;
281+ node . SetResolvedConstant ( text , value ) ;
346282 }
347283
348284 interface IDecimalFormatter
0 commit comments