Doctrine orm zf2和x2B;Doctrine2完整性约束冲突:1048列'';不能为空

Doctrine orm zf2和x2B;Doctrine2完整性约束冲突:1048列'';不能为空,doctrine-orm,zend-framework2,constraints,integrity,Doctrine Orm,Zend Framework2,Constraints,Integrity,我对Doctrine2有一个问题,它引发了以下异常: An exception occurred while executing 'INSERT INTO sesion (Contrasena, Estado, UsuarioIdentificacion) VALUES (?, ?, ?)' with params ["j15474874654j", "1", null]: SQLSTATE[23000]: Integrity constraint violation: 1048 Column

我对Doctrine2有一个问题,它引发了以下异常:

An exception occurred while executing 'INSERT INTO sesion (Contrasena, Estado, UsuarioIdentificacion) VALUES (?, ?, ?)' with params ["j15474874654j", "1", null]:

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'UsuarioIdentificacion' cannot be null
我是信条2的初学者,我无法解决这个错误,我认为错误在于人际关系。我读过其他类似的问题,但我没有成功。 我将非常感谢你的帮助。这是我的代码:

在我的控制器中:

            $usuario = new Usuario();
            $data = $request->getPost();
            $usuario->setNombre($data['nombre']);
            $usuario->setApellidos($data['apellidos']);
            $usuario->setIdentificacion($data['identificacion']);                  
            $usuario->setTitulo($data['titulo']);
            $usuario->setContacto($data['contacto']);
            $usuario->setCorreo($data['correo'] . "@correounivalle.edu.co");                   


            $sesion = new Sesion(); 
            $sesion->setUsuarioidentificacion($usuario);

            $sesion->setEstado("1");
            $sesion->setContrasena($data['nombre'][0].$data['identificacion'].$data['apellidos'][0]);


            $em->persist($usuario);
            $em->persist($sesion);
            $em->flush();
usuario类:

<?php
namespace DBAL\Entity;
use Doctrine\ORM\Mapping as ORM;

/**
 * Usuario
 *
 * @ORM\Table(name="usuario", uniqueConstraints={@ORM\UniqueConstraint(name="Identificacion", columns={"Identificacion"}), @ORM\UniqueConstraint(name="Correo", columns={"Correo"})})
 * @ORM\Entity
 * @ORM\Entity(repositoryClass="DBAL\Repository\UsuarioRepository")
 */
class Usuario
{
    /**
     * @var integer
     *
     * @ORM\Column(name="Id", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;

/**
 * @var integer
 *
 * @ORM\Column(name="Identificacion", type="integer", nullable=false)
 */
private $identificacion;

/**
 * @var string
 *
 * @ORM\Column(name="Nombre", type="string", length=50, nullable=false)
 */
private $nombre;

/**
 * @var string
 *
 * @ORM\Column(name="Apellidos", type="string", length=50, nullable=false)
 */
private $apellidos;

/**
 * @var string
 *
 * @ORM\Column(name="Correo", type="string", length=100, nullable=false)
 */
private $correo;

/**
 * @var integer
 *
 * @ORM\Column(name="Contacto", type="integer", nullable=true)
 */
private $contacto;

/**
 * @var string
 *
 * @ORM\Column(name="Titulo", type="string", length=20, nullable=true)
 */
private $titulo;



/*with their respective setter and getter*/

<?php
namespace DBAL\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * Sesion
 *
 * @ORM\Table(name="sesion", indexes={@ORM\Index(name="UsuarioIdentificacion", columns={"UsuarioIdentificacion"}), @ORM\Index(name="sesion", columns={"UsuarioIdentificacion"})})
 * @ORM\Entity
 */
class Sesion
{
    /**
     * @var integer
     *
     * @ORM\Column(name="Id", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;
    /**
     * @var string
     *
     * @ORM\Column(name="Contrasena", type="string", length=50, nullable=false)
     */
    private $contrasena;

    /**
     * @var boolean
     *
     * @ORM\Column(name="Estado", type="boolean", nullable=false)
     */
    private $estado;

    /**
     * @var \Usuario
     *
     * 
     * @ORM\OneToOne(targetEntity="Usuario")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="UsuarioIdentificacion", referencedColumnName="Correo")
     * })
     */
    private $usuarioidentificacion;

    /**
     * @var \Doctrine\Common\Collections\Collection
     *
     * @ORM\ManyToMany(targetEntity="Roles", mappedBy="sesionusuarioidentificacion")
     */
    private $rolesid;

    /**
     * Constructor
     */
    public function __construct()
    {
        $this->rolesid = new \Doctrine\Common\Collections\ArrayCollection();
    }


    /**
     * Get id
     *
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }


    /**
     * Set contrasena
     *
     * @param string $contrasena
     *
     * @return Sesion
     */
    public function setContrasena($contrasena)
    {
        $this->contrasena = $contrasena;

        return $this;
    }

    /**
     * Get contrasena
     *
     * @return string
     */
    public function getContrasena()
    {
        return $this->contrasena;
    }

    /**
     * Set estado
     *
     * @param boolean $estado
     *
     * @return Sesion
     */
    public function setEstado($estado)
    {
        $this->estado = $estado;

        return $this;
    }

    /**
     * Get estado
     *
     * @return boolean
     */
    public function getEstado()
    {
        return $this->estado;
    }

    /**
     * Set usuarioidentificacion
     *
     * @param \DBAL\Entity\Usuario $usuarioidentificacion
     *
     * @return Sesion
     */
    public function setUsuarioidentificacion(\DBAL\Entity\Usuario $usuarioidentificacion)
    {
        $this->usuarioidentificacion = $usuarioidentificacion;

        return $this;
    }

    /**
     * Get usuarioidentificacion
     *
     * @return \Usuario
     */
    public function getUsuarioidentificacion()
    {
        return $this->usuarioidentificacion;
    }

    /**
     * Add rolesid
     *
     * @param \Roles $rolesid
     *
     * @return Sesion
     */
    public function addRolesid(\Roles $rolesid)
    {
        $this->rolesid[] = $rolesid;

        return $this;
    }

    /**
     * Remove rolesid
     *
     * @param \Roles $rolesid
     */
    public function removeRolesid(\Roles $rolesid)
    {
        $this->rolesid->removeElement($rolesid);
    }

    /**
     * Get rolesid
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getRolesid()
    {
        return $this->rolesid;
    }