[PR #10654] Deprecate usage of @JoinColumn on the inverse side of one-to-one associations #12520

Open
opened 2026-01-22 16:14:17 +01:00 by admin · 0 comments
Owner

Original Pull Request: https://github.com/doctrine/orm/pull/10654

State: closed
Merged: Yes


Following up on #10652:

Current situation

The implementation of \Doctrine\ORM\Mapping\ClassMetadataInfo::_validateAndCompleteOneToOneMapping will consider a field with a one-to-one association to be the owning side also when it configures @JoinColumn settings.

Suggested change

For a one to one association, a field should be the inverse side when it uses the mappedBy attribute, and be the owning side otherwise. The JoinColumn may be configured on the owning side only.

This PR adds a deprecation notice when @JoinColumn is used on the side of a one-to-one association where mappedBy occurs.

In 3.0, this will throw a MappingException.

**Original Pull Request:** https://github.com/doctrine/orm/pull/10654 **State:** closed **Merged:** Yes --- Following up on #10652: #### Current situation The implementation of `\Doctrine\ORM\Mapping\ClassMetadataInfo::_validateAndCompleteOneToOneMapping` will consider a field with a one-to-one association to be the owning side also when it configures `@JoinColumn` settings. #### Suggested change For a one to one association, a field should be the inverse side when it uses the `mappedBy` attribute, and be the owning side otherwise. The `JoinColumn` may be configured on the owning side only. This PR adds a deprecation notice when `@JoinColumn` is used on the side of a one-to-one association where `mappedBy` occurs. In 3.0, this will throw a `MappingException`.
admin added the pull-request label 2026-01-22 16:14:17 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#12520