I have some problems with 2 tables relation with Symfony
NucleiStastiche1M contain time-series data of Nuclei..
One Nuclei can have many rows oof NucleiStatistiche1M
Nuclei SQL
CREATE TABLE public.nuclei
(
id integer NOT NULL,
nome character varying,
cognome character varying
)
NucleiStatistiche1M SQL
CREATE TABLE public.nucleistatistiche1m
(
id integer NOT NULL,
dataora timestamp NOT NULL,
value1 character varying
value2 character varying
)
I defined the relationship on Symfony so
Nuclei.php
/**
* @var NucleiStatistiche1M
*
* @ORM\OneToMany(targetEntity="NucleiStatistiche1M", mappedBy="nucleo")
* @ORM\JoinColumn(name="id", referencedColumnName="id")
*
*/
private $statistiche1M;
public function __construct()
{
$this->statistiche1M = new ArrayCollection();
}
/**
* @return Collection|NucleiStatistiche1M[]
*/
public function getStatistiche1M(): Collection
{
return $this->statistiche1M;
}
NucleStatistiche1M.php
/**
* @var Nuclei
*
* @ORM\ManyToOne(targetEntity="Nuclei", inversedBy="statistiche1M")
* @ORM\JoinColumn(name="id", referencedColumnName="id")
*
*/
private $nucleo;
When i join the 2 tables i only get 1 record.. I do something like
$qb = $em->createQueryBuilder()
->select('n, t, u, ns, ns1m, ts')
->from('App\Entity\Nuclei','n')
->leftJoin('n.statistiche1M', 'ns1m');
I expect many record i don't undestand where is the problem, the only problema i think is the joined table have same value on ID
thanks