[DDC-3272] EntityGenerator writes 'MappedSuperClass' instead of 'MappedSuperclass' Created: 26/Aug/14  Updated: 10/Sep/14  Resolved: 10/Sep/14

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Tools
Affects Version/s: 2.4.4
Fix Version/s: 2.5
Security Level: All

Type: Bug Priority: Minor
Reporter: Jakab Adam Balazs Assignee: Steve Müller
Resolution: Fixed Votes: 0
Labels: mappedsuperclass, orm, tools
Environment:

not relevant


Issue Links:
Dependency
depends on DDC-3302 [GH-1132] DDC-3272 entity generator m... Resolved

 Description   

In file doctrine/orm/lib/Doctrine/ORM/Tools/EntityGenerator.php, method: generateEntityDocBlock at line: 826, we have

$lines[] = ' * @' . $this->annotationsPrefix . 'MappedSuperClass';

but we do NOT have an annotation in Doctrine\ORM\Mapping called 'MappedSuperClass' but 'MappedSuperclass. (Notice the lowercase "c"!).

When using the generator, this generates the mapped superclass with wrong annotation resulting in

AnnotationException ::semanticalError ('The annotation "@Doctrine\ORM\Mapping\MappedSuperClass" in class Jab\Bundle\PlatformBundle\Entity\JabEntity does not exist, or could not be auto-loaded.')
in /home/data/WWW/localServer/test.bradipo/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php at line 706



 Comments   
Comment by Marco Pivetta [ 10/Sep/14 ]

Marked as minor issue: the entity generator is not the primary focus of the project.

Comment by Marco Pivetta [ 10/Sep/14 ]

Provided a hotfix at https://github.com/doctrine/doctrine2/pull/1132

Comment by Steve Müller [ 10/Sep/14 ]

Fixed in commit: https://github.com/doctrine/doctrine2/commit/b249aa9f652efdd36992ea542ccbd8e82f1b75be





[DDC-3061] [GH-996] [DDC-3027] Embedded in MappedSuperclass Created: 31/Mar/14  Updated: 15/May/14  Resolved: 15/May/14

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: None
Fix Version/s: 2.5
Security Level: All

Type: Bug Priority: Minor
Reporter: Doctrine Bot Assignee: Guilherme Blanco
Resolution: Fixed Votes: 0
Labels: mappedsuperclass, mapping


 Description   

This issue is created automatically through a Github pull request on behalf of coma:

Url: https://github.com/doctrine/doctrine2/pull/996

Message:

The fields from the MappedSuperclass embedded properties are getting mapped directly into the MappedSuperclass fields causing the error.

http://www.doctrine-project.org/jira/browse/DDC-3027



 Comments   
Comment by Doctrine Bot [ 30/Apr/14 ]

A related Github Pull-Request [GH-996] was closed:
https://github.com/doctrine/doctrine2/pull/996

Comment by Doctrine Bot [ 15/May/14 ]

A related Github Pull-Request [GH-1023] was closed:
https://github.com/doctrine/doctrine2/pull/1023





[DDC-2436] Inheritance on mappedSuperClass Created: 08/May/13  Updated: 10/May/13  Resolved: 10/May/13

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Improvement Priority: Major
Reporter: Petter Castro Assignee: Marco Pivetta
Resolution: Invalid Votes: 0
Labels: mappedsuperclass


 Description   

Sometimes is necessary some associations(many to many) in the mappedSuperClass. This associations should not be lost (inversedBy side and mappedBy ). The only one way to get this, was to implement an abstract class as Single Inheritance Table and then the mappedSuperClass inherit of this. But this is not optimum, because we are losing the OOP, creating classes which should not exist.

I realized of this when i was creating my bundle to be used for some projects, but I needed each project could extends from my class and add some properties or methods according their needs.

This is the link where you can see more details of this:

http://stackoverflow.com/questions/16405556/mapped-super-class-symfony2-2

Thanks for your attention.



 Comments   
Comment by Marco Pivetta [ 10/May/13 ]

Mapped superclasses cannot be referenced as they are only meant to provide some simplification by allowing inherited mappings in child classes.

If you want to enforce some kind of association in third party libraries, you can define interfaces and reference those: then, with a listener (during the onLoadMetadata event), replace the interfaces in mappings with (configured) concrete class names.

Comment by Petter Castro [ 10/May/13 ]

I did it, and everything worked perfectly. However, is there a way to dynamically change the "resolve_target_entities" inside my LoadClassMetadata or inside my php code?.
I would like the user makes this configurations with params from my bundle. In background, my bundle will configure these params for doctrine.
Could i do that?

Thanks again for your attention.

Comment by Petter Castro [ 10/May/13 ]

I was thinking in duplicate some code of yours. Exactly this one:

$def = $container->findDefinition('doctrine.orm.listeners.resolve_target_entity');
foreach ($config['resolve_target_entities'] as $name => $implementation) {
     $def->addMethodCall('addResolveTargetEntity', array(
     $name, $implementation, array()
     ));
}
Comment by Marco Pivetta [ 10/May/13 ]

That's exactly how this has to be done.

Comment by Petter Castro [ 10/May/13 ]

I did but there is a problem.... The service doctrine.orm.listeners.resolve_target_entity is not public. So i can't use it in my bundle. I wouldn't like to duplicate all code from this Service. How could I do?

Comment by Marco Pivetta [ 10/May/13 ]

That's an issue for the DoctrineBundle, not for the ORM.

Comment by Petter Castro [ 10/May/13 ]

Ok thanks a lot for your help. I will redirect my question to them.





[DDC-2157] @HasLifecycleCallbacks does not fire events when set on @MappedSuperclass Created: 20/Nov/12  Updated: 27/Nov/12  Resolved: 27/Nov/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.2.3
Fix Version/s: None
Security Level: All

Type: Bug Priority: Critical
Reporter: Frederic Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: HasLifecycleCallbacks, MappedSuperclass
Environment:

Windows 7 x64 / Apache 2.4.2 / MySQL server 5.1.62


Attachments: File DDC2157Test.php    

 Description   

I am unable to fire any of the "HasLifecycleCallbacks" when defined on a MappedSuperclass... (neither PreUpdate, PostUpdate,PrePersist, PostPersist and others)

I have even tried to put @ORM\HasLifecycleCallbacks on the child class with onPostRemove() on mapped => not working anymore

It only works when i put @ORM\HasLifecycleCallbacks and onPostRemove() both in child class "MyMappedTask"...

Is this a bug ..?

To reproduce :

<?php
namespace MyProject\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\MappedSuperclass
 * @ORM\HasLifecycleCallbacks
 */
class MyMappedTask
{
   /**
    * @ORM\PreRemove
    * @ORM\PostRemove
    * @ORM\PreUpdate
    * @ORM\PostUpdate
     */
    public function onPostRemove()
    {
        echo "here is never reached !";
    }
}

/**
 * @ORM\Entity(repositoryClass="MyProject\Repository\MyTaskRepository")
 * @ORM\Table()
 */
class MyTask extends MyMappedTask
{

}


 Comments   
Comment by Fabio B. Silva [ 22/Nov/12 ]

code format

Comment by Fabio B. Silva [ 22/Nov/12 ]

Hi Frederic,

It failed for all events or just for @PostRemove ?

Could you try to add a failing test case ?

Cheers

Comment by Frederic [ 23/Nov/12 ]

Hi Fabio,

1) Thank you for the "code" tag, i didn't know to do

2) Is fails with all the Annotations "Pre/Post*" ...

Did you try this test case ?

Thank you

Comment by Fabio B. Silva [ 23/Nov/12 ]

Hi Frederic,

Can't reproduce..
Could you try to change the attached test case and make it fails ?

Cheers

Comment by Frederic [ 27/Nov/12 ]

Hi Fabio,

Thank you for the test case, it is OK !

I found what the problem was :
I use Symfony2 and i have one bundle with the @MappedSuperclass entity and its callbacks (@HasLifecycleCallbacks), and another bundle with the child class (@Entity/@Table).
In that case, you must register the 2 bundles on the mappings (config.yml) otherwise it fails.
(I only registered the bundle which contains the child class but was not enough for Doctrine to understand...)

I don't know if it is a bug on Symfony2, not well documented in this case...

Thank you for all





Generated at Tue Oct 21 18:51:53 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.