Is lazyloaded Collection supposed to be initialized when passed into QueryBuilder::setParameter? #10280
-
This is my setup: #[ORM\Entity(repositoryClass: ReportRepository::class)]
#[ORM\InheritanceType("JOINED")]
#[ORM\DiscriminatorColumn(name: "type", type: "report_type")]
#[ORM\DiscriminatorMap([
"payment_request" => PaymentRequestReport::class,
])]
abstract class Report
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: "integer")]
private int $id;
public function getId(): int
{
return $this->id;
}
} #[ORM\Entity(repositoryClass: PaymentRequestReportRepository::class)]
class PaymentRequestReport extends Report
{
#[ORM\ManyToMany(targetEntity: PaymentModule::class)]
#[ORM\JoinTable(name: 'report_payment_request_payment_module')]
private Collection $paymentModules;
public function __construct()
{
$this->paymentModules = new ArrayCollection();
}
public function getPaymentModules(): Collection
{
return $this->paymentModules;
}
public function addPaymentModule(PaymentModule $paymentModule): self
{
if (!$this->paymentModules->contains($paymentModule)) {
$this->paymentModules[] = $paymentModule;
}
return $this;
}
public function removePaymentModule(PaymentModule $paymentModule): self
{
$this->paymentModules->removeElement($paymentModule);
return $this;
}
} I fetch one Report (of the PaymentRequest type) $report = $this->entityManager
->createQueryBuilder()
->select('r')
->from(Report::class, 'r')
->where('r.id = :reportId')
->setParameter('reportId', 1)
->setMaxResults(1)
->getQuery()
->getSingleResult(); when checking in debugger, this is of type When I later use $transactionsQuery = $this->entityManager
->createQueryBuilder()
->select('t')
->from(Transaction::class, 't')
->where('t.paymentModule IN (:paymentModules)')
->setParameter('paymentModules', $report->getPaymentModules())
->getQuery(); this returns 0 results. After digging in with debugger, it seems that Is this normal? What approach should I use to pass the list of PaymentModules to the transaction query? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
this was an implementation application logic bug on my side, Ive even created orm test to try to reproduce the case and doctrine works without issues. |
Beta Was this translation helpful? Give feedback.
this was an implementation application logic bug on my side, Ive even created orm test to try to reproduce the case and doctrine works without issues.