I am currently facing one problem with mapping I hope some one would helpe me. I have two table describe bellow.. unitid(primary_key, column_1) For example data here
unitid(1,22)
unitid (2,33)
mappaths(primary key, forign_key (column_1), forign_key(column_1))
For example data here
mappaths (1,22,33)
mappaths (2,33,22)
unitid has some kind of units defines while this mappaths table define the specific paths based on the unitid Now when I run the doctrain2 mapping It give me some kind these entities pluse these following mapping information
Entity class
<?php
namespace ApiMaps\ApiMapBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Mappaths
*
* @ORM\Table(name="mappaths", indexes={@ORM\Index(name="idx_45b7519fa3995845", columns={"ref_unitids1"}), @ORM\Index(name="idx_45b7519f3a9009ff", columns={"ref_unitids2"})})
* @ORM\Entity
*/
class Mappaths
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="SEQUENCE")
* @ORM\SequenceGenerator(sequenceName="mappaths_id_seq", allocationSize=1, initialValue=1)
*/
private $id;
/**
* @var integer
*
* @ORM\Column(name="normalvalue", type="smallint", nullable=true)
*/
private $normalvalue;
/**
*
* @var \Unitids
* @ORM\ManyToOne(targetEntity="Unitids",cascade={"all"},fetch="LAZY")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="ref_unitids2", referencedColumnName="databaseid")
* })
*/
private $refUnitids2;
/**
* @var \Unitids
* @ORM\ManyToOne(targetEntity="Unitids",cascade={"all"},fetch="LAZY")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="ref_unitids1", referencedColumnName="databaseid")
* })
*/
private $refUnitids1;
/**
* Set normalvalue
*
* @param integer $normalvalue
*
* @return Mappaths
*/
public function setNormalvalue($normalvalue)
{
$this->normalvalue = $normalvalue;
return $this;
}
/**
* Get normalvalue
*
* @return integer
*/
public function getNormalvalue()
{
return $this->normalvalue;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set refUnitids1
*
* @param \ApiMaps\ApiMapBundle\Entity\Unitids $refUnitids1
*
* @return Mappaths
*/
public function setRefUnitids1(\ApiMaps\ApiMapBundle\Entity\Unitids $refUnitids1 = null)
{
$this->refUnitids1 = $refUnitids1;
return $this;
}
/**
* Get refUnitids1
*
* @return \ApiMaps\ApiMapBundle\Entity\Unitids
*/
public function getRefUnitids1()
{
return $this->refUnitids1;
}
/**
* Set refUnitids2
*
* @param \ApiMaps\ApiMapBundle\Entity\Unitids $refUnitids2
*
* @return Mappaths
*/
public function setRefUnitids2(\ApiMaps\ApiMapBundle\Entity\Unitids $refUnitids2 = null)
{
$this->refUnitids2 = $refUnitids2;
return $this;
}
/**
* Get refUnitids2
*
* @return \ApiMaps\ApiMapBundle\Entity\Unitids
*/
public function getRefUnitids2()
{
return $this->refUnitids2;
}
}
and mappaths.php
<?php
namespace ApiMaps\ApiMapBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Mappaths
*
* @ORM\Table(name="mappaths", indexes={@ORM\Index(name="idx_45b7519fa3995845", columns={"ref_unitids1"}), @ORM\Index(name="idx_45b7519f3a9009ff", columns={"ref_unitids2"})})
* @ORM\Entity
*/
class Mappaths
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="SEQUENCE")
* @ORM\SequenceGenerator(sequenceName="mappaths_id_seq", allocationSize=1, initialValue=1)
*/
private $id;
/**
* @var integer
*
* @ORM\Column(name="normalvalue", type="smallint", nullable=true)
*/
private $normalvalue;
/**
*
* @var \Unitids
* @ORM\ManyToOne(targetEntity="Unitids",cascade={"all"},fetch="LAZY")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="ref_unitids2", referencedColumnName="databaseid")
* })
*/
private $refUnitids2;
/**
* @var \Unitids
* @ORM\ManyToOne(targetEntity="Unitids",cascade={"all"},fetch="LAZY")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="ref_unitids1", referencedColumnName="databaseid")
* })
*/
private $refUnitids1;
/**
* Set normalvalue
*
* @param integer $normalvalue
*
* @return Mappaths
*/
public function setNormalvalue($normalvalue)
{
$this->normalvalue = $normalvalue;
return $this;
}
/**
* Get normalvalue
*
* @return integer
*/
public function getNormalvalue()
{
return $this->normalvalue;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set refUnitids1
*
* @param \ApiMaps\ApiMapBundle\Entity\Unitids $refUnitids1
*
* @return Mappaths
*/
public function setRefUnitids1(\ApiMaps\ApiMapBundle\Entity\Unitids $refUnitids1 = null)
{
$this->refUnitids1 = $refUnitids1;
return $this;
}
/**
* Get refUnitids1
*
* @return \ApiMaps\ApiMapBundle\Entity\Unitids
*/
public function getRefUnitids1()
{
return $this->refUnitids1;
}
/**
* Set refUnitids2
*
* @param \ApiMaps\ApiMapBundle\Entity\Unitids $refUnitids2
*
* @return Mappaths
*/
public function setRefUnitids2(\ApiMaps\ApiMapBundle\Entity\Unitids $refUnitids2 = null)
{
$this->refUnitids2 = $refUnitids2;
return $this;
}
/**
* Get refUnitids2
*
* @return \ApiMaps\ApiMapBundle\Entity\Unitids
*/
public function getRefUnitids2()
{
return $this->refUnitids2;
}
}
now when I run the project it give me the following error
37. public static function missingPrimaryKeyValue($className, $idField)
38. {
39. return new self(sprintf("Missing value for primary key %s on %s", $idField, $className));
40. }
41. }
It seems to me that this primary key of unitsid could not get by mapping
Any solution would be appreciated