Difference between ObjectManager and EntityManager in Symfony2?

后端 未结 1 1703
时光取名叫无心
时光取名叫无心 2020-12-23 16:16

What\'s the difference between Doctrine\\Common\\Persistence\\ObjectManager and Doctrine\\ORM\\EntityManager when using it in a custom form type?

相关标签:
1条回答
  • 2020-12-23 16:44

    ObjectManager is an interface and EntityManager is its ORM implementation. It's not the only implementation; for example, DocumentManager from MongoDB ODM implements it as well. ObjectManager provides only the common subset of all its implementations.

    If you want your form type to work with any ObjectManager implementation, then use it. This way you could switch from ORM to ODM and your type would still work the same. But if you need something specific that only EntityManager provides and aren't planning to switch to ODM, use it instead.

    0 讨论(0)
提交回复
热议问题