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

  • SEARCH
  • Home
  • 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 8475733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:58:23+00:00 2026-06-10T17:58:23+00:00

I have a Stats entity that is related to a Journey entity through a

  • 0

I have a Stats entity that is related to a Journey entity through a ManyToOne association.

id:
    index:
        type: integer

fields:
        idJourney:
        type: string
// data fields...
manyToOne:
    journey:
        targetEntity: Journey
        joinColumn:
            name: idJourney
            referencedColumnName: idJourney

The Journey is related to the Station entity through two ManyToOne association: one for the first Station of the Journey, one for the last.

id:
    idjourney:
        type: string
    fields:
        idFirstStation:
            type: string
        idLastStation:
            type: string
    // other info fields
    manyToOne:
        firstStation:
            targetEntity: Station
            joinColumn:
                name: idFirstStation
                referencedColumnName: idStation
        lastStation:
            targetEntity: Station
            joinColumn:
                name: idLastStation
                referencedColumnName: idStation

Finally, the Station entity :

id:
    idStation:
        type: string
fields:   
    name:
        type: string
// other station info

I retrieve a collection of Stats objects with all related sub-objects via a custom Repository method which works fine.

$statCollection = $statsRepository->getStatsByDateAndArea($date, $area);

//This retrieves the expected data
$statCollection[0]->getJourney()->getFirstStation()->getName();

However, iterating through the collection with a foreach loop doesn’t work:

foreach($statCollection as $stat) {
    $journey = $stat->getJourney(); // works fine
    $firstStationId = $journey->getFirstStationId(); // works too
    $firstStation = $journey->getFirstStation(); // still works, but returns a Proxies\AcmeAppPathWhateverBundleEntityStationProxy object instead of a AcmeAppPathWhateverBundleEntityStation, but this should be transparent (as per Doctrine documentation)
    $firstStationName = $firstStation->getName(); // throws an EntityNotFoundException
}

Any idea what’s going on ? Should I force Doctrine to fetch all sub entities ?

EDIT
The error message is fairly laconic :

EntityNotFoundException: Entity was not found.

Not very helpful…

  • 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-10T17:58:24+00:00Added an answer on June 10, 2026 at 5:58 pm

    I ended up querying explicitly for the full set of sub-entities in my custom repository method…

    I changed this query :

        ->select('stats')
        ->leftJoin('stats.journey', 'j')
        ->leftJoin('j.firstStation', 'fs')
        ->leftJoin('j.lastStation', 'ls')
    

    to :

        ->select('stats, j, fs, ls')
        ->leftJoin('stats.journey', 'j')
        ->leftJoin('j.firstStation', 'fs')
        ->leftJoin('j.lastStation', 'ls')
    

    I guess Doctrine’s use of Proxy objects are not all that transparent…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two related entities, say @Entity public class Book { @ManyToOne Shelf shelf;
I have an entity A that has a link to an entity B through
I have a Supplier Entitiy that contains ID - int Status - string Name
I have a Supplier Entitiy that contains ID - int Status - string Name
I have two tables: servers and stats servers has a column called id that
I have a website with live stats that I wish to display to every
I have an index.php file which has 2 included files require(stats.php); require(stats_encry.php); stats.php which
I have an entity that needs to be grouped several times by three of
I have a simple JPA entity that uses a generated long ID as its
I have an entity model that has audit information on every table (50+ tables)

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.