Without trying to access any field on the Country entity, it hasn't any
field loaded at all. When I try to access any field, it fully loads the
Country and it works. I thought it was for the lazy loading process but
you're right, it's only for associations (it wouldn't make sense in other
way). The strange thing is that now I try it with other entities with
similar associations and it works. I'll inspect the problem a little further
and I'll get back if I can find an answer.


Thanks a lot.

On Wed, Feb 9, 2011 at 11:11 AM, Christophe COEVOET <[email protected]> wrote:

> Le 09/02/2011 14:55, Gustavo Adrian a écrit :
>
>  Hi all,
>>
>> I'm wondering if I'm doing the right thing regarding validation of
>> associated entities. Suppose you have the following entities (simplified to
>> show you my point):
>>
>> /** @orm:Entity */
>> class Country
>> {
>>      // ..Some Fields
>> }
>>
>> /** @orm:Entity */
>> class State
>> {
>>      // Some Fields..
>>
>>      /**
>>       *
>>       * @orm:ManyToOne(targetEntity="Country")
>>       * @validation:Valid
>>       */
>>      protected $country;
>> }
>>
>>
>> Now, when I need to validate the State entity, suppose I do this
>> (simplified):
>>
>>
>> $country = $countryRepository->find( $countryID );
>>
>> $state->setCountry( $country );
>>
>> $resultOfValidation = $myValidator->validate( $state );
>>
>>
>> Result of validation contains errors on the "country" field, because the
>> country entity fields are not fully loaded (lazy load). So, I do this to
>> validate:
>>
>> $country = $countryRepository->find( $countryID );
>>
>> // To fully load the country, I try to access a field
>> $country->getName();
>>
>
> This seems weird. The lazy load only concerns the associations, not the
> fields of this entity so retrieving the country still loads these fields.
>
>
>
>> $state->setCountry( $country );
>>
>> // Now it validates OK
>> $resultOfValidation = $myValidator->validate( $state );
>>
>>
>> So, my question is: Am I doing the right thing regarding validation of
>> associations? if that's so, I use the "find" method of the entity repository
>> on my service to find the entity. Is there a way to fully load an entity
>> just once? I just need a fully loaded entity in these situations.
>>
>>
>
> --
> Christophe | Stof
>
> --
> If you want to report a vulnerability issue on symfony, please send it to
> security at symfony-project.com
>
> You received this message because you are subscribed to the Google
> Groups "symfony users" group.
> 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/symfony-users?hl=en
>

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
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/symfony-users?hl=en

Reply via email to