Sure:

Mappings:

public class LogDtoMap : DtoClassMap<LogDto>
    {
        public LogDtoMap()
        {
            Table("log");
            Id(x => x.Id, "Id");
 
            Map(x => x.Date, "date");
            Map(x => x.Message, "message");
            Map(x => x.Level, "level");
            Map(x => x.Logger, "logger");
            Map(x => x.Exception, "exception");
            Map(x => x.Url, "url").Nullable();
            References(x => x.User, "user_id").NotFound.Ignore().Nullable();
        }
    }


public class UserDtoMap : DtoClassMap<UserDto>
    {
        public UserDtoMap()
        {
            Table("users");
            Id(user => user.Id, "user_id");
 
            Map(user => user.Username, "login");
            Map(user => user.Email, "email");
        }
    }


Query:

*Session.Query<LogDto>().Fetch(x => x.User)*


Query specified join fetching, but the owner of the fetched association was 
not present in the select list 
[FromElement{explicit,not a collection join,fetch join,fetch non-lazy 
properties,classAlias=_0,role=,tableName=users,tableAlias=userdto1_,origin=log 
logdto0_,colums={logdto0_.user_id 
,className=ClientCode.Query.Dto.UserDto}}] 
[.Count[ClientCode.Query.Dto.LogDto](.Fetch[ClientCode.Query.Dto.LogDto,ClientCode.Query.Dto.UserDto](NHibernate.Linq.NhQueryable`1[ClientCode.Query.Dto.LogDto],
 
Quote((x, ) => (x.User)), ), )]

Exception Details:
NHibernate.QueryException: Query specified join fetching, but the owner of 
the fetched association was not present in the select list 
[FromElement{explicit,not a collection join,fetch join,fetch non-lazy 
properties,classAlias=_0,role=,tableName=users,tableAlias=userdto1_,origin=log 
logdto0_,colums={logdto0_.user_id 
,className=ClientCode.Query.Dto.UserDto}}] 
[.Count[ClientCode.Query.Dto.LogDto](.Fetch[ClientCode.Query.Dto.LogDto,ClientCode.Query.Dto.UserDto](NHibernate.Linq.NhQueryable`1[ClientCode.Query.Dto.LogDto],
 
Quote((x, ) => (x.User)), ), )]

Stack Trace:

[QueryException: Query specified join fetching, but the owner of the 
fetched association was not present in the select list 
[FromElement{explicit,not a collection join,fetch join,fetch non-lazy 
properties,classAlias=_0,role=,tableName=users,tableAlias=userdto1_,origin=log 
logdto0_,colums={logdto0_.user_id 
,className=ClientCode.Query.Dto.UserDto}}] 
[.Count[ClientCode.Query.Dto.LogDto](.Fetch[ClientCode.Query.Dto.LogDto,ClientCode.Query.Dto.UserDto](NHibernate.Linq.NhQueryable`1[ClientCode.Query.Dto.LogDto],
 
Quote((x, ) => (x.User)), ), )]]
  
 
NHibernate.Hql.Ast.ANTLR.Tree.SelectClause.InitializeExplicitSelectClause(FromClause
 
fromClause) in 
d:\CSharp\NH\NH\nhibernate\src\NHibernate\Hql\Ast\ANTLR\Tree\SelectClause.cs:211
   NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.ProcessQuery(IASTNode select, 
IASTNode query) in 
d:\CSharp\NH\NH\nhibernate\src\NHibernate\Hql\Ast\ANTLR\HqlSqlWalker.cs:476
   NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.unionedQuery() in 
d:\CSharp\NH\NH\nhibernate\src\NHibernate\Hql\Ast\ANTLR\Generated\HqlSqlWalker.cs:1938
   NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.query() in 
d:\CSharp\NH\NH\nhibernate\src\NHibernate\Hql\Ast\ANTLR\Generated\HqlSqlWalker.cs:1514
   NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.selectStatement() in 
d:\CSharp\NH\NH\nhibernate\src\NHibernate\Hql\Ast\ANTLR\Generated\HqlSqlWalker.cs:540
   NHibernate.Hql.Ast.ANTLR.HqlSqlWalker.statement() in 
d:\CSharp\NH\NH\nhibernate\src\NHibernate\Hql\Ast\ANTLR\Generated\HqlSqlWalker.cs:439
   NHibernate.Hql.Ast.ANTLR.HqlSqlTranslator.Translate() in 
d:\CSharp\NH\NH\nhibernate\src\NHibernate\Hql\Ast\ANTLR\QueryTranslatorImpl.cs:566
   NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.DoCompile(IDictionary`2 
replacements, Boolean shallow, String collectionRole) in 
d:\CSharp\NH\NH\nhibernate\src\NHibernate\Hql\Ast\ANTLR\QueryTranslatorImpl.cs:373
  
 
NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(IASTNode
 
ast, String queryIdentifier, String collectionRole, Boolean shallow, 
IDictionary`2 filters, ISessionFactoryImplementor factory) in 
d:\CSharp\NH\NH\nhibernate\src\NHibernate\Hql\Ast\ANTLR\ASTQueryTranslatorFactory.cs:43
   NHibernate.Engine.Query.HQLExpressionQueryPlan.CreateTranslators(String 
expressionStr, IQueryExpression queryExpression, String collectionRole, 
Boolean shallow, IDictionary`2 enabledFilters, ISessionFactoryImplementor 
factory) in 
d:\CSharp\NH\NH\nhibernate\src\NHibernate\Engine\Query\HQLExpressionQueryPlan.cs:34
   NHibernate.Engine.Query.QueryPlanCache.GetHQLQueryPlan(IQueryExpression 
queryExpression, Boolean shallow, IDictionary`2 enabledFilters) in 
d:\CSharp\NH\NH\nhibernate\src\NHibernate\Engine\Query\QueryPlanCache.cs:89
   NHibernate.Impl.AbstractSessionImpl.GetHQLQueryPlan(IQueryExpression 
queryExpression, Boolean shallow) in 
d:\CSharp\NH\NH\nhibernate\src\NHibernate\Impl\AbstractSessionImpl.cs:312
   NHibernate.Impl.AbstractSessionImpl.CreateQuery(IQueryExpression 
queryExpression) in 
d:\CSharp\NH\NH\nhibernate\src\NHibernate\Impl\AbstractSessionImpl.cs:268
   NHibernate.Linq.DefaultQueryProvider.Execute(Expression expression) in 
d:\CSharp\NH\NH\nhibernate\src\NHibernate\Linq\DefaultQueryProvider.cs:33
   ClientCode.Manage.Helpers.DynamicQueryable.Count(IQueryable source) in 
D:\Projects\ClientCode\master\Web\src\ClientCode.Web.WebApp\Areas\Manage\Helpers\DynamicQueryable.cs:117
   ClientCode.Manage.Helpers.Grid.GridFilter`1.DataFilter(GridSettings 
param) in 
D:\Projects\ClientCode\master\Web\src\ClientCode.Web.WebApp\Areas\Manage\Helpers\Grid\GridFilter.cs:90
   ClientCode.Manage.Controllers.LogController.GetList(GridSettings param) 
in 
D:\Projects\ClientCode\master\Web\src\ClientCode.Web.WebApp\Areas\Manage\Controllers\LogController.cs:33
   lambda_method(Closure , ControllerBase , Object[] ) +127
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext 
controllerContext, IDictionary`2 parameters) +264
  
 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext 
controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 
parameters) +39
  
 
Castle.Proxies.Invocations.ControllerActionInvoker_InvokeActionMethod.InvokeMethodOnTarget()
 
+190
   Castle.DynamicProxy.AbstractInvocation.Proceed() +72
  
 Glimpse.Net.Interceptor.InvokeActionMethodInterceptor.Intercept(IInvocation 
invocation) +416
   Castle.DynamicProxy.AbstractInvocation.Proceed() +316
  
 
Castle.Proxies.ControllerActionInvokerProxy.InvokeActionMethod(ControllerContext
 
controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 
parameters) +206
  
 System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() 
+129
  
 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter 
filter, ActionExecutingContext preContext, Func`1 continuation) +826266
  
 
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext
 
controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, 
IDictionary`2 parameters) +314
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext 
controllerContext, String actionName) +825488
   System.Web.Mvc.Controller.ExecuteCore() +159
   System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +335
   System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +62
   System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +20
   System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +54
  
 
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
 
+469
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& 
completedSynchronously) +375

On Wednesday, May 30, 2012 1:57:01 PM UTC+3, Alexander I. Zaytsev wrote:
>
> Hi, Could you please provide the query which throws and full stack trace 
> of the exception?
>
> среда, 30 мая 2012 г., 16:23:35 UTC+6 пользователь mynkow написал:
>>
>> Is there any workaround for this error? *Query specified join fetching, 
>> but the owner of the fetched association was not present in the select list 
>> [FromElement{explicit,not a collection join,fetch join,fetch non-lazy 
>> properties*
>>
>> I read somewhere that people solved this with introducing an alias in HQL 
>> queries. What about Linq?
>>
>> 10x
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/nhusers/-/epBT-rJEqRkJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to