Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-416

[patch] findBy() and @InheritanceType("JOINED")

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-ALPHA4
    • Fix Version/s: 2.0-BETA1
    • Component/s: DQL, ORM
    • Security Level: All
    • Labels:
      None

      Description

      My tables:

      /**
       * @Entity
       * @Table(name="inventory_system")
       */
      class inventorySystem extends privateInventoryBasic
      {
          /**
           * @Column(name="name", type="string", length=255, nullable=true)
           */
          protected $name;
      
          /**
           * @Column(name="serial", type="string", length=255, nullable=true)
           */
          protected $serial;
      
          /**
           * @Column(name="boot", type="string", length=255, nullable=true)
           */
          protected $boot;
      
          /**
           * @Column(name="chassis", type="string", length=255, nullable=true)
           */
          protected $chassis;
      
          /**
           * @Column(name="smbios", type="string", length=255, nullable=true)
           */
          protected $smbios;
      
          /**
           * @Column(name="dmi", type="string", length=255, nullable=true)
           */
          protected $dmi;
      
          /**
           * @Column(name="bits", type="smallint", nullable=true)
           */
          protected $bits;
      
          /**
           * @Column(name="uuid", type="string", length=255, nullable=true)
           */
          protected $uuid;
      
      /**
       * @Entity
       * @InheritanceType("JOINED") 
       * @DiscriminatorColumn(name="discr", type="smallint")
       * @DiscriminatorMap({
       * "0" = "privateInventoryBasic",
       * "1" = "inventorySystem", 
       * "2" = "inventoryBattery",
       * "3" = "inventoryBus",
       * "4" = "inventoryCache",
       * "5" = "inventoryCdrom",
       * "6" = "inventoryCpu",
       * "7" = "inventoryDisk",
       * "8" = "inventoryDisplay",
       * "9" = "inventoryFirmware",
       * "10" = "inventoryMemory",
       * "11" = "inventoryMemoryBank",
       * "12" = "inventoryMemoryController",
       * "13" = "inventoryMultimedia",
       * "14" = "inventoryNetwork",
       * "15" = "inventoryPciHostBridge",
       * "16" = "inventoryStorage",
       * "17" = "inventorySystem",
       * "18" = "inventoryUsbBus",
       * "19" = "inventoryUsbGeneric",
       * "20" = "inventoryUsbHost",
       * "21" = "inventoryVolume"
       * })
       * @Table(name="private_inventory_basic")
       * @HasLifecycleCallbacks 
       */
      class privateInventoryBasic
      {  	
      	static function getSearchFieldList()
      	{
      		return array('vendor', 'product', 'description', 'version');
      	}
          /**
           * @Id
           * @Column(name="id", type="integer")
           * @GeneratedValue(strategy="AUTO")
           */
          private $id;
               
          /**
           * @Column(name="product", type="string", length=255, nullable=true)
           */
          private $product;
      
          /**
           * @Column(name="vendor", type="string", length=255, nullable=true)
           */
          private $vendor;
      
          /**
           * @Column(name="version", type="string", length=255, nullable=true)
           */
          private $version;
      
          /**
           * @Column(name="businfo", type="string", length=255, nullable=true)
           */
          private $businfo;
      
          /**
           * @Column(name="capabilities", type="bigint", nullable=true)
           */
          private $capabilities;
      
          /**
           * @Column(name="num", type="string", length=255, nullable=true)
           */
          private $num;
      
          /**
           * @Column(name="comment", type="string", length=255, nullable=true)
           */
          private $comment;
      
          /**
           * @Column(name="physid", type="string", length=255, nullable=true)
           */
          private $physid;
      
          /**
           * @Column(name="driver", type="string", length=255, nullable=true)
           */
          private $driver;
      
          /**
           * @Column(name="driver_version", type="string", length=255, nullable=true)
           */
          private $driverversion;
      
          /**
           * @Column(name="description", type="string", length=255, nullable=true)
           */
          private $description;
      
          /**
           * @Column(name="xml_id", type="string", length=255, nullable=true)
           */
          private $xmlId;
          
          /**
           * @ManyToOne(targetEntity="basicHost",  cascade={"all"}, fetch="EAGER")
           * @JoinColumn(name="host_id", referencedColumnName="id", onDelete="CASCADE", onUpdate="CASCADE", nullable=true)
           */
          private $hostId;
          private $hostIdValue;
          
          /**
           * @Column(name="class", type="string", length=255, nullable=true)
           */
          private $class;
      
          /**
           * @Column(name="handle", type="string", length=16, nullable=true)
           */
          private $handle;
      
          /**
           * @Column(name="parent_handle", type="string", length=16, nullable=true)
           */
          private $parentHandle;
      

      hostId and xmlId are the fields of parent table.
      This code gets error:

      $dbObj = $em->getRepository('inventorySystem')->findOneBy(array('hostId' => $hostId, 'xmlId' => $xmlId))

      This code gets no error:

      $dbObj = $em->getRepository('inventorySystem')->findOneBy(array('name' => $name))
      1) Shelly_Core_Task_DaemonTest::testRun
      PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'i0.hostId' in 'where clause'
      
      /var/www/shelly/library/Doctrine/ORM/Persisters/StandardEntityPersister.php:443
      /var/www/shelly/library/Doctrine/ORM/EntityRepository.php:143
      /var/www/shelly/application/library/Shelly/Core/Task/Lshw/Xml/Parser.php:44
      /var/www/shelly/application/library/Shelly/Core/Task/Basic/Host/Lshw.php:12
      /var/www/shelly/application/library/Shelly/Core/Task/Daemon.php:125
      /var/www/shelly/tests/library/Shelly/Core/Task/DaemonTest.php:37
      
      1. broken-patch.diff
        6 kB
        Guilherme Blanco
      2. joinColumnWithInherit.patch
        6 kB
        Uvarov Michael

        Activity

        Hide
        Uvarov Michael added a comment -

        Ok. Thank you. I will rewrite this patch. I need some time for install the unit tests.

        Show
        Uvarov Michael added a comment - Ok. Thank you. I will rewrite this patch. I need some time for install the unit tests.
        Hide
        Uvarov Michael added a comment - - edited

        Create new diff.
        Before patch and after one

        PHPUnit 3.4.11 by Sebastian Bergmann.
        
        ......................................SSSSSSS.......SSSSSSSS  60 / 940
        SSSSSS.........................S.S.......................... 120 / 940
        ............................................................ 180 / 940
        ............................................................ 240 / 940
        ............................................E..EEE.......... 300 / 940
        ...SSSSSSSSSSSSSS..........SSSSSSSSSSSSSSSSSSSSSSS.......... 360 / 940
        ............................................................ 420 / 940
        ............................................................ 480 / 940
        ............................................................ 540 / 940
        ............................................................ 600 / 940
        ............................................................ 660 / 940
        ............................................................ 720 / 940
        ............................................................ 780 / 940
        ............................................................ 840 / 940
        ............................................................ 900 / 940
        SSSS....................................
        
        Time: 02:18, Memory: 79.50Mb
        
        There were 4 errors:
        
        1) Doctrine\Tests\DBAL\DriverManagerTest::testValidPdoInstance
        PDOException: could not find driver
        
        /var/www/doctrine/trunk/tests/Doctrine/Tests/DBAL/DriverManagerTest.php:23
        
        2) Doctrine\Tests\DBAL\DriverManagerTest::testCustomPlatform
        PDOException: could not find driver
        
        /var/www/doctrine/trunk/tests/Doctrine/Tests/DBAL/DriverManagerTest.php:49
        
        3) Doctrine\Tests\DBAL\DriverManagerTest::testCustomWrapper
        PDOException: could not find driver
        
        /var/www/doctrine/trunk/tests/Doctrine/Tests/DBAL/DriverManagerTest.php:63
        
        4) Doctrine\Tests\DBAL\DriverManagerTest::testInvalidWrapperClass
        PDOException: could not find driver
        
        /var/www/doctrine/trunk/tests/Doctrine/Tests/DBAL/DriverManagerTest.php:76
        
        FAILURES!
        Tests: 940, Assertions: 2476, Errors: 4, Skipped: 64.
        
        Show
        Uvarov Michael added a comment - - edited Create new diff. Before patch and after one PHPUnit 3.4.11 by Sebastian Bergmann. ......................................SSSSSSS.......SSSSSSSS 60 / 940 SSSSSS.........................S.S.......................... 120 / 940 ............................................................ 180 / 940 ............................................................ 240 / 940 ............................................E..EEE.......... 300 / 940 ...SSSSSSSSSSSSSS..........SSSSSSSSSSSSSSSSSSSSSSS.......... 360 / 940 ............................................................ 420 / 940 ............................................................ 480 / 940 ............................................................ 540 / 940 ............................................................ 600 / 940 ............................................................ 660 / 940 ............................................................ 720 / 940 ............................................................ 780 / 940 ............................................................ 840 / 940 ............................................................ 900 / 940 SSSS.................................... Time: 02:18, Memory: 79.50Mb There were 4 errors: 1) Doctrine\Tests\DBAL\DriverManagerTest::testValidPdoInstance PDOException: could not find driver / var /www/doctrine/trunk/tests/Doctrine/Tests/DBAL/DriverManagerTest.php:23 2) Doctrine\Tests\DBAL\DriverManagerTest::testCustomPlatform PDOException: could not find driver / var /www/doctrine/trunk/tests/Doctrine/Tests/DBAL/DriverManagerTest.php:49 3) Doctrine\Tests\DBAL\DriverManagerTest::testCustomWrapper PDOException: could not find driver / var /www/doctrine/trunk/tests/Doctrine/Tests/DBAL/DriverManagerTest.php:63 4) Doctrine\Tests\DBAL\DriverManagerTest::testInvalidWrapperClass PDOException: could not find driver / var /www/doctrine/trunk/tests/Doctrine/Tests/DBAL/DriverManagerTest.php:76 FAILURES! Tests: 940, Assertions: 2476, Errors: 4, Skipped: 64.
        Hide
        Roman S. Borschel added a comment -

        This should now be fixed in trunk.

        Please create a new issue for the "double left join" problem.

        Show
        Roman S. Borschel added a comment - This should now be fixed in trunk. Please create a new issue for the "double left join" problem.
        Hide
        Uvarov Michael added a comment -

        Thank you.
        Double left join is my error: I left join inventorySystem twice: in 1 and in 17

        • "0" = "privateInventoryBasic",
        • "1" = "inventorySystem",
        • "2" = "inventoryBattery",
        • "3" = "inventoryBus",
        • "4" = "inventoryCache",
        • "5" = "inventoryCdrom",
        • "6" = "inventoryCpu",
        • "7" = "inventoryDisk",
        • "8" = "inventoryDisplay",
        • "9" = "inventoryFirmware",
        • "10" = "inventoryMemory",
        • "11" = "inventoryMemoryBank",
        • "12" = "inventoryMemoryController",
        • "13" = "inventoryMultimedia",
        • "14" = "inventoryNetwork",
        • "15" = "inventoryPciHostBridge",
        • "16" = "inventoryStorage",
        • "17" = "inventorySystem",
        • "18" = "inventoryUsbBus",
        • "19" = "inventoryUsbGeneric",
        • "20" = "inventoryUsbHost",
        • "21" = "inventoryVolume"
        Show
        Uvarov Michael added a comment - Thank you. Double left join is my error: I left join inventorySystem twice: in 1 and in 17 "0" = "privateInventoryBasic", "1" = "inventorySystem", "2" = "inventoryBattery", "3" = "inventoryBus", "4" = "inventoryCache", "5" = "inventoryCdrom", "6" = "inventoryCpu", "7" = "inventoryDisk", "8" = "inventoryDisplay", "9" = "inventoryFirmware", "10" = "inventoryMemory", "11" = "inventoryMemoryBank", "12" = "inventoryMemoryController", "13" = "inventoryMultimedia", "14" = "inventoryNetwork", "15" = "inventoryPciHostBridge", "16" = "inventoryStorage", "17" = "inventorySystem", "18" = "inventoryUsbBus", "19" = "inventoryUsbGeneric", "20" = "inventoryUsbHost", "21" = "inventoryVolume"
        Hide
        Roman S. Borschel added a comment -

        Please create a new jira issue for that problem. Thanks.

        Show
        Roman S. Borschel added a comment - Please create a new jira issue for that problem. Thanks.

          People

          • Assignee:
            Roman S. Borschel
            Reporter:
            Uvarov Michael
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: