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.