DDC-1437: Strange behavior with proxied classes,expected to get entity, but returned identifier. #2063

Closed
doctrinebot opened this Issue Oct 19, 2011 · 3 comments

2 participants

@doctrinebot

Jira issue originally created by user goetas:

I have the following xml mapping:

User:
  <entity name="User" table="user">
    <id name="id" type="integer" column="id">
      <generator strategy="SEQUENCE"/>
    </id>
    <field name="name" type="string" column="name"/>
   </entity>

SuperUser:
  <entity name="SuperUser" table="superuser">

    <id name="user" type="integer" column="user_id" association-key="true"/>

    <one-to-one field="user" target-entity="User">
      <join-columns>
        <join-column name="user_id" referenced-column-name="id"/>
      </join-columns>
    </one-to-one>

  </entity>

From this mapping i have generated the php classes.

In my application, when the SuperUser class is proxied, SuperUser::getUser() method looks like this:

public function getUser(){

        if ($this->*_isInitialized_* === false) {
            return $this->_identifier["user"];
        }
        $this->**load();
        return parent::getUser();
}

When i call $usperuser->getUser() the expected return value is the User class instance; but the current implementation returns only user id (contained in $this->_identifier["user"]).

In this behavior is also involved private function ProxyFactory::isShortIdentifierGetter($method, $class)

Some solutions proposed by me, can be:

  • remove this behavior
  • during proxy generation, add in this case a method called getUserId, and this method can return user id (but in this case, the behavior continues to be strange because is available only for proxied classes).

(sorry for my english)

@doctrinebot

Comment created by @beberlei:

very recent bug in master, i will fix it.

@doctrinebot

Comment created by @beberlei:

fixed in master

@doctrinebot

Issue was closed with resolution "Fixed"

@beberlei beberlei was assigned by doctrinebot Dec 6, 2015
@doctrinebot doctrinebot added this to the 2.2 milestone Dec 6, 2015
@doctrinebot doctrinebot closed this Dec 6, 2015
@doctrinebot doctrinebot added the Bug label Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment