-->
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.  [ 2 posts ] 
Author Message
 Post subject: Odd exception for HQL query
PostPosted: Thu Dec 01, 2005 10:16 am 
Senior
Senior

Joined: Thu Jun 02, 2005 5:03 pm
Posts: 135
Location: Paris
Can anyone explain this?

I've got an HQL query like the following:

Code:
SELECT
   COUNT(p.Id) 
FROM
   Proof p
   LEFT JOIN p.ParentDeliveryJob parentDeliveryJob
   LEFT JOIN parentDeliveryJob.DeliveryUser.Customer customer
   LEFT JOIN p.ChildDeliveryJob childDeliveryJob
WHERE
   (p.Deleted = false) AND
   (p.Verdict = :Verdict) AND
   (p.DeliveryJob IS NOT NULL AND p.ProofResponse IS NULL) 


I'm aware that the join values aren't being used in the actual result, but I'm generating a statement split into a SELECT clause, a FROM clause and a WHERE clause and then replacing the SELECT clause to get a count of the number of results that will be returned so I can do paging.

The exception that's being thrown for the query when executing .UniqueResult() is as follows:

Code:
[4972] NHibernate.Impl.SessionImpl: 2005-12-01 15:02:22,334 [4692] DEBUG [(null)] <(null)> - opened session
[4972] NHibernate.Impl.SessionImpl: 2005-12-01 15:02:22,334 [4692] DEBUG [(null)] <(null)> - opened session
[4972] NHibernate.Impl.SessionImpl: 2005-12-01 15:02:22,334 [4692] DEBUG [(null)] <(null)> - find: SELECT COUNT(p.Id)  FROM Proof p LEFT JOIN p.ParentDeliveryJob parentDeliveryJob LEFT JOIN parentDeliveryJob.DeliveryUser.Customer customer LEFT JOIN p.ChildDeliveryJob childDeliveryJob WHERE (p.Deleted = false) AND (p.Verdict = :Verdict) AND (p.DeliveryJob IS NOT NULL AND p.ProofResponse IS NULL)
[4972] NHibernate.Impl.SessionImpl: 2005-12-01 15:02:22,334 [4692] DEBUG [(null)] <(null)> - find: SELECT COUNT(p.Id)  FROM Proof p LEFT JOIN p.ParentDeliveryJob parentDeliveryJob LEFT JOIN parentDeliveryJob.DeliveryUser.Customer customer LEFT JOIN p.ChildDeliveryJob childDeliveryJob WHERE (p.Deleted = false) AND (p.Verdict = :Verdict) AND (p.DeliveryJob IS NOT NULL AND p.ProofResponse IS NULL)
[4972] NHibernate.Engine.QueryParameters: 2005-12-01 15:02:22,334 [4692] DEBUG [(null)] <(null)> - named parameters: {Verdict=0}
[4972] NHibernate.Engine.QueryParameters: 2005-12-01 15:02:22,334 [4692] DEBUG [(null)] <(null)> - named parameters: {Verdict=0}
[4972] NHibernate.Hql.QueryTranslator: 2005-12-01 15:02:22,334 [4692] DEBUG [(null)] <(null)> - compiling query
[4972] NHibernate.Hql.QueryTranslator: 2005-12-01 15:02:22,334 [4692] DEBUG [(null)] <(null)> - compiling query
[4972] NHibernate.Hql.QueryTranslator: 2005-12-01 15:02:22,334 [4692] DEBUG [(null)] <(null)> - unexpected query compilation problem
[4972] System.ArgumentException: Item has already been added.  Key in dictionary: "p"  Key being added: "p"
[4972]    at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add)
[4972]    at System.Collections.Hashtable.Add(Object key, Object value)
[4972]    at NHibernate.Hql.FromParser.Token(String token, QueryTranslator q)
[4972]    at NHibernate.Hql.ClauseParser.Token(String token, QueryTranslator q)
[4972]    at NHibernate.Hql.PreprocessingParser.Token(String token, QueryTranslator q)
[4972]    at NHibernate.Hql.ParserHelper.Parse(IParser p, String text, String seperators, QueryTranslator q)
[4972]    at NHibernate.Hql.QueryTranslator.Compile()
[4972] NHibernate.Hql.QueryTranslator: 2005-12-01 15:02:22,334 [4692] DEBUG [(null)] <(null)> - unexpected query compilation problem
[4972] System.ArgumentException: Item has already been added.  Key in dictionary: "p"  Key being added: "p"
[4972]    at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add)
[4972]    at System.Collections.Hashtable.Add(Object key, Object value)
[4972]    at NHibernate.Hql.FromParser.Token(String token, QueryTranslator q)
[4972]    at NHibernate.Hql.ClauseParser.Token(String token, QueryTranslator q)
[4972]    at NHibernate.Hql.PreprocessingParser.Token(String token, QueryTranslator q)
[4972]    at NHibernate.Hql.ParserHelper.Parse(IParser p, String text, String seperators, QueryTranslator q)
[4972]    at NHibernate.Hql.QueryTranslator.Compile()


I've only opened one session, so the duplicated lines in the NHibernate debug output seem a little wierd. Is this a bug?

Cheers,

Symon.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 01, 2005 1:52 pm 
Senior
Senior

Joined: Thu Jun 02, 2005 5:03 pm
Posts: 135
Location: Paris
Interestingly, it turns out that this is being caused by a malformed query...one of the p.DeliveryJob in the WHERE clause is actually an invalid property.

What we've found, however, that the exception is sometimes reported as per my previous post, and other times it's specific enough to say...

Quote:
could not resolve property:DeliveryJob of :Framework.Core.Entities.Proof


..for the exact same query, at the exact same line with the exact same parameters.

So it looks like something is wrong with the exception generation. Anyone got any thoughts?

Symon.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.