[DDC-633] fetch="EAGER" is not loading one to one associations Created: 11/Jun/10 Updated: 28/Sep/10 Resolved: 08/Aug/10 |
|
| Status: | Resolved |
| Project: | Doctrine 2 - ORM |
| Component/s: | ORM |
| Affects Version/s: | None |
| Fix Version/s: | 2.0-BETA4 |
| Security Level: | All |
| Type: | Bug | Priority: | Critical |
| Reporter: | Dave Keen | Assignee: | Benjamin Eberlei |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | None | ||
| Description |
<?php
namespace vo;
/**
* @Entity
*/
class Appointment {
/** @Id @Column(type="integer") @GeneratedValue(strategy="IDENTITY") */
public $id;
/**
* @OneToOne(targetEntity="Patient", inversedBy="appointment", fetch="EAGER")
* @JoinColumn(name="patient_id", referencedColumnName="id")
*/
public $patient;
}
When doing a findAll() on appointments, $patient is being created as a proxy even though fetch is EAGER. |
| Comments |
| Comment by Benjamin Eberlei [ 08/Aug/10 ] |
|
Fixed in master |
| Comment by Michael Moravec [ 17/Aug/10 ] |
|
What is an advantage of this solution (in master) if it is loaded in the same way as when fetched lazily? Maybe it'd be better to use INNER JOIN instead, at least for OneToOne and save one or more (probably unnecessary) SQL queries? |
| Comment by Benjamin Eberlei [ 17/Aug/10 ] |
|
There is none (yet), it may be a future enhancement, however we dont know this yet. fetch=EAGER is not so useful at the moment. |
| Comment by Michael Moravec [ 17/Aug/10 ] |
|
I think that fetch=EAGER should behave like this DQL: Should I open a new issue for this? |
| Comment by Eduard Kracmar [ 28/Sep/10 ] |
|
fetch=EAGER still is not working as I think it should. class Project { /**
but after $this->getEntityManager() 2 doctrine queries are executed: SELECT t0.id AS id1, t0.name AS name2, t0.paths AS paths3, t0.modified AS modified4, t0.created AS SELECT t0.id AS id1, t0.name AS name2, t0.modified AS modified3, t0.created AS created4 And it should be one query with inner join to clients. |
| Comment by Benjamin Eberlei [ 28/Sep/10 ] |
|
Eager doesnt mean it does a Join, it only means the query is executed directly |
| Comment by Eduard Kracmar [ 28/Sep/10 ] |
|
I see. And how can be achieved that product and client will be queried at once, and not only when I request product->getClient() ? |