Symfony2 Doctrine duplicate primary key - symfony

For one of my entities I can suddenly not add records to a specific table. The insert statement is ok, the problem is in the primary key, and that should be handled entirely by doctrine, I have no code to meddle with that. So I am at a loss as to what is actually happening here...
Is this a known effect of something other, PHP/db versions etc.?
... code for setting values of $extraOpening's properties ...
$em = $this->getDoctrine()->getManager();
$em->persist($extraOpening);
$em->flush($extraOpening);
[2017-09-18 11:05:47] request.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\Exception\UniqueConstraintViolationException: "An exception occurred while executing 'INSERT INTO extra_opening (open, close, arrOrDep, callsign, reason, additional, separateOpening, comment, price, debit_period) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' with params ["2017-09-08 10:50:00", "2017-09-08 10:50:00", "Ospec.", null, "mw test", null, 1, null, 1034, 117]: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '0' for key 'PRIMARY'"
--- UPDATE 2 ---
Adding my entity (the little update I just posted was wrong, so disregard if you had time to read it...).
I moved DB using phpmyadmin export and the same tool for import. Perhaps I did a setting wrong relating to relations or pKeys, but I've done it a hundred times and did nothing out of the defaults...
namespace ExtraOpeningBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* ExtraOpening
*
* #ORM\Table(name="extra_opening")
* #ORM\Entity(repositoryClass="ExtraOpeningBundle\Repository\ExtraOpeningRepository")
*/
class ExtraOpening
{
/**
* #var int
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var \DateTime
*
* #ORM\Column(name="open", type="datetime")
*/
private $open;
/**
* #var \DateTime
*
* #ORM\Column(name="close", type="datetime")
*/
private $close;
/**
* #var string
*
* #ORM\Column(name="arrOrDep", type="string", length=6, nullable=true)
*/
private $arrOrDep;
/**
* #var string
*
* #ORM\Column(name="callsign", type="string", length=30, nullable=true)
*/
private $callsign;
/**
* #var string
*
* #ORM\Column(name="reason", type="string", length=255, nullable=true)
*/
private $reason;
/**
* #var int
*
* #ORM\Column(name="additional", type="integer", nullable=true)
*/
private $additional;
/**
* #var bool
*
* #ORM\Column(name="separateOpening", type="boolean")
*/
private $separateOpening;
/**
* #var string
*
* #ORM\Column(name="comment", type="text", nullable=true)
*/
private $comment;
/**
* #var int
*
* #ORM\Column(name="price", type="integer", nullable=true)
*/
private $price;
/**
* #var object \ExtraOpeningBundle\Entity\DebitPeriod
*
* #ORM\ManyToOne(targetEntity="\ExtraOpeningBundle\Entity\DebitPeriod", inversedBy="extraOpenings")
* #ORM\JoinColumn(name="debit_period", referencedColumnName="id", nullable=false)
*/
protected $debitPeriod;
/**
* Get id
*
* #return int
*/
public function getId()
{
return $this->id;
}
/**
* Set open
*
* #param \DateTime $open
*
* #return ExtraOpening
*/
public function setOpen($open)
{
$this->open = $open;
return $this;
}
/**
* Get open
*
* #return \DateTime
*/
public function getOpen()
{
return $this->open;
}
/**
* Set close
*
* #param \DateTime $close
*
* #return ExtraOpening
*/
public function setClose($close)
{
$this->close = $close;
return $this;
}
/**
* Get close
*
* #return \DateTime
*/
public function getClose()
{
return $this->close;
}
/**
* Set arrOrDep
*
* #param string $arrOrDep
*
* #return ExtraOpening
*/
public function setArrOrDep($arrOrDep)
{
$this->arrOrDep = $arrOrDep;
return $this;
}
/**
* Get arrOrDep
*
* #return string
*/
public function getArrOrDep()
{
return $this->arrOrDep;
}
/**
* Set callsign
*
* #param string $callsign
*
* #return ExtraOpening
*/
public function setCallsign($callsign)
{
$this->callsign = $callsign;
return $this;
}
/**
* Get callsign
*
* #return string
*/
public function getCallsign()
{
return $this->callsign;
}
/**
* Set reason
*
* #param string $reason
*
* #return ExtraOpening
*/
public function setReason($reason)
{
$this->reason = $reason;
return $this;
}
/**
* Get reason
*
* #return string
*/
public function getReason()
{
return $this->reason;
}
/**
* Set additional
*
* #param integer $additional
*
* #return ExtraOpening
*/
public function setAdditional($additional)
{
$this->additional = $additional;
return $this;
}
/**
* Get additional
*
* #return int
*/
public function getAdditional()
{
return $this->additional;
}
/**
* Set separateOpening
*
* #param boolean $separateOpening
*
* #return ExtraOpening
*/
public function setSeparateOpening($separateOpening)
{
$this->separateOpening = $separateOpening;
return $this;
}
/**
* Get separateOpening
*
* #return bool
*/
public function getSeparateOpening()
{
return $this->separateOpening;
}
/**
* Set price
*
* #param integer $price
*
* #return ExtraOpening
*/
public function setPrice($price)
{
$this->price = $price;
return $this;
}
/**
* Get price
*
* #return int
*/
public function getPrice()
{
return $this->price;
}
/**
* Get debitTime
*
* #return string
*/
public function getDebitTime()
{
$open = $this->getOpen();
$close = $this->getClose();
$interval = date_diff($open, $close);
$r = $interval->format('%H:%I');
return $r;
}
/**
* Get debitTimeSeconds
*
* #return int
*/
public function getDebitTimeSeconds()
{
$open = $this->getOpen();
$close = $this->getClose();
$r = $close->format('U') - $open->format('U');
return $r;
}
/**
* Get debitHours
*
* #return decimal
*/
public function getDebitHours()
{
$open = $this->getOpen();
$close = $this->getClose();
$seconds = date_timestamp_get($close) - date_timestamp_get($open);
$hours = $seconds / 3600;
if($this->getSeparateOpening() && $hours < 3) {
$hours = 3;
}
return number_format($hours,2);
}
/**
* Get debitAmount
*
* #return decimal
*/
public function getDebitAmount()
{
$hours = $this->getDebitHours();
$price = $this->getPrice();
$amount = $hours * $price;
//return number_format($amount,2);
return $amount;
}
/**
* Set comment
*
* #param string $comment
*
* #return ExtraOpening
*/
public function setComment($comment)
{
$this->comment = $comment;
return $this;
}
/**
* Get comment
*
* #return string
*/
public function getComment()
{
return $this->comment;
}
/**
* Get acrGroup
*
* #return \HazardlogBundle\Entity\ACRGroup
*/
public function getAcrGroup()
{
return $this->getDebitPeriod()->getACRGroup();
}
/**
* Set debitPeriod
*
* #param \ExtraOpeningBundle\Entity\DebitPeriod $debitPeriod
*
* #return ExtraOpening
*/
public function setDebitPeriod(\ExtraOpeningBundle\Entity\DebitPeriod $debitPeriod)
{
$this->debitPeriod = $debitPeriod;
return $this;
}
/**
* Get debitPeriod
*
* #return \ExtraOpeningBundle\Entity\DebitPeriod
*/
public function getDebitPeriod()
{
return $this->debitPeriod;
}
}

As m-khalid-junaid https://stackoverflow.com/users/853360/m-khalid-junaid pointed out, the import had been corrupt and the auto_increment property had gone unnoticed, it was not set. Thank you.

Related

Error query for a user does not come out in consultation OneToMany if given a condition

First, forgive me for my bad English.
I have a problem with an sql query that I am doing using doctrine in symfony
I have two related tables, one of users and one of actions performed by the user, these tables are related from one to many, a user can do many actions.
I am trying to make a query in which I from all users who have not done an action (the status column is the one that indicates the types of actions, when the process ends it will have an 8) therefore I want to remove those that do not have an 8. In principle, although I have tried many options, what I think would be more correct would be
$query = $em->createQueryBuilder()
->from("BackendBundle:Inscritos", "e")
->select("e")
->innerJoin("BackendBundle:InscritosAcciones", "u", "WITH", "e.id=u.inscritosId")
->groupBy("u.inscritosId")
->where("u.status != 8")
->getQuery();
The fact is that as the user has some other action besides that of status 8 (must have them since it is a process and the actions allow to see what has been happening) I continue to remove that user.
my entities
namespace BackendBundle\Entity;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* Inscritos
* #UniqueEntity(fields={"correoUsuario"}, message="¡Este correo ya esta registrado!")
* #UniqueEntity(fields={"documento"}, message="¡Este numero de documento ya esta registrado!")
*/
class Inscritos {
/**
* #var integer
*/
private $id;
/**
* #var string
* #Assert\NotBlank(message = "Por favor, escribe tu nombre")
*/
private $nombreUsuario;
/**
* #var string
* #Assert\NotBlank(message = "Por favor, escribe tus apellidos")
*/
private $apellidoUsuario;
/**
* #var string
* #Assert\NotBlank()
* #Assert\Range(
* min = 9,
* max = 9,
* minMessage = "Este campo tiene que tener {{ limit }} numeros ",
* maxMessage = "Este campo tiene que tener {{ limit }} numeros "
* )
*/
private $telefono;
/**
* #var string
* #Assert\Email(checkMX=true)
*/
private $correoUsuario;
/**
* #var string
*/
private $validadocorreo = 'NO';
/**
* #var string
*/
private $tipodocumento;
/**
* #var string
* #Assert\NotBlank(message = "Por favor, escribe tu numero de documento")
*/
private $documento;
/**
* #var \DateTime
* #Assert\NotBlank(message = "Por favor, escribe tu fecha de nacimiento")
*/
private $fechanacimiento;
/**
* #var string
*/
private $pais;
/**
* #var string
*/
private $provinciaotros;
/**
* #var string
*/
private $municipiootros;
/**
* #var string
* #Assert\NotBlank(message = "Por favor, escribe tu codigo postal")
*/
private $codigopostal;
/**
* #var string
* #Assert\NotBlank(message = "Por favor, escribe tu direccion de contacto")
*/
private $direccion;
/**
* #var string
*/
private $lugarparticipacion;
/**
* #var \DateTime
*/
private $fechainscritpcion;
/**
* #var string
*/
private $ipinscripcion;
/**
* #var string
*/
private $cadenaseg;
/**
* #var string
*/
private $bloqueo = 'no';
/**
* #var string
*/
private $razonBloqueo;
/**
* #var string
*/
private $perfil;
/**
* #var \DateTime
*/
private $fechaControl;
/**
* #var integer
*/
private $idMunicipio;
/**
* #var integer
*/
private $idProvincia;
/**
* #var string
*/
private $idCcaa;
public function __toString() {
return (string) $this->getId();
}
/**
* Get id
*
* #return integer
*/
public function getId() {
return $this->id;
}
/**
* Set nombreUsuario
*
* #param string $nombreUsuario
*
* #return Inscritos
*/
public function setNombreUsuario($nombreUsuario) {
$this->nombreUsuario = $nombreUsuario;
return $this;
}
/**
* Get nombreUsuario
*
* #return string
*/
public function getNombreUsuario() {
return $this->nombreUsuario;
}
/**
* Set apellidoUsuario
*
* #param string $apellidoUsuario
*
* #return Inscritos
*/
public function setApellidoUsuario($apellidoUsuario) {
$this->apellidoUsuario = $apellidoUsuario;
return $this;
}
/**
* Get apellidoUsuario
*
* #return string
*/
public function getApellidoUsuario() {
return $this->apellidoUsuario;
}
/**
* Set telefono
*
* #param string $telefono
*
* #return Inscritos
*/
public function setTelefono($telefono) {
$this->telefono = $telefono;
return $this;
}
/**
* Get telefono
*
* #return string
*/
public function getTelefono() {
return $this->telefono;
}
/**
* Set correoUsuario
*
* #param string $correoUsuario
*
* #return Inscritos
*/
public function setCorreoUsuario($correoUsuario) {
$this->correoUsuario = $correoUsuario;
return $this;
}
/**
* Get correoUsuario
*
* #return string
*/
public function getCorreoUsuario() {
return $this->correoUsuario;
}
/**
* Set validadocorreo
*
* #param string $validadocorreo
*
* #return Inscritos
*/
public function setValidadocorreo($validadocorreo) {
$this->validadocorreo = $validadocorreo;
return $this;
}
/**
* Get validadocorreo
*
* #return string
*/
public function getValidadocorreo() {
return $this->validadocorreo;
}
/**
* Set tipodocumento
*
* #param string $tipodocumento
*
* #return Inscritos
*/
public function setTipodocumento($tipodocumento) {
$this->tipodocumento = $tipodocumento;
return $this;
}
/**
* Get tipodocumento
*
* #return string
*/
public function getTipodocumento() {
return $this->tipodocumento;
}
/**
* Set documento
*
* #param string $documento
*
* #return Inscritos
*/
public function setDocumento($documento) {
$this->documento = $documento;
return $this;
}
/**
* Get documento
*
* #return string
*/
public function getDocumento() {
return $this->documento;
}
/**
* Set fechanacimiento
*
* #param \DateTime $fechanacimiento
*
* #return Inscritos
*/
public function setFechanacimiento($fechanacimiento) {
$this->fechanacimiento = $fechanacimiento;
return $this;
}
/**
* Get fechanacimiento
*
* #return \DateTime
*/
public function getFechanacimiento() {
return $this->fechanacimiento;
}
/**
* Set pais
*
* #param string $pais
*
* #return Inscritos
*/
public function setPais($pais) {
$this->pais = $pais;
return $this;
}
/**
* Get pais
*
* #return string
*/
public function getPais() {
return $this->pais;
}
/**
* Set provinciaotros
*
* #param string $provinciaotros
*
* #return Inscritos
*/
public function setProvinciaotros($provinciaotros) {
$this->provinciaotros = $provinciaotros;
return $this;
}
/**
* Get provinciaotros
*
* #return string
*/
public function getProvinciaotros() {
return $this->provinciaotros;
}
/**
* Set municipiootros
*
* #param string $municipiootros
*
* #return Inscritos
*/
public function setMunicipiootros($municipiootros) {
$this->municipiootros = $municipiootros;
return $this;
}
/**
* Get municipiootros
*
* #return string
*/
public function getMunicipiootros() {
return $this->municipiootros;
}
/**
* Set codigopostal
*
* #param string $codigopostal
*
* #return Inscritos
*/
public function setCodigopostal($codigopostal) {
$this->codigopostal = $codigopostal;
return $this;
}
/**
* Get codigopostal
*
* #return string
*/
public function getCodigopostal() {
return $this->codigopostal;
}
/**
* Set direccion
*
* #param string $direccion
*
* #return Inscritos
*/
public function setDireccion($direccion) {
$this->direccion = $direccion;
return $this;
}
/**
* Get direccion
*
* #return string
*/
public function getDireccion() {
return $this->direccion;
}
/**
* Set lugarparticipacion
*
* #param string $lugarparticipacion
*
* #return Inscritos
*/
public function setLugarparticipacion($lugarparticipacion) {
$this->lugarparticipacion = $lugarparticipacion;
return $this;
}
/**
* Get lugarparticipacion
*
* #return string
*/
public function getLugarparticipacion() {
return $this->lugarparticipacion;
}
/**
* Set fechainscritpcion
*
* #param \DateTime $fechainscritpcion
*
* #return Inscritos
*/
public function setFechainscritpcion($fechainscritpcion) {
$this->fechainscritpcion = $fechainscritpcion;
return $this;
}
/**
* Get fechainscritpcion
*
* #return \DateTime
*/
public function getFechainscritpcion() {
return $this->fechainscritpcion;
}
/**
* Set ipinscripcion
*
* #param string $ipinscripcion
*
* #return Inscritos
*/
public function setIpinscripcion($ipinscripcion) {
$this->ipinscripcion = $ipinscripcion;
return $this;
}
/**
* Get ipinscripcion
*
* #return string
*/
public function getIpinscripcion() {
return $this->ipinscripcion;
}
/**
* Set cadenaseg
*
* #param string $cadenaseg
*
* #return Inscritos
*/
public function setCadenaseg($cadenaseg) {
$this->cadenaseg = $cadenaseg;
return $this;
}
/**
* Get cadenaseg
*
* #return string
*/
public function getCadenaseg() {
return $this->cadenaseg;
}
/**
* Set bloqueo
*
* #param string $bloqueo
*
* #return Inscritos
*/
public function setBloqueo($bloqueo) {
$this->bloqueo = $bloqueo;
return $this;
}
/**
* Get bloqueo
*
* #return string
*/
public function getBloqueo() {
return $this->bloqueo;
}
/**
* Set razonBloqueo
*
* #param string $razonBloqueo
*
* #return Inscritos
*/
public function setRazonBloqueo($razonBloqueo) {
$this->razonBloqueo = $razonBloqueo;
return $this;
}
/**
* Get razonBloqueo
*
* #return string
*/
public function getRazonBloqueo() {
return $this->razonBloqueo;
}
/**
* Set perfil
*
* #param string $perfil
*
* #return Inscritos
*/
public function setPerfil($perfil) {
$this->perfil = $perfil;
return $this;
}
/**
* Get perfil
*
* #return string
*/
public function getPerfil() {
return $this->perfil;
}
/**
* Set fechaControl
*
* #param \DateTime $fechaControl
*
* #return Inscritos
*/
public function setFechaControl($fechaControl) {
$this->fechaControl = $fechaControl;
return $this;
}
/**
* Get fechaControl
*
* #return \DateTime
*/
public function getFechaControl() {
return $this->fechaControl;
}
/**
* Set idMunicipio
*
* #param integer $idMunicipio
*
* #return Inscritos
*/
public function setIdMunicipio($idMunicipio) {
$this->idMunicipio = $idMunicipio;
return $this;
}
/**
* Get idMunicipio
*
* #return integer
*/
public function getIdMunicipio() {
return $this->idMunicipio;
}
/**
* Set idProvincia
*
* #param integer $idProvincia
*
* #return Inscritos
*/
public function setIdProvincia($idProvincia) {
$this->idProvincia = $idProvincia;
return $this;
}
/**
* Get idProvincia
*
* #return integer
*/
public function getIdProvincia() {
return $this->idProvincia;
}
/**
* Set idCcaa
*
* #param string $idCcaa
*
* #return Inscritos
*/
public function setIdCcaa($idCcaa) {
$this->idCcaa = $idCcaa;
return $this;
}
/**
* Get idCcaa
*
* #return string
*/
public function getIdCcaa() {
return $this->idCcaa;
}
/**
* #var \Doctrine\Common\Collections\Collection
*/
private $imagenes;
/**
* #var \Doctrine\Common\Collections\Collection
*/
private $validaInscritos;
/**
* #var \BackendBundle\Entity\Ccaa
*/
private $ccaaInscritos;
/**
* #var \BackendBundle\Entity\Municipios
*/
private $municipioInscritos;
/**
* #var \BackendBundle\Entity\Provincia
*/
private $provinciaInscritos;
/**
* Constructor
*/
public function __construct() {
$this->imagenes = new \Doctrine\Common\Collections\ArrayCollection();
$this->validaInscritos = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Add imagene
*
* #param \BackendBundle\Entity\InscritosImages $imagene
*
* #return Inscritos
*/
public function addImagene(\BackendBundle\Entity\InscritosImages $imagene) {
$this->imagenes[] = $imagene;
return $this;
}
/**
* Remove imagene
*
* #param \BackendBundle\Entity\InscritosImages $imagene
*/
public function removeImagene(\BackendBundle\Entity\InscritosImages $imagene) {
$this->imagenes->removeElement($imagene);
}
/**
* Get imagenes
*
* #return \Doctrine\Common\Collections\Collection
*/
public function getImagenes() {
return $this->imagenes;
}
/**
* Add validaInscrito
*
* #param \BackendBundle\Entity\ValidaInscritos $validaInscrito
*
* #return Inscritos
*/
public function addValidaInscrito(\BackendBundle\Entity\ValidaInscritos $validaInscrito) {
$this->validaInscritos[] = $validaInscrito;
return $this;
}
/**
* Remove validaInscrito
*
* #param \BackendBundle\Entity\ValidaInscritos $validaInscrito
*/
public function removeValidaInscrito(\BackendBundle\Entity\ValidaInscritos $validaInscrito) {
$this->validaInscritos->removeElement($validaInscrito);
}
/**
* Get validaInscritos
*
* #return \Doctrine\Common\Collections\Collection
*/
public function getValidaInscritos() {
return $this->validaInscritos;
}
/**
* Set ccaaInscritos
*
* #param \BackendBundle\Entity\Ccaa $ccaaInscritos
*
* #return Inscritos
*/
public function setCcaaInscritos(\BackendBundle\Entity\Ccaa $ccaaInscritos = null) {
$this->ccaaInscritos = $ccaaInscritos;
return $this;
}
/**
* Get ccaaInscritos
*
* #return \BackendBundle\Entity\Ccaa
*/
public function getCcaaInscritos() {
return $this->ccaaInscritos;
}
/**
* Set municipioInscritos
*
* #param \BackendBundle\Entity\Municipios $municipioInscritos
*
* #return Inscritos
*/
public function setMunicipioInscritos(\BackendBundle\Entity\Municipios $municipioInscritos = null) {
$this->municipioInscritos = $municipioInscritos;
return $this;
}
/**
* Get municipioInscritos
*
* #return \BackendBundle\Entity\Municipios
*/
public function getMunicipioInscritos() {
return $this->municipioInscritos;
}
/**
* Set provinciaInscritos
*
* #param \BackendBundle\Entity\Provincia $provinciaInscritos
*
* #return Inscritos
*/
public function setProvinciaInscritos(\BackendBundle\Entity\Provincia $provinciaInscritos = null) {
$this->provinciaInscritos = $provinciaInscritos;
return $this;
}
/**
* Get provinciaInscritos
*
* #return \BackendBundle\Entity\Provincia
*/
public function getProvinciaInscritos() {
return $this->provinciaInscritos;
}
/**
* #var \Doctrine\Common\Collections\Collection
*/
private $inscritosAcciones;
/**
* Add inscritosAccione
*
* #param \BackendBundle\Entity\InscritosAcciones $inscritosAccione
*
* #return Inscritos
*/
public function addInscritosAccione(\BackendBundle\Entity\InscritosAcciones $inscritosAccione) {
$this->inscritosAcciones[] = $inscritosAccione;
return $this;
}
/**
* Remove inscritosAccione
*
* #param \BackendBundle\Entity\InscritosAcciones $inscritosAccione
*/
public function removeInscritosAccione(\BackendBundle\Entity\InscritosAcciones $inscritosAccione) {
$this->inscritosAcciones->removeElement($inscritosAccione);
}
/**
* Get inscritosAcciones
*
* #return \Doctrine\Common\Collections\Collection
*/
public function getInscritosAcciones() {
return $this->inscritosAcciones;
}
}
entity InscritosAcciones
namespace BackendBundle\Entity;
/**
* InscritosAcciones
*/
class InscritosAcciones
{
/**
* #var integer
*/
private $id;
/**
* #var integer
*/
private $status;
/**
* #var string
*/
private $accion;
/**
* #var string
*/
private $datos;
/**
* #var \DateTime
*/
private $fecha = 'CURRENT_TIMESTAMP';
/**
* #var integer
*/
private $inscritosId;
/**
* #var \BackendBundle\Entity\Inscritos
*/
private $inscritos;
/**
* #var \BackendBundle\Entity\Acciones
*/
private $acciones;
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set status
*
* #param integer $status
*
* #return InscritosAcciones
*/
public function setStatus($status)
{
$this->status = $status;
return $this;
}
/**
* Get status
*
* #return integer
*/
public function getStatus()
{
return $this->status;
}
/**
* Set accion
*
* #param string $accion
*
* #return InscritosAcciones
*/
public function setAccion($accion)
{
$this->accion = $accion;
return $this;
}
/**
* Get accion
*
* #return string
*/
public function getAccion()
{
return $this->accion;
}
/**
* Set datos
*
* #param string $datos
*
* #return InscritosAcciones
*/
public function setDatos($datos)
{
$this->datos = $datos;
return $this;
}
/**
* Get datos
*
* #return string
*/
public function getDatos()
{
return $this->datos;
}
/**
* Set fecha
*
* #param \DateTime $fecha
*
* #return InscritosAcciones
*/
public function setFecha($fecha)
{
$this->fecha = $fecha;
return $this;
}
/**
* Get fecha
*
* #return \DateTime
*/
public function getFecha()
{
return $this->fecha;
}
/**
* Set inscritosId
*
* #param integer $inscritosId
*
* #return InscritosAcciones
*/
public function setInscritosId($inscritosId)
{
$this->inscritosId = $inscritosId;
return $this;
}
/**
* Get inscritosId
*
* #return integer
*/
public function getInscritosId()
{
return $this->inscritosId;
}
/**
* Set inscritos
*
* #param \BackendBundle\Entity\Inscritos $inscritos
*
* #return InscritosAcciones
*/
public function setInscritos(\BackendBundle\Entity\Inscritos $inscritos = null)
{
$this->inscritos = $inscritos;
return $this;
}
/**
* Get inscritos
*
* #return \BackendBundle\Entity\Inscritos
*/
public function getInscritos()
{
return $this->inscritos;
}
/**
* Set acciones
*
* #param \BackendBundle\Entity\Acciones $acciones
*
* #return InscritosAcciones
*/
public function setAcciones(\BackendBundle\Entity\Acciones $acciones = null)
{
$this->acciones = $acciones;
return $this;
}
/**
* Get acciones
*
* #return \BackendBundle\Entity\Acciones
*/
public function getAcciones()
{
return $this->acciones;
}
}
Both tables are related to other tables but are not necessary in this query. The incritosAcciones table is related to a table of actions, and the one of inscribed with enough tables since it is a quite complex structure.
    
Regarding what result gives me, because I think I had previously put it, I list all the rows of the inscribed table since they will always have more shares (something in the status field) besides the status = 8
Finally, if in the consultation I group it by
->groupBy("u.status")
I only get (normal) one record for each of the statuses except the one that has status 8
a full consultation would be
$query = $em->createQueryBuilder()
->from("BackendBundle:Inscritos", "e")
->select("e")
->innerJoin("BackendBundle:InscritosAcciones", "u", "WITH", "e.id=u.inscritosId")
->groupBy("u.status")
->where("u.status != 8")
->getQuery();
I have added two screenshots of my phpmyAdmin that you can see in the Spanish version because here I do not have enough reputation to upload images
https://es.stackoverflow.com/questions/132649/problema-para-que-no-salga-un-usuario-en-consulta-onetomany-si-se-da-una-condici
And what they would have to leave are users 43 and 63, nothing would happen because the other users left who do not have any action yet, but the one who should never leave is user 1, who has an action with status 8
Can someone help me please.
Thank you

Symfony Insert Foreign Key Value

I have 3 tables: EdiTradingPartner, EdiDocType and EdiTradingPartnerTransactions
src\Matrix\MatrixEdiBundle\Entity\EdiTradingPartner
namespace Matrix\MatrixEdiBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* EdiTradingPartner
*
* #ORM\Table(name="edi_trading_partner")
* #ORM\Entity(repositoryClass="Matrix\MatrixEdiBundle\Repository\EdiTradingPartnerRepository")
*/
class EdiTradingPartner
{
/**
* #var string
*
* #ORM\Column(name="edi_interchange_id", type="string", length=30, nullable=false)
*/
private $ediInterchangeId;
/**
* #var string
*
* #ORM\Column(name="tp_name", type="string", length=30, nullable=false)
*/
private $tpName;
/**
* #var string
*
* #ORM\Column(name="tp_location", type="string", length=50, nullable=false)
*/
private $tpLocation;
/**
* #var integer
*
* #ORM\Column(name="edi_trading_partner_id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $ediTradingPartnerId;
/**
* Set ediInterchangeId
*
* #param string $ediInterchangeId
* #return EdiTradingPartner
*/
public function setEdiInterchangeId($ediInterchangeId)
{
$this->ediInterchangeId = $ediInterchangeId;
return $this;
}
/**
* Get ediInterchangeId
*
* #return string
*/
public function getEdiInterchangeId()
{
return $this->ediInterchangeId;
}
/**
* Set tpName
*
* #param string $tpName
* #return EdiTradingPartner
*/
public function setTpName($tpName)
{
$this->tpName = $tpName;
return $this;
}
/**
* Get tpName
*
* #return string
*/
public function getTpName()
{
return $this->tpName;
}
/**
* Set tpLocation
*
* #param string $tpLocation
* #return EdiTradingPartner
*/
public function setTpLocation($tpLocation)
{
$this->tpLocation = $tpLocation;
return $this;
}
/**
* Get tpLocation
*
* #return string
*/
public function getTpLocation()
{
return $this->tpLocation;
}
/**
* Get ediTradingPartnerId
*
* #return integer
*/
public function getEdiTradingPartnerId()
{
return $this->ediTradingPartnerId;
}
}
src\Matrix\MatrixEdiBundle\Entity\EdiDocType
<?php
namespace Matrix\MatrixEdiBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* EdiDocType
*
* #ORM\Table(name="edi_doc_type")
* #ORM\Entity(repositoryClass="Matrix\MatrixEdiBundle\Repository\EdiDocTypeRepository")
*/
class EdiDocType
{
/**
* #var integer
*
* #ORM\Column(name="doc_type", type="integer", nullable=false)
*/
private $docType;
/**
* #var string
*
* #ORM\Column(name="name", type="string", length=50, nullable=false)
*/
private $name;
/**
* #var string
*
* #ORM\Column(name="description", type="string", length=255, nullable=false)
*/
private $description;
/**
* #var string
*
* #ORM\Column(name="direction", type="string", length=10, nullable=false)
*/
private $direction;
/**
* #var integer
*
* #ORM\Column(name="edi_doc_type_id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $ediDocTypeId;
/**
* Set docType
*
* #param integer $docType
* #return EdiDocType
*/
public function setDocType($docType)
{
$this->docType = $docType;
return $this;
}
/**
* Get docType
*
* #return integer
*/
public function getDocType()
{
return $this->docType;
}
/**
* Set name
*
* #param string $name
* #return EdiDocType
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* #return string
*/
public function getName()
{
return $this->name;
}
/**
* Set description
*
* #param string $description
* #return EdiDocType
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Get description
*
* #return string
*/
public function getDescription()
{
return $this->description;
}
/**
* Set direction
*
* #param string $direction
* #return EdiDocType
*/
public function setDirection($direction)
{
$this->direction = $direction;
return $this;
}
/**
* Get direction
*
* #return string
*/
public function getDirection()
{
return $this->direction;
}
/**
* Get ediDocTypeId
*
* #return integer
*/
public function getEdiDocTypeId()
{
return $this->ediDocTypeId;
}
}
src\Matrix\MatrixEdiBundle\Entity\EdiTradingPartnerTransactions
namespace Matrix\MatrixEdiBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* EdiTradingPartnerTransactions
*
* #ORM\Table(name="edi_trading_partner_transactions", indexes={#ORM\Index(name="edi_tp_id", columns={"edi_tp_id", "edi_doc_type_id"}), #ORM\Index(name="edi_transactions_id", columns={"edi_doc_type_id"}), #ORM\Index(name="IDX_F2BE50F7B9C737A1", columns={"edi_tp_id"})})
* #ORM\Entity(repositoryClass="Matrix\MatrixEdiBundle\Repository\EdiTradingPartnerTransactionsRepository")
*/
class EdiTradingPartnerTransactions
{
/**
* #var integer
*
* #ORM\Column(name="edi_tp_transactions_id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $ediTpTransactionsId;
/**
* #var \Matrix\MatrixEdiBundle\Entity\EdiDocType
*
* #ORM\ManyToOne(targetEntity="Matrix\MatrixEdiBundle\Entity\EdiDocType")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="edi_doc_type_id", referencedColumnName="edi_doc_type_id")
* })
*/
private $ediDocType;
/**
* #var \Matrix\MatrixEdiBundle\Entity\EdiTradingPartner
*
* #ORM\ManyToOne(targetEntity="Matrix\MatrixEdiBundle\Entity\EdiTradingPartner")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="edi_tp_id", referencedColumnName="edi_trading_partner_id")
* })
*/
private $ediTp;
/**
* Get ediTpTransactionsId
*
* #return integer
*/
public function getEdiTpTransactionsId()
{
return $this->ediTpTransactionsId;
}
/**
* Set ediDocType
*
* #param \Matrix\MatrixEdiBundle\Entity\EdiDocType $ediDocType
* #return EdiTradingPartnerTransactions
*/
public function setEdiDocType(\Matrix\MatrixEdiBundle\Entity\EdiDocType $ediDocType = null)
{
$this->ediDocType = $ediDocType;
return $this;
}
/**
* Get ediDocType
*
* #return \Matrix\MatrixEdiBundle\Entity\EdiDocType
*/
public function getEdiDocType()
{
return $this->ediDocType;
}
/**
* Set ediTp
*
* #param \Matrix\MatrixEdiBundle\Entity\EdiTradingPartner $ediTp
* #return EdiTradingPartnerTransactions
*/
public function setEdiTp(\Matrix\MatrixEdiBundle\Entity\EdiTradingPartner $ediTp = null)
{
$this->ediTp = $ediTp;
return $this;
}
/**
* Get ediTp
*
* #return \Matrix\MatrixEdiBundle\Entity\EdiTradingPartner
*/
public function getEdiTp()
{
return $this->ediTp;
}
}
I want to insert into EdiTradingPartnerTransactions table yet I really don't know what to do since I've been receiving this error:
Catchable fatal error: Argument 1 passed to
Matrix\MatrixEdiBundle\Entity\EdiTradingPartnerTransactions::setEdiTp()
must be an instance of
Matrix\MatrixEdiBundle\Entity\EdiTradingPartner, string given, called
in
C:\xampp\htdocs\Editracker\src\Matrix\MatrixEdiBundle\Controller\MatrixController.php
on line 474 and defined in
C:\xampp\htdocs\Editracker\src\Matrix\MatrixEdiBundle\Entity\EdiTradingPartnerTransactions.php
on line 85
Here's my function in the controller side:
public function deleteTpTransAction($tpId, $docType, $direction, $tpName) {
$em = $this->getDoctrine()->getManager();
$docTypeId = $em->getRepository('MatrixEdiBundle:EdiDocType')->getId($docType, $direction);
if ($docTypeId != null) {
$result = $em->getRepository('MatrixEdiBundle:EdiTradingPartnerTransactions')->getTpTrans($tpId, $docType, $direction);
if ($result == null) {
$transaction = new EdiTradingPartnerTransactions();
$transaction->setEdiTp($tpId);
$transaction->setEdiDocType($docTypeId);
$em->persist($transaction);
} else {
foreach ($result as $key) {
$id = $key->getEdiTpTransactionsId();
$transaction = $em->getRepository('MatrixEdiBundle:EdiTradingPartnerTransactions')->find($id);
$em->remove($transaction);
}
}
$em->flush();
}
return $this->redirect($this->generateUrl('matrix_edi_tpTrans'));
}
Any help would really be appreciated. Thanks in advanced!
The error here is pretty clear: Doctrine handle, at least for relationships, only objects of the "related" (let's call that way) entity.
When you do
$transaction->setEdiTp($tpId);
$transaction->setEdiDocType($docTypeId);
you're trying to insert ID(s) of related objects. This is an error: although your db expects an integer (foreign key), Doctrine is an abstaction "pillow" between your code and db; it choose to work with objects and not with ids(you can see it pretty clearly into entity classes files)
Solution here is pretty simple:
Fetch from db the entity for setEdiTp and setEdiDocType
Pass them to the functions
In PHP (Symfony):
$ediTp = $em
->getRepository('MatrixEdiBundle:EdiTp')
->findOneById($tpId);
$ediDocType = $em
->getRepository('MatrixEdiBundle:EdiDocType')
->findOneById($docTypeId);
then
$transaction->setEdiTp($ediTp);
$transaction->setEdiDocType($ediDocType);
Your error is because setEdiTp need an instance of EdiTradingPartner.
Your error say string given.
Because $tpId is string.
Verify
Change
$transaction->setEdiTp($tpId);
To
// $transaction->setEdiTp($tpId);
var_dump($tpId);
Normally, $tpId return a string, not a object.
So when you call deleteTpTransAction, $tpId must be an instance of setEdiTp
Changement :
$editp = $em->getRepository('MatrixEdiBundle:EdiTradingPartner')->find($tpId);
and change
$transaction->setEdiTp($tpId);
by
$transaction->setEdiTp($editTp);

Symfony 2 - The annotation in property does not exist, or could not be auto-loaded

I have a weird problem when I want to generate my database schema on Symfony2, one attribut is not accepted...
The annotation "#Doctrine\ORM\Mapping\ManyToOne" in property L3L2\EntraideBundle\Entity\RendezVous::$idDispoProf does not exist, or could not be auto-loaded.
It's even weirder because its working on MacOS X and Windows (Vista & Seven). I tried to make it works on Ubuntu Server VM.
Here is my entities code :
<?php
namespace L3L2\EntraideBundle\Entity;
use L3L2\UserBundle\Entity\User;
use Doctrine\ORM\Mapping as ORM;
/**
* RendezVous
*
* #ORM\Table()
* #ORM\Entity(repositoryClass="L3L2\EntraideBundle\Entity\RendezVousRepository")
*/
class RendezVous
{
/**
* Constructor
*/
public function __construct()
{
$this->vuEleve = "NON";
$this->vuProf = "NON";
}
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var string
*
* #ORM\Column(name="lieu", type="string", length=255)
*/
private $lieu;
/**
* #var string
*
* #ORM\Column(name="statut", type="string", length=255)
*/
private $statut;
/**
* #var \DateTime
*
* #ORM\Column(name="date", type="date")
*/
private $date;
/**
* #var \DateTime
*
* #ORM\Column(name="time", type="time")
*/
private $time;
/**
* #var \DateTime
*
* #ORM\Column(name="datetimeDebut", type="datetime")
*/
private $datetimeDebut;
/**
* #var \DateTime
*
* #ORM\Column(name="datetimeFin", type="datetime")
*/
private $datetimeFin;
//Création de OneToOne vers Evaluation
/**
* #ORM\OneToOne(targetEntity="L3L2\EntraideBundle\Entity\Evaluation", mappedBy="idRdvEval")
* #ORM\JoinColumn(name="id_eval", referencedColumnName="id")
*/
protected $evaluationRdv;
//PROBLEM HERE !!
// Création de ManytoOne vers Disponibilite
/**
* #ORM\ManytoOne(targetEntity="L3L2\EntraideBundle\Entity\Disponibilite")
* #ORM\JoinColumn(name="id_dispo_prof", referencedColumnName="id", onDelete="SET NULL")
*/
protected $idDispoProf;
//Création de ManyToOne vers Cours
/**
* #ORM\ManyToOne(targetEntity="L3L2\EntraideBundle\Entity\Cours", inversedBy="rendezVousCours")
* #ORM\JoinColumn(name="id_cours_rdv", referencedColumnName="id")
*/
protected $idCoursRdv;
//Création de ManyToOne vers User
/**
* #ORM\ManyToOne(targetEntity="L3L2\UserBundle\Entity\User", inversedBy="rendezVousEleve")
* #ORM\JoinColumn(name="id_eleve_rdv", referencedColumnName="id")
*/
protected $idEleveRdv;
/**
* #var string
*
* #ORM\Column(name="vuEleve", type="string", length=255, nullable=true)
*/
private $vuEleve;
/**
* #var string
*
* #ORM\Column(name="vuProf", type="string", length=255, nullable=true)
*/
private $vuProf;
//Création de ManyToOne vers User
/**
* #ORM\ManyToOne(targetEntity="L3L2\UserBundle\Entity\User")
* #ORM\JoinColumn(name="dernierModif", referencedColumnName="id")
*/
private $dernierModif;
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set lieu
*
* #param string $lieu
* #return RendezVous
*/
public function setLieu($lieu)
{
$this->lieu = $lieu;
return $this;
}
/**
* Get lieu
*
* #return string
*/
public function getLieu()
{
return $this->lieu;
}
/**
* Set statut
*
* #param string $statut
* #return RendezVous
*/
public function setStatut($statut)
{
$this->statut = $statut;
return $this;
}
/**
* Get statut
*
* #return string
*/
public function getStatut()
{
return $this->statut;
}
/**
* Set evaluationRdv
*
* #param \L3L2\EntraideBundle\Entity\Evaluation $evaluationRdv
* #return RendezVous
*/
public function setEvaluationRdv(\L3L2\EntraideBundle\Entity\Evaluation $evaluationRdv = null)
{
$this->evaluationRdv = $evaluationRdv;
return $this;
}
/**
* Get evaluationRdv
*
* #return \L3L2\EntraideBundle\Entity\Evaluation
*/
public function getEvaluationRdv()
{
return $this->evaluationRdv;
}
/**
* Set idEleveRdv
*
* #param \L3L2\UserBundle\Entity\User $idEleveRdv
* #return RendezVous
*/
public function setIdEleveRdv(\L3L2\UserBundle\Entity\User $idEleveRdv = null)
{
return $this->idEleveRdv = $idEleveRdv;
}
/**
* Get idEleveRdv
*
* #return \L3L2\UserBundle\Entity\User
*/
public function getIdEleveRdv()
{
return $this->idEleveRdv;
}
/**
* Set idDispoProf
*
* #param \L3L2\EntraideBundle\Entity\Disponibilite $idDispoProf
* #return RendezVous
*/
public function setIdDispoProf(\L3L2\EntraideBundle\Entity\Disponibilite $idDispoProf = null)
{
return $this->idDispoProf = $idDispoProf;
}
/**
* Get idDispoProf
*
* #return \L3L2\EntraideBundle\Entity\Disponibilite
*/
public function getIdDispoProf()
{
return $this->idDispoProf;
}
/**
* Set idCoursRdv
*
* #param \L3L2\EntraideBundle\Entity\Cours $idCoursRdv
* #return RendezVous
*/
public function setIdCoursRdv(\L3L2\EntraideBundle\Entity\Cours $idCoursRdv = null)
{
return $this->idCoursRdv = $idCoursRdv;
}
/**
* Get idCoursRdv
*
* #return \L3L2\EntraideBundle\Entity\Cours
*/
public function getIdCoursRdv()
{
return $this->idCoursRdv;
}
/**
* Set date
*
* #param \DateTime $date
* #return RendezVous
*/
public function setDate($date)
{
$this->date = clone $date;
return $this;
}
/**
* Get date
*
* #return \DateTime
*/
public function getDate()
{
return clone $this->date;
}
/**
* Set time
*
* #param \DateTime $time
* #return RendezVous
*/
public function setTime($time)
{
$this->time = clone $time;
return $this;
}
/**
* Get time
*
* #return \DateTime
*/
public function getTime()
{
return clone $this->time;
}
/**
* Set vuEleve
*
* #param string $vuEleve
* #return RendezVous
*/
public function setVuEleve($vuEleve)
{
$this->vuEleve = $vuEleve;
return $this;
}
/**
* Get vuEleve
*
* #return string
*/
public function getVuEleve()
{
return $this->vuEleve;
}
/**
* Set vuProf
*
* #param string $vuProf
* #return RendezVous
*/
public function setVuProf($vuProf)
{
$this->vuProf = $vuProf;
return $this;
}
/**
* Get vuProf
*
* #return string
*/
public function getVuProf()
{
return $this->vuProf;
}
/**
* Set datetimeDebut
*
* #param \DateTime $datetimeDebut
* #return RendezVous
*/
public function setDatetimeDebut($datetimeDebut)
{
$this->datetimeDebut = $datetimeDebut;
return $this;
}
/**
* Get datetimeDebut
*
* #return \DateTime
*/
public function getDatetimeDebut()
{
return $this->datetimeDebut;
}
/**
* Set datetimeFin
*
* #param \DateTime $datetimeFin
* #return RendezVous
*/
public function setDatetimeFin($datetimeFin)
{
$this->datetimeFin = $datetimeFin;
return $this;
}
/**
* Get datetimeFin
*
* #return \DateTime
*/
public function getDatetimeFin()
{
return $this->datetimeFin;
}
/**
* Set dernierModif
*
* #param \L3L2\UserBundle\Entity\User $dernierModif
* #return RendezVous
*/
public function setDernierModif(\L3L2\UserBundle\Entity\User $dernierModif = null)
{
$this->dernierModif = $dernierModif;
return $this;
}
/**
* Get dernierModif
*
* #return \L3L2\UserBundle\Entity\User
*/
public function getDernierModif()
{
return $this->dernierModif;
}
}
If I remove the $idDispoProf or annotations before $idDispoProf I can schema:update...
Any idea ?
You have ManytoOne written in lowercase in this specific property instead of ManyToOne in rest of them. Autoloader works in Windows probably because for this system file called ManyToOne.php and ManytoOne.php is the same - Linux is case sensitive.
So solution for you: change ManytoOne to ManyToOne

Doctrine only returns a single result from database even though it should return multple records

I have a strange problem with a query in my Symfony2 project.
I have the following query:
$enviroFigures = $dm->createQuery('
SELECT efu.wasteType, efu.ewcCode, SUM(efu.totalUom) AS totalTonne, SUM(efu.co2Saving) AS totalCO2
FROM CoreBundle:EnviroFiguresUpload efu
WHERE efu.customerSite = :site
AND efu.completionDate BETWEEN :start AND :end
AND efu.completionDate != :blank
AND efu.totalUom != :zero
AND efu.wasteType != :blank
ORDER BY efu.completionDate DESC'
)->setParameters(array(
'site' => $cs,
'start' => $ds,
'end' => $de,
'blank' => '',
'zero' => '0'
));
$enviFig = $enviroFigures->getResult();
And with the test data I have, there are two records this query should return from the database. I've even used this SQL query to test the general query, and it has returned two rows of data as expected.
SELECT waste_type AS wasteType, ewc_code AS ewcCode, SUM(total_uom) AS totalTonne, SUM(co2_saving) AS totalCO2
FROM `enviro_figures_upload
WHERE customer_site = 'A Customer'
AND completion_date BETWEEN '2014-01-01' AND '2015-01-15'
AND completion_date != ''
AND total_uom != ''
AND waste_type != ''
GROUP BY waste_type
ORDER BY completion_date DESC
This is the output
wasteType ewcCode totalTonne totalCO2
Dry Mixed Recycling 20 03 01 20 2
Confidential Paper Shred service 20 01 01 75 0.84
However, inside the Symfony2 application only one result is returned:
wasteType ewcCode totalTonne totalCO2
Confidential Paper Shred service 20 01 01 75 0.84
I have also used a native SQL query inside Symfony2 but that returns the same result. Even removing any parameter to search with returns the one record (even though using this method, it should have displayed 100 records).
Here is the Entity file for the table in question:
<?php
namespace CWWA\CoreBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* EnviroFiguresUpload
*
* #ORM\Table(name="enviro_figures_upload")
* #ORM\Entity
*/
class EnviroFiguresUpload
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* #var integer
*
* #ORM\Column(name="account_number", type="integer", nullable=false)
*/
private $accountNumber;
/**
* #var integer
*
* #ORM\Column(name="customer_reference", type="integer", nullable=false)
*/
private $customerReference;
/**
* #var string
*
* #ORM\Column(name="billing_customer", type="string", length=500, nullable=false)
*/
private $billingCustomer;
/**
* #var string
*
* #ORM\Column(name="division", type="string", length=500, nullable=false)
*/
private $division;
/**
* #var string
*
* #ORM\Column(name="customer_site", type="string", length=500, nullable=false)
*/
private $customerSite;
/**
* #var string
*
* #ORM\Column(name="town", type="string", length=500, nullable=false)
*/
private $town;
/**
* #var string
*
* #ORM\Column(name="postcode", type="string", length=12, nullable=false)
*/
private $postcode;
/**
* #var integer
*
* #ORM\Column(name="job_number", type="integer", nullable=false)
*/
private $jobNumber;
/**
* #var string
*
* #ORM\Column(name="job_status", type="string", length=50, nullable=false)
*/
private $jobStatus;
/**
* #var string
*
* #ORM\Column(name="job_type", type="string", length=50, nullable=false)
*/
private $jobType;
/**
* #var string
*
* #ORM\Column(name="completion_date", type="string", length=45, nullable=false)
*/
private $completionDate;
/**
* #var string
*
* #ORM\Column(name="description", type="text", nullable=true)
*/
private $description;
/**
* #var string
*
* #ORM\Column(name="waste_type", type="string", length=100, nullable=true)
*/
private $wasteType;
/**
* #var string
*
* #ORM\Column(name="ewc_code", type="string", length=12, nullable=true)
*/
private $ewcCode;
/**
* #var string
*
* #ORM\Column(name="container", type="string", length=50, nullable=true)
*/
private $container;
/**
* #var integer
*
* #ORM\Column(name="quantity", type="integer", nullable=true)
*/
private $quantity;
/**
* #var string
*
* #ORM\Column(name="total_uom", type="string", length=45, nullable=true)
*/
private $totalUom;
/**
* #var string
*
* #ORM\Column(name="co2_saving", type="string", length=45, nullable=true)
*/
private $co2Saving;
/**
* #var string
*
* #ORM\Column(name="total_resource", type="string", length=45, nullable=true)
*/
private $totalResource;
/**
* #var string
*
* #ORM\Column(name="total_co2_saving", type="string", length=45, nullable=true)
*/
private $totalCo2Saving;
/**
* #var string
*
* #ORM\Column(name="recovery_rate", type="string", length=45, nullable=true)
*/
private $recoveryRate;
/**
* #var string
*
* #ORM\Column(name="disposal_method", type="string", length=120, nullable=true)
*/
private $disposalMethod;
/**
* #var string
*
* #ORM\Column(name="waste_hierarchy", type="string", length=120, nullable=true)
*/
private $wasteHierarchy;
/**
* #var string
*
* #ORM\Column(name="customer_order_date", type="string", length=45, nullable=true)
*/
private $customerOrderDate;
/**
* #var string
*
* #ORM\Column(name="job_notes", type="text", nullable=true)
*/
private $jobNotes;
/**
* #var string
*
* #ORM\Column(name="customer_ref_po", type="text", nullable=true)
*/
private $customerRefPo;
/**
* #var \Date
*
* #ORM\Column(name="uploaded", type="date", nullable=false)
*/
private $uploaded;
/**
* #var boolean
*
* #ORM\Column(name="processed", type="boolean", nullable=false)
*/
private $processed;
/**
* #var boolean
*
* #ORM\Column(name="deleted", type="boolean", nullable=false)
*/
private $deleted;
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set accountNumber
*
* #param integer $accountNumber
* #return EnviroFiguresUpload
*/
public function setAccountNumber($accountNumber)
{
$this->accountNumber = $accountNumber;
return $this;
}
/**
* Get accountNumber
*
* #return integer
*/
public function getAccountNumber()
{
return $this->accountNumber;
}
/**
* Set customerReference
*
* #param integer $customerReference
* #return EnviroFiguresUpload
*/
public function setCustomerReference($customerReference)
{
$this->customerReference = $customerReference;
return $this;
}
/**
* Get customerReference
*
* #return integer
*/
public function getCustomerReference()
{
return $this->customerReference;
}
/**
* Set billingCustomer
*
* #param string $billingCustomer
* #return EnviroFiguresUpload
*/
public function setBillingCustomer($billingCustomer)
{
$this->billingCustomer = $billingCustomer;
return $this;
}
/**
* Get billingCustomer
*
* #return string
*/
public function getBillingCustomer()
{
return $this->billingCustomer;
}
/**
* Set division
*
* #param string $division
* #return EnviroFiguresUpload
*/
public function setDivision($division)
{
$this->division = $division;
return $this;
}
/**
* Get division
*
* #return string
*/
public function getDivision()
{
return $this->division;
}
/**
* Set customerSite
*
* #param string $customerSite
* #return EnviroFiguresUpload
*/
public function setCustomerSite($customerSite)
{
$this->customerSite = $customerSite;
return $this;
}
/**
* Get customerSite
*
* #return string
*/
public function getCustomerSite()
{
return $this->customerSite;
}
/**
* Set town
*
* #param string $town
* #return EnviroFiguresUpload
*/
public function setTown($town)
{
$this->town = $town;
return $this;
}
/**
* Get town
*
* #return string
*/
public function getTown()
{
return $this->town;
}
/**
* Set postcode
*
* #param string $postcode
* #return EnviroFiguresUpload
*/
public function setPostcode($postcode)
{
$this->postcode = $postcode;
return $this;
}
/**
* Get postcode
*
* #return string
*/
public function getPostcode()
{
return $this->postcode;
}
/**
* Set jobNumber
*
* #param integer $jobNumber
* #return EnviroFiguresUpload
*/
public function setJobNumber($jobNumber)
{
$this->jobNumber = $jobNumber;
return $this;
}
/**
* Get jobNumber
*
* #return integer
*/
public function getJobNumber()
{
return $this->jobNumber;
}
/**
* Set jobStatus
*
* #param string $jobStatus
* #return EnviroFiguresUpload
*/
public function setJobStatus($jobStatus)
{
$this->jobStatus = $jobStatus;
return $this;
}
/**
* Get jobStatus
*
* #return string
*/
public function getJobStatus()
{
return $this->jobStatus;
}
/**
* Set jobType
*
* #param string $jobType
* #return EnviroFiguresUpload
*/
public function setJobType($jobType)
{
$this->jobType = $jobType;
return $this;
}
/**
* Get jobType
*
* #return string
*/
public function getJobType()
{
return $this->jobType;
}
/**
* Set completionDate
*
* #param string $completionDate
* #return EnviroFiguresUpload
*/
public function setCompletionDate($completionDate)
{
$this->completionDate = $completionDate;
return $this;
}
/**
* Get completionDate
*
* #return string
*/
public function getCompletionDate()
{
return $this->completionDate;
}
/**
* Set description
*
* #param string $description
* #return EnviroFiguresUpload
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Get description
*
* #return string
*/
public function getDescription()
{
return $this->description;
}
/**
* Set wasteType
*
* #param string $wasteType
* #return EnviroFiguresUpload
*/
public function setWasteType($wasteType)
{
$this->wasteType = $wasteType;
return $this;
}
/**
* Get wasteType
*
* #return string
*/
public function getWasteType()
{
return $this->wasteType;
}
/**
* Set ewcCode
*
* #param string $ewcCode
* #return EnviroFiguresUpload
*/
public function setEwcCode($ewcCode)
{
$this->ewcCode = $ewcCode;
return $this;
}
/**
* Get ewcCode
*
* #return string
*/
public function getEwcCode()
{
return $this->ewcCode;
}
/**
* Set container
*
* #param string $container
* #return EnviroFiguresUpload
*/
public function setContainer($container)
{
$this->container = $container;
return $this;
}
/**
* Get container
*
* #return string
*/
public function getContainer()
{
return $this->container;
}
/**
* Set quantity
*
* #param integer $quantity
* #return EnviroFiguresUpload
*/
public function setQuantity($quantity)
{
$this->quantity = $quantity;
return $this;
}
/**
* Get quantity
*
* #return integer
*/
public function getQuantity()
{
return $this->quantity;
}
/**
* Set totalUom
*
* #param string $totalUom
* #return EnviroFiguresUpload
*/
public function setTotalUom($totalUom)
{
$this->totalUom = $totalUom;
return $this;
}
/**
* Get totalUom
*
* #return string
*/
public function getTotalUom()
{
return $this->totalUom;
}
/**
* Set co2Saving
*
* #param string $co2Saving
* #return EnviroFiguresUpload
*/
public function setCo2Saving($co2Saving)
{
$this->co2Saving = $co2Saving;
return $this;
}
/**
* Get co2Saving
*
* #return string
*/
public function getCo2Saving()
{
return $this->co2Saving;
}
/**
* Set totalResource
*
* #param string $totalResource
* #return EnviroFiguresUpload
*/
public function setTotalResource($totalResource)
{
$this->totalResource = $totalResource;
return $this;
}
/**
* Get totalResource
*
* #return string
*/
public function getTotalResource()
{
return $this->totalResource;
}
/**
* Set totalCo2Saving
*
* #param string $totalCo2Saving
* #return EnviroFiguresUpload
*/
public function setTotalCo2Saving($totalCo2Saving)
{
$this->totalCo2Saving = $totalCo2Saving;
return $this;
}
/**
* Get totalCo2Saving
*
* #return string
*/
public function getTotalCo2Saving()
{
return $this->totalCo2Saving;
}
/**
* Set recoveryRate
*
* #param string $recoveryRate
* #return EnviroFiguresUpload
*/
public function setRecoveryRate($recoveryRate)
{
$this->recoveryRate = $recoveryRate;
return $this;
}
/**
* Get recoveryRate
*
* #return string
*/
public function getRecoveryRate()
{
return $this->recoveryRate;
}
/**
* Set disposalMethod
*
* #param string $disposalMethod
* #return EnviroFiguresUpload
*/
public function setDisposalMethod($disposalMethod)
{
$this->disposalMethod = $disposalMethod;
return $this;
}
/**
* Get disposalMethod
*
* #return string
*/
public function getDisposalMethod()
{
return $this->disposalMethod;
}
/**
* Set wasteHierarchy
*
* #param string $wasteHierarchy
* #return EnviroFiguresUpload
*/
public function setWasteHierarchy($wasteHierarchy)
{
$this->wasteHierarchy = $wasteHierarchy;
return $this;
}
/**
* Get wasteHierarchy
*
* #return string
*/
public function getWasteHierarchy()
{
return $this->wasteHierarchy;
}
/**
* Set customerOrderDate
*
* #param string $customerOrderDate
* #return EnviroFiguresUpload
*/
public function setCustomerOrderDate($customerOrderDate)
{
$this->customerOrderDate = $customerOrderDate;
return $this;
}
/**
* Get customerOrderDate
*
* #return string
*/
public function getCustomerOrderDate()
{
return $this->customerOrderDate;
}
/**
* Set jobNotes
*
* #param string $jobNotes
* #return EnviroFiguresUpload
*/
public function setJobNotes($jobNotes)
{
$this->jobNotes = $jobNotes;
return $this;
}
/**
* Get jobNotes
*
* #return string
*/
public function getJobNotes()
{
return $this->jobNotes;
}
/**
* Set customerRefPo
*
* #param string $customerRefPo
* #return EnviroFiguresUpload
*/
public function setCustomerRefPo($customerRefPo)
{
$this->customerRefPo = $customerRefPo;
return $this;
}
/**
* Get customerRefPo
*
* #return string
*/
public function getCustomerRefPo()
{
return $this->customerRefPo;
}
/**
* Set uploaded
*
* #param \Date $uploaded
* #return EnviroFiguresUpload
*/
public function setUploaded($uploaded)
{
$this->uploaded = $uploaded;
return $this;
}
/**
* Get uploaded
*
* #return \Date
*/
public function getUploaded()
{
return $this->uploaded;
}
/**
* Set processed
*
* #param boolean $processed
* #return EnviroFiguresUpload
*/
public function setProcessed($processed)
{
$this->processed = $processed;
return $this;
}
/**
* Get processed
*
* #return boolean
*/
public function getProcessed()
{
return $this->processed;
}
/**
* Set deleted
*
* #param boolean $deleted
* #return EnviroFiguresUpload
*/
public function setDeleted($deleted)
{
$this->deleted = $deleted;
return $this;
}
/**
* Get deleted
*
* #return boolean
*/
public function getDeleted()
{
return $this->deleted;
}
}
From what I've done so far, it does seem to be a Symfony2 issue as I can retrieve the data from MySQL quite easily. It just doesn't work here.
EDIT
I noticed that with the collation of the table, all the fields were set to latin1_swedish_ci. I've changed this to utf8_unicode_cibut this hasn't made a difference. I've also removed the blank checks in the query, again this still only returns one record.
EDIT 2
I've used EchoSQLLogger, and this is the output for this particular query inside Symfony2:
SELECT e0_.waste_type AS waste_type0, e0_.ewc_code AS ewc_code1, SUM(e0_.total_uom) AS sclr2, SUM(e0_.co2_saving) AS sclr3 FROM enviro_figures_upload e0_ WHERE e0_.customer_site = ? AND e0_.completion_date BETWEEN ? AND ? AND e0_.completion_date <> ? AND e0_.total_uom <> ? AND e0_.waste_type <> ? GROUP BY e0_.waste_type ORDER BY e0_.completion_date DESC
array(6) {
[0]=>
string(25) "CBS - Arena Park Coventry"
[1]=>
string(10) "2014-01-16"
[2]=>
string(10) "2015-01-16"
[3]=>
string(0) ""
[4]=>
string(0) ""
[5]=>
string(0) ""
}
array(6) {
[0]=>
int(2)
[1]=>
int(2)
[2]=>
int(2)
[3]=>
int(2)
[4]=>
int(2)
[5]=>
int(2)
}
It seems that you are comparing with empty sting AND total_uom != '' in custom query where in symfony query you are comparing with AND efu.totalUom != :zero.
Also group by statement is missing in symfony query.

Symfony 2/Doctrine - set value of forgein key

I had a problem like here. I followed the instructions of given solutions, but it generate another problem.
I've got two Entities:
namespace Acme\TyperBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* Mecz
*
* #ORM\Table()
* #ORM\Entity
*/
class Mecz
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
*/
private $id;
/**
* #var string
*
* #ORM\Column(name="druzyna1", type="string", length=255)
*/
private $druzyna1;
/**
* #var string
*
* #ORM\Column(name="druzyna2", type="string", length=255)
*/
private $druzyna2;
/**
* #var int
*
* #ORM\Column(name="bramki1", type="integer")
*/
private $bramki1;
/**
* #var int
*
* #ORM\Column(name="bramki2", type="integer")
*/
private $bramki2;
/**
* #var string
*
* #ORM\Column(name="wyniktyp", type="string", length=2)
*/
private $wyniktyp;
/**
* #var \DateTime
*
* #ORM\Column(name="data", type="datetime")
*/
private $data;
/**
* #var int
*
* #ORM\Column(name="typ1", type="float")
*/
private $typ1;
/**
* #var int
*
* #ORM\Column(name="typ1x", type="float")
*/
private $typ1x;
/**
* #var int
*
* #ORM\Column(name="typ2", type="float")
*/
private $typ2;
/**
* #var int
*
* #ORM\Column(name="typ2x", type="float")
*/
private $typ2x;
/**
* #var int
*
* #ORM\Column(name="typx", type="float")
*/
private $typx;
/**
* #ORM\OneToMany(targetEntity="Typy", mappedBy="meczid")
*/
protected $meczid;
public function __construct()
{
$this->products = new ArrayCollection();
}
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set druzyna1
*
* #param string $druzyna1
* #return Mecz
*/
public function setDruzyna1($druzyna1)
{
$this->druzyna1 = $druzyna1;
return $this;
}
/**
* Get druzyna1
*
* #return string
*/
public function getDruzyna1()
{
return $this->druzyna1;
}
/**
* Set druzyna2
*
* #param string $druzyna2
* #return Mecz
*/
public function setDruzyna2($druzyna2)
{
$this->druzyna2 = $druzyna2;
return $this;
}
/**
* Get druzyna2
*
* #return string
*/
public function getDruzyna2()
{
return $this->druzyna2;
}
/**
* Set bramki1
*
* #param integer $bramki1
* #return Mecz
*/
public function setBramki1($bramki1)
{
$this->bramki1 = $bramki1;
return $this;
}
/**
* Get bramki1
*
* #return integer
*/
public function getBramki1()
{
return $this->bramki1;
}
/**
* Set bramki2
*
* #param integer $bramki2
* #return Mecz
*/
public function setBramki2($bramki2)
{
$this->bramki2 = $bramki2;
return $this;
}
/**
* Get bramki2
*
* #return integer
*/
public function getBramki2()
{
return $this->bramki2;
}
/**
* Set wyniktyp
*
* #param string $wyniktyp
* #return Mecz
*/
public function setWyniktyp($wyniktyp)
{
$this->wyniktyp = $wyniktyp;
return $this;
}
/**
* Get wyniktyp
*
* #return string
*/
public function getWyniktyp()
{
return $this->wyniktyp;
}
/**
* Set data
*
* #param \DateTime $data
* #return Mecz
*/
public function setData($data)
{
$this->data = $data;
return $this;
}
/**
* Get data
*
* #return \DateTime
*/
public function getData()
{
return $this->data;
}
/**
* Set typ1
*
* #param float $typ1
* #return Mecz
*/
public function setTyp1($typ1)
{
$this->typ1 = $typ1;
return $this;
}
/**
* Get typ1
*
* #return float
*/
public function getTyp1()
{
return $this->typ1;
}
/**
* Set typ2
*
* #param float $typ2
* #return Mecz
*/
public function setTyp2($typ2)
{
$this->typ2 = $typ2;
return $this;
}
/**
* Get typ2
*
* #return float
*/
public function getTyp2()
{
return $this->typ2;
}
/**
* Set typ1x
*
* #param float $typ1x
* #return Mecz
*/
public function setTyp1x($typ1x)
{
$this->typ1x = $typ1x;
return $this;
}
/**
* Get typ1x
*
* #return float
*/
public function getTyp1x()
{
return $this->typ1x;
}
/**
* Set typ2x
*
* #param float $typ2x
* #return Mecz
*/
public function setTyp2x($typ2x)
{
$this->typ2x = $typ2x;
return $this;
}
/**
* Get typ2x
*
* #return float
*/
public function getTyp2x()
{
return $this->typ2x;
}
/**
* Set typx
*
* #param float $typx
* #return Mecz
*/
public function setTypx($typx)
{
$this->typx = $typx;
return $this;
}
/**
* Get typx
*
* #return float
*/
public function getTypx()
{
return $this->typx;
}
/**
* Set id
*
* #param integer $id
* #return Mecz
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* Add meczid
*
* #param \Acme\TyperBundle\Entity\Typy $meczid
* #return Mecz
*/
public function addMeczid(\Acme\TyperBundle\Entity\Typy $meczid)
{
$this->meczid[] = $meczid;
return $this;
}
/**
* Remove meczid
*
* #param \Acme\TyperBundle\Entity\Typy $meczid
*/
public function removeMeczid(\Acme\TyperBundle\Entity\Typy $meczid)
{
$this->meczid->removeElement($meczid);
}
/**
* Get meczid
*
* #return \Doctrine\Common\Collections\Collection
*/
public function getMeczid()
{
return $this->meczid;
}
/**
* Add mecz
*
* #param \Acme\TyperBundle\Entity\Typy $mecz
* #return Mecz
*/
public function addMecz(\Acme\TyperBundle\Entity\Typy $mecz)
{
$this->mecz[] = $mecz;
return $this;
}
/**
* Remove mecz
*
* #param \Acme\TyperBundle\Entity\Typy $mecz
*/
public function removeMecz(\Acme\TyperBundle\Entity\Typy $mecz)
{
$this->mecz->removeElement($mecz);
}
/**
* Get mecz
*
* #return \Doctrine\Common\Collections\Collection
*/
public function getMecz()
{
return $this->mecz;
}
/**
* Add mecztyp
*
* #param \Acme\TyperBundle\Entity\Typy $mecztyp
* #return Mecz
*/
public function addMecztyp(\Acme\TyperBundle\Entity\Typy $mecztyp)
{
$this->mecztyp[] = $mecztyp;
return $this;
}
/**
* Remove mecztyp
*
* #param \Acme\TyperBundle\Entity\Typy $mecztyp
*/
public function removeMecztyp(\Acme\TyperBundle\Entity\Typy $mecztyp)
{
$this->mecztyp->removeElement($mecztyp);
}
/**
* Get mecztyp
*
* #return \Doctrine\Common\Collections\Collection
*/
public function getMecztyp()
{
return $this->mecztyp;
}
}
and
namespace Acme\TyperBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Typy
*
* #ORM\Table()
* #ORM\Entity
*/
class Typy
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var integer
*
* #ORM\Column(name="id_kuponu", type="integer")
*/
private $id_kuponu;
/**
* #var integer
*
* #ORM\Column(name="id_meczu", type="integer")
*/
private $id_meczu;
/**
* #var string
*
* #ORM\Column(name="typ", type="string", length=2)
*/
private $typ;
/**
* #var int
*
* #ORM\Column(name="stawka", type="float")
*/
private $stawka;
/**
* #ORM\ManyToOne(targetEntity="Mecz", inversedBy="meczid",cascade={"persist"})
* #ORM\JoinColumn(name="id_meczu", referencedColumnName="id")
*/
private $meczid;
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set id_kuponu
*
* #param integer $idKuponu
* #return Typy
*/
public function setIdKuponu($idKuponu)
{
$this->id_kuponu = $idKuponu;
return $this;
}
/**
* Get id_kuponu
*
* #return integer
*/
public function getIdKuponu()
{
return $this->id_kuponu;
}
/**
* Set id_meczu
*
* #param integer $idMeczu
* #return Typy
*/
public function setIdMeczu($idMeczu)
{
$this->id_meczu = $idMeczu;
return $this;
}
/**
* Get id_meczu
*
* #return integer
*/
public function getIdMeczu()
{
return $this->id_meczu;
}
/**
* Set typ
*
* #param string $typ
* #return Typy
*/
public function setTyp($typ)
{
$this->typ = $typ;
return $this;
}
/**
* Get typ
*
* #return string
*/
public function getTyp()
{
return $this->typ;
}
/**
* Set meczid
*
* #param \Acme\TyperBundle\Entity\Mecz $meczid
* #return Typy
*/
public function setMeczid(\Acme\TyperBundle\Entity\Mecz $meczid = null)
{
$this->meczid = $meczid;
return $this;
}
/**
* Get meczid
*
* #return \Acme\TyperBundle\Entity\Mecz
*/
public function getMeczid()
{
return $this->meczid;
}
/**
* Set stawka
*
* #param float $stawka
* #return Typy
*/
public function setStawka($stawka)
{
$this->stawka = $stawka;
return $this;
}
/**
* Get stawka
*
* #return float
*/
public function getStawka()
{
return $this->stawka;
}
}
So I want to use this code to insert data to table:
$mecz = new Mecz();
$mecz->setId($id_meczu);
$typs = new Typy();
$et = $this->getDoctrine()->getManager();
$typs->setIdKuponu($id_kuponu);
$typs->setMeczid($mecz);
$typs->setTyp($typ);
$typs->setStawka($stawka);
$et->persist($typs);
$et->flush();
And i get exception:
An exception occurred while executing 'INSERT INTO Mecz (id, druzyna1, druzyna2, bramki1, bramki2, wyniktyp, data, typ1, typ1x, typ2, typ2x, typx) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' with params ["2", null, null, null, null, null, null, null, null, null, null, null]:
I don't know why, because i want to instert data to "Typy" table not "Mecz" table. Can anyone could help me?
The problem is the following:
You have the field Typy::meczid, but this field does (from the perspecitve of Doctrine) not hold a numeric ID, but a reference to a Mecz instance. Therefore the name meczid is misleading, it should be Typy::mecz. I'd recommend renaming the field and the accessors for the sake of consistency.
Now the Typy entity expects a Mecz entity to be set, which you do: You create a new Mecz(), and assign it to Typy with $typs->setMeczid($mecz);. BUT: The Mecz instance is lacking lots all properties except the ID. (By the way, in Doctrine IDs should generally be autogenerated, not by the business logic.) As the Typy entity depends on Mecz, the Mecz must be persisted first, so its reference can be stored with the Typy.
Bottom line: You must fill the generated Mecz with the missing properties.
Hint: To avoid that this type of error happens on the DB level, you should use Symfony's entity validation component. This will allow a much better error handling; both during development, and in production.

Resources