Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Nullable assocations for entity generator #287

merged 1 commit into from

3 participants


Hi all!
If an entity is identified thought another entity (using @association-key), this entity can't be nullable


Where is this situation applicable?
Looking at the patch seems that you are inspecting for @*ToOne(id="..."), which seems to be invalid.

  <entity name="EntA" table="ent">
    <id name="entb" type="integer" column="entb_id" association-key="true"/>
    <one-to-one field="entb" target-entity="EntB">
        <join-column name="entb_id" referenced-column-name="id"/>

this should generate something like this

clas EntA{
  function setEntB(EntB $entb){

but currently generate

clas EntA{
  function setEntB(EntB $entb = null){
@beberlei beberlei merged commit f040ed0 into doctrine:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 15, 2012
  1. @goetas

    nullable assoc

    goetas committed
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 0 deletions.
  1. +3 −0  lib/Doctrine/ORM/Tools/EntityGenerator.php
3  lib/Doctrine/ORM/Tools/EntityGenerator.php
@@ -707,6 +707,9 @@ private function _generateEntityStubMethods(ClassMetadataInfo $metadata)
private function _isAssociationIsNullable($associationMapping)
+ if (isset($associationMapping['id']) && $associationMapping['id']) {
+ return false;
+ }
if (isset($associationMapping['joinColumns'])) {
$joinColumns = $associationMapping['joinColumns'];
} else {
Something went wrong with that request. Please try again.