Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doctrine Proxy Class Serialization #34

Closed
leevigraham opened this issue Sep 25, 2011 · 7 comments
Closed

Doctrine Proxy Class Serialization #34

leevigraham opened this issue Sep 25, 2011 · 7 comments

Comments

@leevigraham
Copy link

Hey guys,

I think I've setup the bundle correctly using the instructions in the FOS Rest bundle documentation. However when viewing either .xml or .json I get the following error:

[Semantical Error] The annotation "@OverRide" in method Doctrine\ORM\Mapping\ClassMetadataInfo::_validateAndCompleteOneToOneMapping() was never imported.

I'm using Symfony2 Standard with the master branch of the metadata bundle.

Here's my full config.yml, stacktrace and deps files: https://gist.github.com/1240315

Any help would be appreciated.

Cheers Leevi

@leevigraham
Copy link
Author

Strangely removing the @OverRide comment from the ClassMetadataInfo class results in a timeout.

@stof
Copy link
Contributor

stof commented Sep 25, 2011

upgrade Doctrine Common to the 2.1.x branch instead of the 2.1.1 release. This annotation is now ignored by default

@schmittjoh
Copy link
Owner

As discussed on IRC, the main problem here is that Doctrine generates a proxy object to allow a relation to be lazy-loaded. The possible solutions to this are:

  1. Either exclude the relation if you don't want to serialize it, or actively query the relation from the database.
  2. Use a pre-serialize callback to initialize the relation (more of a workaround)

I'll leave this ticket open for reference, not sure if we can find, or need a better solution.

@leevigraham
Copy link
Author

Thanks for checking this out guys.

@stefanosala
Copy link

Hi,
same issue here.
Isn't it possible to call a "wake up" method to fetch the related object and serialize it insted of Doctrine Proxy class?

@stefanosala
Copy link

I managed to solve it by specifing a exclusion_policy: ALL for my Proxy class (FooBundleEntityUserProxy).
Don't know if this is the best method.

@schmittjoh
Copy link
Owner

Proxies should now be initialized automatically thanks to @yethee. Please try out the latest version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants