|
From: Andrei A. (JIRA) <nh...@gm...> - 2011-05-25 14:59:49
|
CLONE -HQL .class query on <any> mapping does not work
------------------------------------------------------
Key: NH-2741
URL: http://216.121.112.228/browse/NH-2741
Project: NHibernate
Issue Type: Bug
Components: Core
Affects Versions: 3.2.0Beta1
Reporter: Andrei Alecu
Priority: Major
Consider the test in trunk for NH-2328.
Modifying it to do this does not work:
var boxes = s.CreateQuery("from ToyBox t where t.Shape.class = Square")
.List<ToyBox>();
The error is:
System.NullReferenceException : Object reference not set to an instance of an object.
at NHibernate.Hql.Ast.ANTLR.SessionFactoryHelperExtensions.FindSQLFunction(String functionName) in SessionFactoryHelperExtensions.cs: line 45
at NHibernate.Hql.Ast.ANTLR.Tree.IdentNode.get_DataType() in IdentNode.cs: line 41
at NHibernate.Hql.Ast.ANTLR.Tree.BinaryLogicOperatorNode.ExtractDataType(IASTNode operand) in BinaryLogicOperatorNode.cs: line 244
at NHibernate.Hql.Ast.ANTLR.Tree.BinaryLogicOperatorNode.Initialize() in BinaryLogicOperatorNode.cs: line 50
at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.PrepareLogicOperator(IASTNode operatorNode) in HqlSqlWalker.cs: line 786
at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.comparisonExpr() in HqlSqlWalker.cs: line 6239
at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.logicalExpr() in HqlSqlWalker.cs: line 5228
at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.whereClause() in HqlSqlWalker.cs: line 4952
at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.unionedQuery() in HqlSqlWalker.cs: line 1706
at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.query() in HqlSqlWalker.cs: line 1514
at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.selectStatement() in HqlSqlWalker.cs: line 540
at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.statement() in HqlSqlWalker.cs: line 439
at NHibernate.Hql.Ast.ANTLR.HqlSqlTranslator.Translate() in QueryTranslatorImpl.cs: line 590
at NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.Analyze(String collectionRole) in QueryTranslatorImpl.cs: line 449
at NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.DoCompile(IDictionary`2 replacements, Boolean shallow, String collectionRole) in QueryTranslatorImpl.cs: line 354
at NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.Compile(IDictionary`2 replacements, Boolean shallow) in QueryTranslatorImpl.cs: line 71
at NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(IASTNode ast, String queryIdentifier, String collectionRole, Boolean shallow, IDictionary`2 filters, ISessionFactoryImplementor factory) in ASTQueryTranslatorFactory.cs: line 43
at NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(String queryString, String collectionRole, Boolean shallow, IDictionary`2 filters, ISessionFactoryImplementor factory) in ASTQueryTranslatorFactory.cs: line 21
at NHibernate.Engine.Query.HQLStringQueryPlan.CreateTranslators(String hql, String collectionRole, Boolean shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor factory) in HQLStringQueryPlan.cs: line 24
at NHibernate.Engine.Query.HQLStringQueryPlan..ctor(String hql, String collectionRole, Boolean shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor factory) in HQLStringQueryPlan.cs: line 16
at NHibernate.Engine.Query.HQLStringQueryPlan..ctor(String hql, Boolean shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor factory) in HQLStringQueryPlan.cs: line 10
at NHibernate.Engine.Query.QueryPlanCache.GetHQLQueryPlan(String queryString, Boolean shallow, IDictionary`2 enabledFilters) in QueryPlanCache.cs: line 61
at NHibernate.Impl.AbstractSessionImpl.GetHQLQueryPlan(String query, Boolean shallow) in AbstractSessionImpl.cs: line 304
at NHibernate.Impl.AbstractSessionImpl.CreateQuery(String queryString) in AbstractSessionImpl.cs: line 283
at NHibernate.Test.NHSpecificTest.NH2328.Fixture.AnyIs_HqlRequiresNumberIn() in Fixture.cs: line 80
However, explicitly using a parameter works properly:
var boxes = s.CreateQuery("from ToyBox t where t.Shape.class = :clazz")
.SetParameter("clazz", typeof(Square).FullName).List<ToyBox>();
Upon further inspection, it works because the implementation calls NullSafeSet() on MetaType while setting the parameter. If the type is specified inline, NullSafeSet isn't called.
I believe the proper fix here would be for the query parser to extract what's after = here and pass it in as a parameter, if possible, so that NullSafeSet() is called. It might involve changes to the grammar files, I'm not sure.
Fixing this bug in the HQL parser should also fix NH-2328.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
|
|
From: Andrei A. (JIRA) <nh...@gm...> - 2011-05-25 14:59:58
|
[ http://216.121.112.228/browse/NH-2741?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Andrei Alecu updated NH-2741:
-----------------------------
Attachment: nh2724 and nh2328.patch
Fabio, I have created a patch for NH-2724 so that .class = Square now works properly, and this also fixes NH-2328.
I have attached it. Please review.
> CLONE -HQL .class query on <any> mapping does not work
> ------------------------------------------------------
>
> Key: NH-2741
> URL: http://216.121.112.228/browse/NH-2741
> Project: NHibernate
> Issue Type: Bug
> Components: Core
> Affects Versions: 3.2.0Beta1
> Reporter: Andrei Alecu
> Priority: Major
> Attachments: nh2724 and nh2328.patch
>
>
> Consider the test in trunk for NH-2328.
> Modifying it to do this does not work:
> var boxes = s.CreateQuery("from ToyBox t where t.Shape.class = Square")
> .List<ToyBox>();
> The error is:
> System.NullReferenceException : Object reference not set to an instance of an object.
> at NHibernate.Hql.Ast.ANTLR.SessionFactoryHelperExtensions.FindSQLFunction(String functionName) in SessionFactoryHelperExtensions.cs: line 45
> at NHibernate.Hql.Ast.ANTLR.Tree.IdentNode.get_DataType() in IdentNode.cs: line 41
> at NHibernate.Hql.Ast.ANTLR.Tree.BinaryLogicOperatorNode.ExtractDataType(IASTNode operand) in BinaryLogicOperatorNode.cs: line 244
> at NHibernate.Hql.Ast.ANTLR.Tree.BinaryLogicOperatorNode.Initialize() in BinaryLogicOperatorNode.cs: line 50
> at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.PrepareLogicOperator(IASTNode operatorNode) in HqlSqlWalker.cs: line 786
> at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.comparisonExpr() in HqlSqlWalker.cs: line 6239
> at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.logicalExpr() in HqlSqlWalker.cs: line 5228
> at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.whereClause() in HqlSqlWalker.cs: line 4952
> at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.unionedQuery() in HqlSqlWalker.cs: line 1706
> at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.query() in HqlSqlWalker.cs: line 1514
> at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.selectStatement() in HqlSqlWalker.cs: line 540
> at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.statement() in HqlSqlWalker.cs: line 439
> at NHibernate.Hql.Ast.ANTLR.HqlSqlTranslator.Translate() in QueryTranslatorImpl.cs: line 590
> at NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.Analyze(String collectionRole) in QueryTranslatorImpl.cs: line 449
> at NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.DoCompile(IDictionary`2 replacements, Boolean shallow, String collectionRole) in QueryTranslatorImpl.cs: line 354
> at NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.Compile(IDictionary`2 replacements, Boolean shallow) in QueryTranslatorImpl.cs: line 71
> at NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(IASTNode ast, String queryIdentifier, String collectionRole, Boolean shallow, IDictionary`2 filters, ISessionFactoryImplementor factory) in ASTQueryTranslatorFactory.cs: line 43
> at NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(String queryString, String collectionRole, Boolean shallow, IDictionary`2 filters, ISessionFactoryImplementor factory) in ASTQueryTranslatorFactory.cs: line 21
> at NHibernate.Engine.Query.HQLStringQueryPlan.CreateTranslators(String hql, String collectionRole, Boolean shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor factory) in HQLStringQueryPlan.cs: line 24
> at NHibernate.Engine.Query.HQLStringQueryPlan..ctor(String hql, String collectionRole, Boolean shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor factory) in HQLStringQueryPlan.cs: line 16
> at NHibernate.Engine.Query.HQLStringQueryPlan..ctor(String hql, Boolean shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor factory) in HQLStringQueryPlan.cs: line 10
> at NHibernate.Engine.Query.QueryPlanCache.GetHQLQueryPlan(String queryString, Boolean shallow, IDictionary`2 enabledFilters) in QueryPlanCache.cs: line 61
> at NHibernate.Impl.AbstractSessionImpl.GetHQLQueryPlan(String query, Boolean shallow) in AbstractSessionImpl.cs: line 304
> at NHibernate.Impl.AbstractSessionImpl.CreateQuery(String queryString) in AbstractSessionImpl.cs: line 283
> at NHibernate.Test.NHSpecificTest.NH2328.Fixture.AnyIs_HqlRequiresNumberIn() in Fixture.cs: line 80
> However, explicitly using a parameter works properly:
> var boxes = s.CreateQuery("from ToyBox t where t.Shape.class = :clazz")
> .SetParameter("clazz", typeof(Square).FullName).List<ToyBox>();
> Upon further inspection, it works because the implementation calls NullSafeSet() on MetaType while setting the parameter. If the type is specified inline, NullSafeSet isn't called.
> I believe the proper fix here would be for the query parser to extract what's after = here and pass it in as a parameter, if possible, so that NullSafeSet() is called. It might involve changes to the grammar files, I'm not sure.
> Fixing this bug in the HQL parser should also fix NH-2328.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
|
|
From: Andrei A. (JIRA) <nh...@gm...> - 2011-05-25 15:10:55
|
[ http://216.121.112.228/browse/NH-2741?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21193#action_21193 ]
Andrei Alecu commented on NH-2741:
----------------------------------
Oops, I meant NH-2734 not NH-2724 in the previous comment.
> CLONE -HQL .class query on <any> mapping does not work
> ------------------------------------------------------
>
> Key: NH-2741
> URL: http://216.121.112.228/browse/NH-2741
> Project: NHibernate
> Issue Type: Bug
> Components: Core
> Affects Versions: 3.2.0Beta1
> Reporter: Andrei Alecu
> Priority: Major
> Attachments: nh2724 and nh2328.patch
>
>
> Consider the test in trunk for NH-2328.
> Modifying it to do this does not work:
> var boxes = s.CreateQuery("from ToyBox t where t.Shape.class = Square")
> .List<ToyBox>();
> The error is:
> System.NullReferenceException : Object reference not set to an instance of an object.
> at NHibernate.Hql.Ast.ANTLR.SessionFactoryHelperExtensions.FindSQLFunction(String functionName) in SessionFactoryHelperExtensions.cs: line 45
> at NHibernate.Hql.Ast.ANTLR.Tree.IdentNode.get_DataType() in IdentNode.cs: line 41
> at NHibernate.Hql.Ast.ANTLR.Tree.BinaryLogicOperatorNode.ExtractDataType(IASTNode operand) in BinaryLogicOperatorNode.cs: line 244
> at NHibernate.Hql.Ast.ANTLR.Tree.BinaryLogicOperatorNode.Initialize() in BinaryLogicOperatorNode.cs: line 50
> at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.PrepareLogicOperator(IASTNode operatorNode) in HqlSqlWalker.cs: line 786
> at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.comparisonExpr() in HqlSqlWalker.cs: line 6239
> at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.logicalExpr() in HqlSqlWalker.cs: line 5228
> at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.whereClause() in HqlSqlWalker.cs: line 4952
> at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.unionedQuery() in HqlSqlWalker.cs: line 1706
> at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.query() in HqlSqlWalker.cs: line 1514
> at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.selectStatement() in HqlSqlWalker.cs: line 540
> at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.statement() in HqlSqlWalker.cs: line 439
> at NHibernate.Hql.Ast.ANTLR.HqlSqlTranslator.Translate() in QueryTranslatorImpl.cs: line 590
> at NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.Analyze(String collectionRole) in QueryTranslatorImpl.cs: line 449
> at NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.DoCompile(IDictionary`2 replacements, Boolean shallow, String collectionRole) in QueryTranslatorImpl.cs: line 354
> at NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.Compile(IDictionary`2 replacements, Boolean shallow) in QueryTranslatorImpl.cs: line 71
> at NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(IASTNode ast, String queryIdentifier, String collectionRole, Boolean shallow, IDictionary`2 filters, ISessionFactoryImplementor factory) in ASTQueryTranslatorFactory.cs: line 43
> at NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(String queryString, String collectionRole, Boolean shallow, IDictionary`2 filters, ISessionFactoryImplementor factory) in ASTQueryTranslatorFactory.cs: line 21
> at NHibernate.Engine.Query.HQLStringQueryPlan.CreateTranslators(String hql, String collectionRole, Boolean shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor factory) in HQLStringQueryPlan.cs: line 24
> at NHibernate.Engine.Query.HQLStringQueryPlan..ctor(String hql, String collectionRole, Boolean shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor factory) in HQLStringQueryPlan.cs: line 16
> at NHibernate.Engine.Query.HQLStringQueryPlan..ctor(String hql, Boolean shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor factory) in HQLStringQueryPlan.cs: line 10
> at NHibernate.Engine.Query.QueryPlanCache.GetHQLQueryPlan(String queryString, Boolean shallow, IDictionary`2 enabledFilters) in QueryPlanCache.cs: line 61
> at NHibernate.Impl.AbstractSessionImpl.GetHQLQueryPlan(String query, Boolean shallow) in AbstractSessionImpl.cs: line 304
> at NHibernate.Impl.AbstractSessionImpl.CreateQuery(String queryString) in AbstractSessionImpl.cs: line 283
> at NHibernate.Test.NHSpecificTest.NH2328.Fixture.AnyIs_HqlRequiresNumberIn() in Fixture.cs: line 80
> However, explicitly using a parameter works properly:
> var boxes = s.CreateQuery("from ToyBox t where t.Shape.class = :clazz")
> .SetParameter("clazz", typeof(Square).FullName).List<ToyBox>();
> Upon further inspection, it works because the implementation calls NullSafeSet() on MetaType while setting the parameter. If the type is specified inline, NullSafeSet isn't called.
> I believe the proper fix here would be for the query parser to extract what's after = here and pass it in as a parameter, if possible, so that NullSafeSet() is called. It might involve changes to the grammar files, I'm not sure.
> Fixing this bug in the HQL parser should also fix NH-2328.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
|
|
From: Fabio M. (JIRA) <nh...@gm...> - 2011-05-30 15:16:45
|
[ http://216.121.112.228/browse/NH-2741?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21222#action_21222 ]
Fabio Maulo commented on NH-2741:
---------------------------------
Andrei,
can you resume which are the issues solved by your patch ?
> CLONE -HQL .class query on <any> mapping does not work
> ------------------------------------------------------
>
> Key: NH-2741
> URL: http://216.121.112.228/browse/NH-2741
> Project: NHibernate
> Issue Type: Bug
> Components: Core
> Affects Versions: 3.2.0Beta1
> Reporter: Andrei Alecu
> Priority: Major
> Attachments: nh2724 and nh2328.patch
>
>
> Consider the test in trunk for NH-2328.
> Modifying it to do this does not work:
> var boxes = s.CreateQuery("from ToyBox t where t.Shape.class = Square")
> .List<ToyBox>();
> The error is:
> System.NullReferenceException : Object reference not set to an instance of an object.
> at NHibernate.Hql.Ast.ANTLR.SessionFactoryHelperExtensions.FindSQLFunction(String functionName) in SessionFactoryHelperExtensions.cs: line 45
> at NHibernate.Hql.Ast.ANTLR.Tree.IdentNode.get_DataType() in IdentNode.cs: line 41
> at NHibernate.Hql.Ast.ANTLR.Tree.BinaryLogicOperatorNode.ExtractDataType(IASTNode operand) in BinaryLogicOperatorNode.cs: line 244
> at NHibernate.Hql.Ast.ANTLR.Tree.BinaryLogicOperatorNode.Initialize() in BinaryLogicOperatorNode.cs: line 50
> at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.PrepareLogicOperator(IASTNode operatorNode) in HqlSqlWalker.cs: line 786
> at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.comparisonExpr() in HqlSqlWalker.cs: line 6239
> at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.logicalExpr() in HqlSqlWalker.cs: line 5228
> at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.whereClause() in HqlSqlWalker.cs: line 4952
> at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.unionedQuery() in HqlSqlWalker.cs: line 1706
> at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.query() in HqlSqlWalker.cs: line 1514
> at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.selectStatement() in HqlSqlWalker.cs: line 540
> at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.statement() in HqlSqlWalker.cs: line 439
> at NHibernate.Hql.Ast.ANTLR.HqlSqlTranslator.Translate() in QueryTranslatorImpl.cs: line 590
> at NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.Analyze(String collectionRole) in QueryTranslatorImpl.cs: line 449
> at NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.DoCompile(IDictionary`2 replacements, Boolean shallow, String collectionRole) in QueryTranslatorImpl.cs: line 354
> at NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.Compile(IDictionary`2 replacements, Boolean shallow) in QueryTranslatorImpl.cs: line 71
> at NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(IASTNode ast, String queryIdentifier, String collectionRole, Boolean shallow, IDictionary`2 filters, ISessionFactoryImplementor factory) in ASTQueryTranslatorFactory.cs: line 43
> at NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(String queryString, String collectionRole, Boolean shallow, IDictionary`2 filters, ISessionFactoryImplementor factory) in ASTQueryTranslatorFactory.cs: line 21
> at NHibernate.Engine.Query.HQLStringQueryPlan.CreateTranslators(String hql, String collectionRole, Boolean shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor factory) in HQLStringQueryPlan.cs: line 24
> at NHibernate.Engine.Query.HQLStringQueryPlan..ctor(String hql, String collectionRole, Boolean shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor factory) in HQLStringQueryPlan.cs: line 16
> at NHibernate.Engine.Query.HQLStringQueryPlan..ctor(String hql, Boolean shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor factory) in HQLStringQueryPlan.cs: line 10
> at NHibernate.Engine.Query.QueryPlanCache.GetHQLQueryPlan(String queryString, Boolean shallow, IDictionary`2 enabledFilters) in QueryPlanCache.cs: line 61
> at NHibernate.Impl.AbstractSessionImpl.GetHQLQueryPlan(String query, Boolean shallow) in AbstractSessionImpl.cs: line 304
> at NHibernate.Impl.AbstractSessionImpl.CreateQuery(String queryString) in AbstractSessionImpl.cs: line 283
> at NHibernate.Test.NHSpecificTest.NH2328.Fixture.AnyIs_HqlRequiresNumberIn() in Fixture.cs: line 80
> However, explicitly using a parameter works properly:
> var boxes = s.CreateQuery("from ToyBox t where t.Shape.class = :clazz")
> .SetParameter("clazz", typeof(Square).FullName).List<ToyBox>();
> Upon further inspection, it works because the implementation calls NullSafeSet() on MetaType while setting the parameter. If the type is specified inline, NullSafeSet isn't called.
> I believe the proper fix here would be for the query parser to extract what's after = here and pass it in as a parameter, if possible, so that NullSafeSet() is called. It might involve changes to the grammar files, I'm not sure.
> Fixing this bug in the HQL parser should also fix NH-2328.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
|
|
From: Andrei A. (JIRA) <nh...@gm...> - 2011-05-30 16:11:46
|
[ http://216.121.112.228/browse/NH-2741?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=21225#action_21225 ]
Andrei Alecu commented on NH-2741:
----------------------------------
The patch fixes NH-2328 and this current issue (NH-2741 , and also the one you closed at NH-2734, which made me make this clone :)). There are some tests attached in the patch file, I mainly removed [Ignore] from those failing tests (since they now pass).
To reiterate, it allows .class = ClassName on <any/> mappings, instead of needing to use the underlaying meta-value, so that this works:
var boxes = s.CreateQuery("from ToyBox t where t.Shape.class = Square") // without the patch, this would throw an exception
.List<ToyBox>();
And since this works, it also fixes NH-2328 by default.
The tests are in the .patch file and they're under the NH2328 folder in NHSpecificTests.
> CLONE -HQL .class query on <any> mapping does not work
> ------------------------------------------------------
>
> Key: NH-2741
> URL: http://216.121.112.228/browse/NH-2741
> Project: NHibernate
> Issue Type: Bug
> Components: Core
> Affects Versions: 3.2.0Beta1
> Reporter: Andrei Alecu
> Priority: Major
> Attachments: nh2724 and nh2328.patch
>
>
> Consider the test in trunk for NH-2328.
> Modifying it to do this does not work:
> var boxes = s.CreateQuery("from ToyBox t where t.Shape.class = Square")
> .List<ToyBox>();
> The error is:
> System.NullReferenceException : Object reference not set to an instance of an object.
> at NHibernate.Hql.Ast.ANTLR.SessionFactoryHelperExtensions.FindSQLFunction(String functionName) in SessionFactoryHelperExtensions.cs: line 45
> at NHibernate.Hql.Ast.ANTLR.Tree.IdentNode.get_DataType() in IdentNode.cs: line 41
> at NHibernate.Hql.Ast.ANTLR.Tree.BinaryLogicOperatorNode.ExtractDataType(IASTNode operand) in BinaryLogicOperatorNode.cs: line 244
> at NHibernate.Hql.Ast.ANTLR.Tree.BinaryLogicOperatorNode.Initialize() in BinaryLogicOperatorNode.cs: line 50
> at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.PrepareLogicOperator(IASTNode operatorNode) in HqlSqlWalker.cs: line 786
> at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.comparisonExpr() in HqlSqlWalker.cs: line 6239
> at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.logicalExpr() in HqlSqlWalker.cs: line 5228
> at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.whereClause() in HqlSqlWalker.cs: line 4952
> at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.unionedQuery() in HqlSqlWalker.cs: line 1706
> at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.query() in HqlSqlWalker.cs: line 1514
> at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.selectStatement() in HqlSqlWalker.cs: line 540
> at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.statement() in HqlSqlWalker.cs: line 439
> at NHibernate.Hql.Ast.ANTLR.HqlSqlTranslator.Translate() in QueryTranslatorImpl.cs: line 590
> at NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.Analyze(String collectionRole) in QueryTranslatorImpl.cs: line 449
> at NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.DoCompile(IDictionary`2 replacements, Boolean shallow, String collectionRole) in QueryTranslatorImpl.cs: line 354
> at NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.Compile(IDictionary`2 replacements, Boolean shallow) in QueryTranslatorImpl.cs: line 71
> at NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(IASTNode ast, String queryIdentifier, String collectionRole, Boolean shallow, IDictionary`2 filters, ISessionFactoryImplementor factory) in ASTQueryTranslatorFactory.cs: line 43
> at NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(String queryString, String collectionRole, Boolean shallow, IDictionary`2 filters, ISessionFactoryImplementor factory) in ASTQueryTranslatorFactory.cs: line 21
> at NHibernate.Engine.Query.HQLStringQueryPlan.CreateTranslators(String hql, String collectionRole, Boolean shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor factory) in HQLStringQueryPlan.cs: line 24
> at NHibernate.Engine.Query.HQLStringQueryPlan..ctor(String hql, String collectionRole, Boolean shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor factory) in HQLStringQueryPlan.cs: line 16
> at NHibernate.Engine.Query.HQLStringQueryPlan..ctor(String hql, Boolean shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor factory) in HQLStringQueryPlan.cs: line 10
> at NHibernate.Engine.Query.QueryPlanCache.GetHQLQueryPlan(String queryString, Boolean shallow, IDictionary`2 enabledFilters) in QueryPlanCache.cs: line 61
> at NHibernate.Impl.AbstractSessionImpl.GetHQLQueryPlan(String query, Boolean shallow) in AbstractSessionImpl.cs: line 304
> at NHibernate.Impl.AbstractSessionImpl.CreateQuery(String queryString) in AbstractSessionImpl.cs: line 283
> at NHibernate.Test.NHSpecificTest.NH2328.Fixture.AnyIs_HqlRequiresNumberIn() in Fixture.cs: line 80
> However, explicitly using a parameter works properly:
> var boxes = s.CreateQuery("from ToyBox t where t.Shape.class = :clazz")
> .SetParameter("clazz", typeof(Square).FullName).List<ToyBox>();
> Upon further inspection, it works because the implementation calls NullSafeSet() on MetaType while setting the parameter. If the type is specified inline, NullSafeSet isn't called.
> I believe the proper fix here would be for the query parser to extract what's after = here and pass it in as a parameter, if possible, so that NullSafeSet() is called. It might involve changes to the grammar files, I'm not sure.
> Fixing this bug in the HQL parser should also fix NH-2328.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
|
|
From: Fabio M. (JIRA) <nh...@gm...> - 2011-05-30 16:50:41
|
[ http://216.121.112.228/browse/NH-2741?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Fabio Maulo resolved NH-2741.
-----------------------------
Resolution: Fixed
Fix Version/s: 3.2.0Beta2
> CLONE -HQL .class query on <any> mapping does not work
> ------------------------------------------------------
>
> Key: NH-2741
> URL: http://216.121.112.228/browse/NH-2741
> Project: NHibernate
> Issue Type: Bug
> Components: Core
> Affects Versions: 3.2.0Beta1
> Reporter: Andrei Alecu
> Priority: Major
> Fix For: 3.2.0Beta2
>
> Attachments: nh2724 and nh2328.patch
>
>
> Consider the test in trunk for NH-2328.
> Modifying it to do this does not work:
> var boxes = s.CreateQuery("from ToyBox t where t.Shape.class = Square")
> .List<ToyBox>();
> The error is:
> System.NullReferenceException : Object reference not set to an instance of an object.
> at NHibernate.Hql.Ast.ANTLR.SessionFactoryHelperExtensions.FindSQLFunction(String functionName) in SessionFactoryHelperExtensions.cs: line 45
> at NHibernate.Hql.Ast.ANTLR.Tree.IdentNode.get_DataType() in IdentNode.cs: line 41
> at NHibernate.Hql.Ast.ANTLR.Tree.BinaryLogicOperatorNode.ExtractDataType(IASTNode operand) in BinaryLogicOperatorNode.cs: line 244
> at NHibernate.Hql.Ast.ANTLR.Tree.BinaryLogicOperatorNode.Initialize() in BinaryLogicOperatorNode.cs: line 50
> at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.PrepareLogicOperator(IASTNode operatorNode) in HqlSqlWalker.cs: line 786
> at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.comparisonExpr() in HqlSqlWalker.cs: line 6239
> at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.logicalExpr() in HqlSqlWalker.cs: line 5228
> at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.whereClause() in HqlSqlWalker.cs: line 4952
> at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.unionedQuery() in HqlSqlWalker.cs: line 1706
> at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.query() in HqlSqlWalker.cs: line 1514
> at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.selectStatement() in HqlSqlWalker.cs: line 540
> at NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.statement() in HqlSqlWalker.cs: line 439
> at NHibernate.Hql.Ast.ANTLR.HqlSqlTranslator.Translate() in QueryTranslatorImpl.cs: line 590
> at NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.Analyze(String collectionRole) in QueryTranslatorImpl.cs: line 449
> at NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.DoCompile(IDictionary`2 replacements, Boolean shallow, String collectionRole) in QueryTranslatorImpl.cs: line 354
> at NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.Compile(IDictionary`2 replacements, Boolean shallow) in QueryTranslatorImpl.cs: line 71
> at NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(IASTNode ast, String queryIdentifier, String collectionRole, Boolean shallow, IDictionary`2 filters, ISessionFactoryImplementor factory) in ASTQueryTranslatorFactory.cs: line 43
> at NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(String queryString, String collectionRole, Boolean shallow, IDictionary`2 filters, ISessionFactoryImplementor factory) in ASTQueryTranslatorFactory.cs: line 21
> at NHibernate.Engine.Query.HQLStringQueryPlan.CreateTranslators(String hql, String collectionRole, Boolean shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor factory) in HQLStringQueryPlan.cs: line 24
> at NHibernate.Engine.Query.HQLStringQueryPlan..ctor(String hql, String collectionRole, Boolean shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor factory) in HQLStringQueryPlan.cs: line 16
> at NHibernate.Engine.Query.HQLStringQueryPlan..ctor(String hql, Boolean shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor factory) in HQLStringQueryPlan.cs: line 10
> at NHibernate.Engine.Query.QueryPlanCache.GetHQLQueryPlan(String queryString, Boolean shallow, IDictionary`2 enabledFilters) in QueryPlanCache.cs: line 61
> at NHibernate.Impl.AbstractSessionImpl.GetHQLQueryPlan(String query, Boolean shallow) in AbstractSessionImpl.cs: line 304
> at NHibernate.Impl.AbstractSessionImpl.CreateQuery(String queryString) in AbstractSessionImpl.cs: line 283
> at NHibernate.Test.NHSpecificTest.NH2328.Fixture.AnyIs_HqlRequiresNumberIn() in Fixture.cs: line 80
> However, explicitly using a parameter works properly:
> var boxes = s.CreateQuery("from ToyBox t where t.Shape.class = :clazz")
> .SetParameter("clazz", typeof(Square).FullName).List<ToyBox>();
> Upon further inspection, it works because the implementation calls NullSafeSet() on MetaType while setting the parameter. If the type is specified inline, NullSafeSet isn't called.
> I believe the proper fix here would be for the query parser to extract what's after = here and pass it in as a parameter, if possible, so that NullSafeSet() is called. It might involve changes to the grammar files, I'm not sure.
> Fixing this bug in the HQL parser should also fix NH-2328.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
|