Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9155979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:41:27+00:00 2026-06-17T12:41:27+00:00

I have a query like (session.query(Root).with_polymorphic(‘*’) .outerjoin(Subclass.related1).options(contains_eager(Subclass.related1))) So far things work. I want also

  • 0

I have a query like

(session.query(Root).with_polymorphic('*')
    .outerjoin(Subclass.related1).options(contains_eager(Subclass.related1)))

So far things work.

I want also want to eagerly load Related1.related2 and I tried this:

(session.query(Root).with_polymorphic('*')
    .outerjoin(Subclass.related1).options(contains_eager(Subclass.related1))
    .outerjoin(Related1.related2).options(contains_eager(Related1.related2)))

But it doesn’t work:

sqlalchemy.exc.ArgumentError: Can’t find property ‘related2’ on any entity specified in this Query. Note the full path from root (Mapper|Root|root) to target entity must be specified.

Given that related1 is related to the root entity via a subclass I don’t see how to specify the full path.

I also tried

(session.query(Root).with_polymorphic('*')
    .outerjoin(Subclass.related1).options(contains_eager(Subclass.related1))
    .outerjoin(Related1.related2).options(contains_eager('related1.related2')))

which predictably fails with

sqlalchemy.exc.ArgumentError: Can’t find property named ‘related1’ on the mapped entity Mapper|Root|root in this Query.

How can I specify the full path to the indirectly-related entity in contains_eager()?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T12:41:28+00:00Added an answer on June 17, 2026 at 12:41 pm

    contains_eager needs a full path from the entities the query knows about:

    contains_eager(Subclass.related1, Related1.related2)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a nHibernate query like this ICriteria query = session.CreateCriteria(typeof(MyResult)) .Add(Expression.Eq(ResultTypeId, myResult.ResultTypeId)) Problem
I have an NHibernate query that looks like this: var query = Session.CreateQuery(@ select
So, I have a query like public static IEnumerable<Archive> GetArchivesRecursive(this ISession session, Page rootPage)
I have an NHibernate LINQ query like this: var maxNumber = session .Linq<Child>() .Where(c
I have a query like this: var query = scope.Session.QueryOver<Task>().Where(s => s.Code == code
I have a hql query like this: return (long)Session.CreateQuery ( select count(*) + from
I have query like this : SELECT EXTRACT(MONTH FROM d.mydate) AS synmonth, SUM(apcp) AS
I have a query like this: select empno,name from emp where job = 'CLERK'
I have a query like: SELECT ... FROM ... WHERE .. AND SomeID =
I have a query like DELETE from tablename where colname = value; which takes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.