-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: HQL: param types validation against collections element type
PostPosted: Thu Jan 26, 2006 11:16 pm 
Newbie

Joined: Thu Jan 26, 2006 10:58 pm
Posts: 1
1.0.2

Hierarchy: Parent-Child-Grandchild, both 1:M

Query: "from Child ch where :parm in elements(ch.Grandchild)"

Parameter passed: session.SetEntity("parm", someParentObject)
(YES - incorrect object submitted, the intent was to test type validation)

Result - no Exception raised, SQL successfully generated, Parent's ID substituted as the param value, SQL executed, some list of Child objects returned.

Problem: the actual param type was obviosly incorrect; but accepted by the system

Question: the lack of Param type validation - is this by design, or has some other explanation?

thank you


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 27, 2006 5:10 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
HQL parser in NHibernate is not sophisticated enough to do type checking, and besides it would slow things down.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 27, 2006 12:38 pm 
Newbie

Joined: Fri Jan 27, 2006 12:27 pm
Posts: 2
This creates an opening for some fairly pernicious bugs particuarly for large projects with multiple programmers since the incorrectness of the query will be very hard to detect.

Are there common patterns people use to validate Query parameters for type correctness.

Your point about expense of type checking is well taken. It would be nice if you could flag the parser to optionally perform the check but it would probably be a beast to code.

To all the authors and contribs. nHib is an impressive piece of work thanks for creating it.

Cheers,

Terence


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.