Hi Cuong,

Could you please make an example of what is crashing? Did you also validate
your mappings?

Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/

On 2 December 2014 at 17:20, Cuong Nguyen <[email protected]> wrote:

> Hi everyone
> I try top update the exists entity by using entity merge, with another
> normal entity everything fine, but when i create the entities
> with Inheritance type SINGLE_TABLE,
> the entity merge just working with all the fields in mapper entity only,
> and all the parent class field cannot update. I'm already check the problem
> came from entity merge.
>
> Please check the code below, all the field in ProfilePersonEntity &
> ProfileCompanyEntity update after merge but all the field in ProfileEntity
> didn't update anything.
> Somebody can help to know where the problem came from, doctrine or my code.
>
> Thank you very much...
> Regards,
> Brian
>
> ProfileEntity.php
>
> namespace CMS\Entity;
>
> use Doctrine\ORM\Mapping\Entity;
> use Doctrine\ORM\Mapping\Table;
> use Doctrine\ORM\Mapping\InheritanceType;
> use Doctrine\ORM\Mapping\DiscriminatorColumn;
> use Doctrine\ORM\Mapping\DiscriminatorMap;
> use Doctrine\ORM\Mapping\Column;
> use Doctrine\ORM\Mapping\OneToMany;
> use Symfony\Component\Validator\Constraints as Assert;
> use Doctrine\Common\Collections\ArrayCollection;
>
> /**
>  * @Entity
>  * @Table(name="PROFILE")
>  * @InheritanceType("SINGLE_TABLE")
>  * @DiscriminatorColumn(name="type", type="string")
>  * @DiscriminatorMap({
>  *     "Profile" = "ProfileEntity",
>  *     "ProfilePerson" = "ProfilePersonEntity",
>  *     "ProfileCompany" = "ProfileCompanyEntity"
>  * })
>  */
> class ProfileEntity extends LockableEntity {
>
> /**
>  * @Column(name="TYPE", type="string", length=15)
>  * @Assert\NotBlank
>  */
> private $type;
>     /**
>      * @Column(name="NAME", type="string", length=45)
>      * @Assert\NotBlank
>      */
>     private $name;
>
>     /**
>      * @Column(name="PLACE_OF_ISSUE", type="string", length=45)
>      */
>     private $placeOfIssue;
>
>     /**
>      * @Column(name="DATE_OF_ISSUE", type="timestamp")
>      */
>     private $dateOfIssue;
>
>     /**
>      * @Column(name="NATIONALITY", type="string", length=3)
>      */
>     private $nationality;
>
>     /**
>      * @OneToMany(targetEntity="PhoneEntity", mappedBy="profile",
> cascade={"all"})
>      */
>     private $phones;
>
>     /**
>      * @OneToMany(targetEntity="EmailEntity", mappedBy="profile",
> cascade={"all"})
>      */
>     private $emails;
>
>     /**
>      * @OneToMany(targetEntity="WebsiteEntity", mappedBy="profile",
> cascade={"all"})
>      */
>     private $websites;
>
>     /**
>      * @OneToMany(targetEntity="AddressProfileEntity", mappedBy="profile",
> cascade={"all"})
>      */
>     private $addresses;
>
>
>     public function __construct() {
>     $this->phones = new ArrayCollection();
>     $this->emails = new ArrayCollection();
>     $this->websites = new ArrayCollection();
>     $this->addresses = new ArrayCollection();
>     }
>
>
>     public function getType() {
>     return $this->type;
>     }
>     public function setType($type) {
>     $this->type = $type;
>     }
>
>     public function getName() {
>         return $this->name;
>     }
>     public function setName($name) {
>         $this->name = $name;
>     }
>
>     public function getPlaceOfIssue() {
>     return $this->placeOfIssue;
>     }
>     public function setPlaceOfIssue($placeOfIssue) {
>     $this->placeOfIssue = $placeOfIssue;
>     }
>
>     public function getDateOfIssue() {
>     return $this->dateOfIssue;
>     }
>     public function setDateOfIssue($dateOfIssue) {
>     $this->dateOfIssue = $dateOfIssue;
>     }
>
>     public function getNationality() {
>     return $this->nationality;
>     }
>     public function setNationality($nationality) {
>     $this->nationality = $nationality;
>     }
>
>     public function getPhones() {
>     return $this->phones;
>     }
>     public function setPhones($phones) {
>     $this->phones = $phones;
>     }
>
>     public function getEmails() {
>     return $this->emails;
>     }
>     public function setEmails($emails) {
>     $this->emails = $emails;
>     }
>
>     public function getWebsites() {
>     return $this->websites;
>     }
>     public function setWebsites($websites) {
>     $this->websites = $websites;
>     }
>
>     public function getAddresses() {
>     return $this->addresses;
>     }
>     public function setAddresses($addresses) {
>     $this->addresses = $addresses;
>     }
>
>     public function getFullname() {
>     return (method_exists($this, 'getLastName') ? $this->getLastName().'
> ' : '').$this->name;
>     }
>
> }
>
>
> ==============================================================================================
> ProfilePersonEntity.php
>
> namespace CMS\Entity;
>
> use Doctrine\ORM\Mapping\Entity;
> use Doctrine\ORM\Mapping\Column;
>
> /**
>  * @Entity
>  */
> class ProfilePersonEntity extends ProfileEntity {
>
> /**
>  * @Column(name="LAST_NAME", type="string", length=45)
>  */
> private $lastName;
>
> /**
>  * @Column(name="GENDER", type="string", length=9)
>  */
> private $gender;
>
> /**
>  * @Column(name="BIRTHDAY", type="timestamp")
>  */
> private $birthday;
>
> /**
>  * @Column(name="IDENTITY_NUMBER", type="string", length=45)
>  */
> private $identityNumber;
>
> /**
>  * @Column(name="PASSPORT_NUMBER", type="string", length=45)
>  */
> private $passportNumber;
>
>
> public function __construct() {}
>
>
> public function getLastName() {
> return $this->lastName;
> }
> public function setLastName($lastName) {
> $this->lastName = $lastName;
> }
>
> public function getGender() {
> return $this->gender;
> }
> public function setGender($gender) {
> $this->gender = $gender;
> }
>
> public function getBirthday() {
> return $this->birthday;
> }
> public function setBirthday($birthday) {
> $this->birthday = $birthday;
> }
>
> public function getIdentityNumber() {
> return $this->identityNumber;
> }
> public function setIdentityNumber($identityNumber) {
> $this->identityNumber = $identityNumber;
> }
>
> public function getPassportNumber() {
> return $this->passportNumber;
> }
> public function setPassportNumber($passportNumber) {
> $this->passportNumber = $passportNumber;
> }
>
> }
>
>
> ==============================================================================================
> ProfileCompanyEntity.php
>
> namespace CMS\Entity;
>
> use Doctrine\ORM\Mapping\Entity;
> use Doctrine\ORM\Mapping\Column;
>
> /**
>  * @Entity
>  */
> class ProfileCompanyEntity extends ProfileEntity {
>
> /**
>  * @Column(name="ENGLISH_NAME", type="string", length=45)
>  */
> private $englishName;
>
> /**
>  * @Column(name="TAX_CODE", type="string", length=45)
>  */
> private $taxCode;
>
> /**
>  * @Column(name="BUSINESS_REGISTRATION_CODE", type="string", length=45)
>  */
> private $businessRegistrationCode;
>
>
> public function __construct() {}
>
>
> public function getEnglishName() {
> return $this->englishName;
> }
> public function setEnglishName($englishName) {
> $this->englishName = $englishName;
> }
>
> public function getTaxCode() {
> return $this->taxCode;
> }
> public function setTaxCode($taxCode) {
> $this->taxCode = $taxCode;
> }
>
> public function getBusinessRegistrationCode() {
> return $this->businessRegistrationCode;
> }
> public function setBusinessRegistrationCode($businessRegistrationCode) {
> $this->businessRegistrationCode = $businessRegistrationCode;
> }
>
> }
>
> --
> You received this message because you are subscribed to the Google Groups
> "doctrine-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/doctrine-user.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to