Skip to content

Commit

Permalink
Merge branch 'hotfix/#1257-discriminator-map-changes-documentation'
Browse files Browse the repository at this point in the history
  • Loading branch information
Ocramius committed Jan 24, 2015
2 parents 2253304 + 52fb4e5 commit 3f360d7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
16 changes: 16 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Upgrade to 2.5

## Minor BC BREAK: discriminator map must now include all non-transient classes

It is now required that you declare the root of an inheritance in the
discriminator map.

When declaring an inheritance map, it was previously possible to skip the root
of the inheritance in the discriminator map. This was actually a validation
mistake by Doctrine2 and led to problems when trying to persist instances of
that class.

If you don't plan to persist instances some classes in your inheritance, then
either:

- make those classes `abstract`
- map those classes as `MappedSuperclass`

## Minor BC BREAK: ``EntityManagerInterface`` instead of ``EntityManager`` in type-hints

As of 2.5, classes requiring the ``EntityManager`` in any method signature will now require
Expand Down
19 changes: 19 additions & 0 deletions docs/en/changelog/migration_2_5.rst
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,25 @@ Hydrators are per query instantiated since Doctrine 2.4.

- `DDC-3060 <http://doctrine-project.org/jira/browse/DDC-3060>`_

Minor BC BREAK: All non-transient classes in an inheritance must be part of the inheritance map
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

As of 2.5, classes, if you define an inheritance map for an inheritance tree, you are required
to map all non-transient classes in that inheritance, including the root of the inheritance.

So far, the root of the inheritance was allowed to be skipped in the inheritance map: this is
not possible anymore, and if you don't plan to persist instances of that class, then you should
either:

- make that class as ``abstract``
- add that class to your inheritance map

If you fail to do so, then a ``Doctrine\ORM\Mapping\MappingException`` will be thrown.


- `DDC-3300 <http://doctrine-project.org/jira/browse/DDC-3300>`_
- `DDC-3503 <http://doctrine-project.org/jira/browse/DDC-3503>`_

Minor BC BREAK: Entity based EntityManager#clear() calls follow cascade detach
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down

5 comments on commit 3f360d7

@TomasVotruba
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not very clear to me. Not sure what to to differently now. I got stuck with interface, which lead me here.

Could you add some before/after example?

@Ocramius
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TomasVotruba you simply have to make sure that the root of the inheritance is also in the inheritance map.

@TomasVotruba
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ocramius I use it without this on ORM 2.5 and still got no issue, that's why I'm confused.

@Ocramius
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TomasVotruba in 2.4.x (and before) the discriminator map didn't require abstract types.

@TomasVotruba
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ocramius I have the same experience in 2.4 and 2.5, with no abstract types mentioned.

Please sign in to comment.