I am trying to populate the database with the object User and Person by executing
persist and flush.
First of all, I am creating the Person object and persis
I have finally found the problem:
When creating the object user, instead of setting those fields
$user->setDegree();
$user->setWorkplace();
$user->setJobtype();
$user->setResearchField();
as objects (because of the OneToMany relation), I gived here only a string, from the form.
So, for those fields, the code would be:
$degree = $em->getRepository('SciForumVersion2Bundle:Degree')->findOneById($enquiry->getDegree());
$workplace = $em->getRepository('SciForumVersion2Bundle:Workplace')->findOneById($enquiry->getWorkplace());
$job_type = $em->getRepository('SciForumVersion2Bundle:JobType')->findOneById($enquiry->getJobtype());
$research_field = $em->getRepository('SciForumVersion2Bundle:ResearchField')->findOneById($enquiry->getResearchField());
And then:
$user->setPerson($person);
$user->setWorkplace($workplace);
$user->setJobtype($job_type);
$user->setResearchField($research_field);
So: Be careful when you are getting this kind of warnings, you probably have to check if you are populating your object in the right way.