Doctrine MongoDB ODM
  1. Doctrine MongoDB ODM
  2. MODM-75

mappedSuperclass and embedded document not working with yaml mapping

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.0.0BETA2
    • Component/s: Mapping Drivers
    • Labels:
      None

      Description

      all documents inherits from an abstract class Cgd\DomainObject\DomainObjectAbstract

      The document App\Entity\Contact\Contact has many App\Entity\Contact\Program

      abstract class Cgd\DomainObject\DomainObjectAbstract

      mappedSuperclass
      #Cgd.DomainObject.DomainObjectAbstract.dcm.yml
      Cgd\DomainObject\DomainObjectAbstract:
        type: mappedSuperclass
        fields:
          id:
            fieldName: id
            id: true
          createdAt:
            fieldName: createdAt
            type: date
          updatedAt:
            fieldName: updatedAt
            type: date
        lifecycleCallbacks:
          prePersist: [onPreInsert]
          preUpdate: [onPreUpdate]
      

      Here the inherited class

      class App\Entity\Contact\Contact extends Cgd\DomainObject\DomainObjectAbstract

      InheritedClass
      #App.Entity.Contact.Contact.dcm.yml
      App\Entity\Contact\Contact:
        collection: contacts
        type: document
        fields:
          email:
            fieldName: email
            type: string
          status:
            fieldName: status
            type: int
        embedMany:
          programs:
            targetDocument: App\Entity\Contact\Program
            cascade: all
      

      The embedded

      class App\Entity\Contact\Program extends Cgd\DomainObject\DomainObjectAbstract

      embeddedDocument
      #App.Entity.Contact.Program.dcm.yml
      App\Entity\Contact\Program:
        type: embeddedDocument
        fields:
          name:
            fieldName: name
            type: string
      

      No field from abstract class are populated in embedded document

        Activity

        Hide
        julien rollin added a comment -

        if i call

        $dm->persist($contact);
        $dm->flush();

        properties createdAt and updatedAt are saved to contact document only

        if i call

        $dm->persist($program);
        $dm->persist($contact);
        $dm->flush();

        properties createdAt and updatedAt are saved to contact and embedded documents.

        So is it the "cascade: all" property the problem ?

        Show
        julien rollin added a comment - if i call $dm->persist($contact); $dm->flush(); properties createdAt and updatedAt are saved to contact document only if i call $dm->persist($program); $dm->persist($contact); $dm->flush(); properties createdAt and updatedAt are saved to contact and embedded documents. So is it the "cascade: all" property the problem ?
        Hide
        Jonathan H. Wage added a comment -

        Are you using the absolute latest version from git? we made some changes recently to cascading and embedded documents. It is not necessary anymore to specify any cascading options as it does not make sense for embedded documents. it should and does cascade by default now for embedded documents.

        Show
        Jonathan H. Wage added a comment - Are you using the absolute latest version from git? we made some changes recently to cascading and embedded documents. It is not necessary anymore to specify any cascading options as it does not make sense for embedded documents. it should and does cascade by default now for embedded documents.
        Hide
        julien rollin added a comment - - edited

        yes i use the remote origin/master (i just did an update to de2e671201ef5a97e2a970f35cc94b5ad3590bb5)

        but actually, since your my comments and after yours, i got this beautiful fatal error (unknown before )

        Fatal error: Class Doctrine\ODM\MongoDB\Query\Lexer contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Doctrine\Common\Lexer::_getType) in D:\web\php\doctrine2-mongodb\lib\Doctrine\ODM\MongoDB\Query\Lexer.php on line 33

        edit : rechecking all dependencies (doctrine/common, etc )

        edit 2 : last checkout resolved cascade persist

        Show
        julien rollin added a comment - - edited yes i use the remote origin/master (i just did an update to de2e671201ef5a97e2a970f35cc94b5ad3590bb5) but actually, since your my comments and after yours, i got this beautiful fatal error (unknown before ) Fatal error: Class Doctrine\ODM\MongoDB\Query\Lexer contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Doctrine\Common\Lexer::_getType) in D:\web\php\doctrine2-mongodb\lib\Doctrine\ODM\MongoDB\Query\Lexer.php on line 33 edit : rechecking all dependencies (doctrine/common, etc ) edit 2 : last checkout resolved cascade persist

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            julien rollin
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: