mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
DDC-143: Add @MappedClass #179
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Nov 13, 2009).
Jira issue originally created by user reinier.kip:
At this moment Doctrine already knows the mapped superclass. A mapped superclass is an abstract or concrete class that provides persistent entity state and mapping information for its subclasses, but which is not itself an entity. I'd like to see something called the mapped class (or however you want to name it). For example, this means that when using class table inheritance classes that only provide (re)implementation of one or more methods they need not be stored in the database. They still, however, need to be mapped.
Another example is the inversion of the above: the subclasses only have a different implementation and do not have additional properties that need to be stored.
I hope this all makes sense.
@doctrinebot commented on GitHub (Dec 18, 2009):
Comment created by romanb:
"they need not be stored in the database. They still, however, need to be mapped"
Can you elaborate on that? As seen in the other ticket, it is well possible to have transient classes in a class table inheritance hierarchy.
And if you need classes in the middle of the hierarchy that are not mapped themselves but have mapping information for their children, a mapped superclass can be used in the middle of a hierarchy.
@doctrinebot commented on GitHub (Dec 18, 2009):
Comment created by reinier.kip:
We started this discussion in http://groups.google.com/group/doctrine-user/browse_thread/thread/9df8b3171968971d/7d42679d0d6e7c32 from post 5.
An simple example is the second example in the issue description.
'StringChanger' (whatever) has $string, which contains e.g. 'my first string!'. StringChanger#changeString()'s implementation replaces 'first' with 'second' and turns it into 'my second string!'.
AnotherStringChanger's implementation reverses the string instead of replacing 'first' with 'second'.
When stored in the database, a StringChanger would be stored like:
where StringChanger is the discriminator value
An AnotherStringChanger would be stored like:
So AnotherStringChanger does not add state, and is not stored in an additional table or in additional columns, it's only mapped.
If I recall correctly, this cannot be done with a mapped superclass. Am I right?
@doctrinebot commented on GitHub (Feb 28, 2010):
Comment created by @beberlei:
You can easily solve this by aggregation:
Now your Entity:
@doctrinebot commented on GitHub (Feb 28, 2010):
Issue was closed with resolution "Won't Fix"