i have two entities named UserCode and Question that have relation between question columns and when i run doctrine:schema:validate it s ok
but my problem is when i add
#ORM\Entity(repositoryClass="AppBundle\Repository\UserCodeRepository")
at top of UserCode entity i get this error !!
* The association AppBundle\Entity\UserCode#question refers to the inverse side field AppBundle\Entity\Question#question which is not defined as association.
* The association AppBundle\Entity\UserCode#question refers to the inverse side field AppBundle\Entity\Question#question which does not exist.
Question entity :
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use AppBundle\Entity\UserCode;
/**
* Question
*
* #ORM\Table(name="question")
* #ORM\Entity(repositoryClass="AppBundle\Repository\QuestionRepository")
*/
class Question
{
/**
* #var int
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var string
*
* #ORM\Column(name="question", type="text")
* #ORM\OneToMany(targetEntity="AppBundle\Entity\UserCode", mappedBy="question")
*/
private $question;
/**
* Get id
*
* #return int
*/
public function getId()
{
return $this->id;
}
/**
* Set question
*
* #param string $question
*
* #return Question
*/
public function setQuestion($question)
{
$this->question = $question;
return $this;
}
/**
* Get question
*
* #return string
*/
public function getQuestion()
{
return $this->question;
}
}
and this is my UserCode entity:
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\JoinColumn;
use Symfony\Component\Validator\Constraints as Assert;
/**
* UserCode
*
* #ORM\Table(name="user_code")
* #ORM\Entity(repositoryClass="AppBundle\Repository\UserCodeRepository")
*/
class UserCode
{
/**
* #var int
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #ORM\ManyToOne(targetEntity="AppBundle\Entity\Question", inversedBy="question")
* #ORM\JoinColumn(name="question", referencedColumnName="id")
*/
private $question;
/**
* Get id
*
* #return int
*/
public function getId()
{
return $this->id;
}
/**
* Set question
*
* #param \AppBundle\Entity\Question $question
*
* #return UserCode
*/
public function setQuestion(\AppBundle\Entity\Question $question = null)
{
$this->question = $question;
return $this;
}
/**
* Get question
*
* #return \AppBundle\Entity\Question
*/
public function getQuestion()
{
return $this->question;
}
}
remove
#ORM\JoinColumn(name="question", referencedColumnName="id")
from
UserCode entity and
* #var string
*
* #ORM\Column(name="question", type="text")
from question entity
it will work perfectly :)
Related
I want to insert into my joint-table RoleUser idUser and idRole ,but in the function I should add an object user and role
How can I do that?
the joint table RoleUser :
/**
* RoleUser
*
* #ORM\Table(name="role_user", indexes={#ORM\Index(name="fk_role_user_id", columns={"ref_user_id"}), #ORM\Index(name="fk_role_id", columns={"ref_role_id"})})
* #ORM\Entity(repositoryClass="AppBundle\Repository\RoleUserRepository")
*/
class RoleUser
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* #var \AppBundle\Entity\Role
*
* #ORM\ManyToOne(targetEntity="AppBundle\Entity\Role")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="ref_role_id", referencedColumnName="id")
* })
*/
private $refRole;
/**
* #var \AppBundle\Entity\User
*
* #ORM\ManyToOne(targetEntity="AppBundle\Entity\User")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="ref_user_id", referencedColumnName="id")
* })
*/
private $refUser;
/**
* #param Role $refRole
*/
public function setRefRole(\AppBundle\Entity\Role $refRole)
{
$this->refRole = $refRole;
}
/**
* #param User $refUser
*/
public function setRefUser(\AppBundle\Entity\User $refUser)
{
$this->refUser= $refUser;
}
}
In my controller I want to insert the following (for a particular case I should insert in the background, the user can't choose his role):
$user = new User();
$role= new Role();
$roleUser =new RoleUser();
$roleUser->setRefUser($user->getId());
$roleUser->setRefRole(1);
but I konw that I should pass a user and a role :
$roleUser->setRefUser($user);
$roleUser->setRefRole($role);
You need to use a relation ManyToMany instead of OneToMany and remove your Entity RoleUser. you can follow the next example in the documentation official, to mapping this kind of relations.
For the save:
In this case you need to add in the two entities this relation:
<?php
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* Location
*
* #ORM\Table(name="location")
* #ORM\Entity
*/
class Location
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* <p>Represent the </p>
* #ORM\ManyToMany(targetEntity="LogoLocation", mappedBy="locations")
*/
private $logoLocationCurse;
/**
* Location constructor.
*/
public function __construct()
{
$this->logoLocationCurse = new ArrayCollection();
}
public function addlogoLocationCurse(LogoLocation $location)
{
$this->logoLocationCurse->add($location);
$location->addLocations($this);
}
public function removeLogo(LogoLocation $location)
{
$this->logoLocationCurse->removeElement($location);
$location->removeLocation($this);
}
}
<?php
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use \DateTime;
/**
* Class LogoLocation
* #ORM\Table(name="logo_location_curso")
* #ORM\Entity
*/
class LogoLocation
{
/**
* #var integer
* #ORM\Id
* #ORM\Column(type="integer")
* #ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* Many Users have Many Groups.
* #ORM\ManyToMany(targetEntity="Location", inversedBy="logocurso")
* #ORM\JoinTable(name="logo_locations")
*/
private $locations;
/**
* LogoLocation constructor.
*/
public function __construct()
{
$this->locations = new ArrayCollection();
}
/**
* #param Location $location
*/
public function addLocations(Location $location)
{
$this->locations->add($location);
}
/**
* #param Location $location
*/
public function removeLocation(Location $location)
{
$this->locations->removeElement($location);
}
/**
*
*/
public function removeLocations()
{
/** #var Location $location */
foreach ($this->locations as $location) {
$location->removeLogo($this);
}
}
}
and make the flush
I am currently facing one problem with mapping I hope some one would helpe me.
I have two table describe bellow..
unitid(primary_key, column_1)
For example data here
unitid(1,22)
unitid (2,33)
mappaths(primary key, forign_key (column_1), forign_key(column_1))
For example data here
mappaths (1,22,33)
mappaths (2,33,22)
unitid has some kind of units defines while this mappaths table define the specific paths based on the unitid
Now when I run the doctrain2 mapping It give me some kind these entities pluse these following mapping information
Entity class
<?php
namespace ApiMaps\ApiMapBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Mappaths
*
* #ORM\Table(name="mappaths", indexes={#ORM\Index(name="idx_45b7519fa3995845", columns={"ref_unitids1"}), #ORM\Index(name="idx_45b7519f3a9009ff", columns={"ref_unitids2"})})
* #ORM\Entity
*/
class Mappaths
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer", nullable=false)
* #ORM\Id
* #ORM\GeneratedValue(strategy="SEQUENCE")
* #ORM\SequenceGenerator(sequenceName="mappaths_id_seq", allocationSize=1, initialValue=1)
*/
private $id;
/**
* #var integer
*
* #ORM\Column(name="normalvalue", type="smallint", nullable=true)
*/
private $normalvalue;
/**
*
* #var \Unitids
* #ORM\ManyToOne(targetEntity="Unitids",cascade={"all"},fetch="LAZY")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="ref_unitids2", referencedColumnName="databaseid")
* })
*/
private $refUnitids2;
/**
* #var \Unitids
* #ORM\ManyToOne(targetEntity="Unitids",cascade={"all"},fetch="LAZY")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="ref_unitids1", referencedColumnName="databaseid")
* })
*/
private $refUnitids1;
/**
* Set normalvalue
*
* #param integer $normalvalue
*
* #return Mappaths
*/
public function setNormalvalue($normalvalue)
{
$this->normalvalue = $normalvalue;
return $this;
}
/**
* Get normalvalue
*
* #return integer
*/
public function getNormalvalue()
{
return $this->normalvalue;
}
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set refUnitids1
*
* #param \ApiMaps\ApiMapBundle\Entity\Unitids $refUnitids1
*
* #return Mappaths
*/
public function setRefUnitids1(\ApiMaps\ApiMapBundle\Entity\Unitids $refUnitids1 = null)
{
$this->refUnitids1 = $refUnitids1;
return $this;
}
/**
* Get refUnitids1
*
* #return \ApiMaps\ApiMapBundle\Entity\Unitids
*/
public function getRefUnitids1()
{
return $this->refUnitids1;
}
/**
* Set refUnitids2
*
* #param \ApiMaps\ApiMapBundle\Entity\Unitids $refUnitids2
*
* #return Mappaths
*/
public function setRefUnitids2(\ApiMaps\ApiMapBundle\Entity\Unitids $refUnitids2 = null)
{
$this->refUnitids2 = $refUnitids2;
return $this;
}
/**
* Get refUnitids2
*
* #return \ApiMaps\ApiMapBundle\Entity\Unitids
*/
public function getRefUnitids2()
{
return $this->refUnitids2;
}
}
and mappaths.php
<?php
namespace ApiMaps\ApiMapBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Mappaths
*
* #ORM\Table(name="mappaths", indexes={#ORM\Index(name="idx_45b7519fa3995845", columns={"ref_unitids1"}), #ORM\Index(name="idx_45b7519f3a9009ff", columns={"ref_unitids2"})})
* #ORM\Entity
*/
class Mappaths
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer", nullable=false)
* #ORM\Id
* #ORM\GeneratedValue(strategy="SEQUENCE")
* #ORM\SequenceGenerator(sequenceName="mappaths_id_seq", allocationSize=1, initialValue=1)
*/
private $id;
/**
* #var integer
*
* #ORM\Column(name="normalvalue", type="smallint", nullable=true)
*/
private $normalvalue;
/**
*
* #var \Unitids
* #ORM\ManyToOne(targetEntity="Unitids",cascade={"all"},fetch="LAZY")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="ref_unitids2", referencedColumnName="databaseid")
* })
*/
private $refUnitids2;
/**
* #var \Unitids
* #ORM\ManyToOne(targetEntity="Unitids",cascade={"all"},fetch="LAZY")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="ref_unitids1", referencedColumnName="databaseid")
* })
*/
private $refUnitids1;
/**
* Set normalvalue
*
* #param integer $normalvalue
*
* #return Mappaths
*/
public function setNormalvalue($normalvalue)
{
$this->normalvalue = $normalvalue;
return $this;
}
/**
* Get normalvalue
*
* #return integer
*/
public function getNormalvalue()
{
return $this->normalvalue;
}
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set refUnitids1
*
* #param \ApiMaps\ApiMapBundle\Entity\Unitids $refUnitids1
*
* #return Mappaths
*/
public function setRefUnitids1(\ApiMaps\ApiMapBundle\Entity\Unitids $refUnitids1 = null)
{
$this->refUnitids1 = $refUnitids1;
return $this;
}
/**
* Get refUnitids1
*
* #return \ApiMaps\ApiMapBundle\Entity\Unitids
*/
public function getRefUnitids1()
{
return $this->refUnitids1;
}
/**
* Set refUnitids2
*
* #param \ApiMaps\ApiMapBundle\Entity\Unitids $refUnitids2
*
* #return Mappaths
*/
public function setRefUnitids2(\ApiMaps\ApiMapBundle\Entity\Unitids $refUnitids2 = null)
{
$this->refUnitids2 = $refUnitids2;
return $this;
}
/**
* Get refUnitids2
*
* #return \ApiMaps\ApiMapBundle\Entity\Unitids
*/
public function getRefUnitids2()
{
return $this->refUnitids2;
}
}
now when I run the project it give me the following error
37. public static function missingPrimaryKeyValue($className, $idField)
38. {
39. return new self(sprintf("Missing value for primary key %s on %s", $idField, $className));
40. }
41. }
It seems to me that this primary key of unitsid could not get by mapping
Any solution would be appreciated
First I think you haven't understand the ORM (object relational mapping) concept in your entities you don't map these relations by foreign keys, doctrine will do it for you, in the entities layer you have to map objects and only objects
Second you need to map your entities relations by using orm annotations or xml configuration to describe those relations if they are oneToOne or ManyToOne or OneToMany or ManyToMany relation
Third You are having this error because you haven't set a value to the entity id, to do that you have two options : auto generate the id or set it manually before persisting object
see this
i working with Symfony2 and Doctrine ORM using MySql.
When i try uo use:
php app/console doctrine:migration:diff
i have this error:
[Doctrine\DBAL\Schema\SchemaException]
The table with name 'blog.post' already exists.
My code in Post.php (i use annotation) is:
namespace Blog\ModelBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Post
*
* #ORM\Table()
* #ORM\Entity
*/
class Post extends Timestampable
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var string
*
* #ORM\Column(name="title", type="string", length=150)
* #Assert\NotBlank
*/
private $title;
/**
* #var string
*
* #ORM\Column(name="body", type="text")
* #Assert\NotBlank
*/
private $body;
/**
* #var Author
* #ORM\ManyToOne (targetEntity="Author", inversedBy="posts")
* #ORM\JoinColumn (name="author_id", referencedColumnName="id", nullable=false)
* #Assert\NotBlank
*/
private $author;
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set title
*
* #param string $title
* #return Post
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* Get title
*
* #return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Set body
*
* #param string $body
* #return Post
*/
public function setBody($body)
{
$this->body = $body;
return $this;
}
/**
* Get body
*
* #return string
*/
public function getBody()
{
return $this->body;
}
/**
* Set author
*
* #param \Blog\ModelBundle\Entity\Author $author
* #return Post
*/
public function setAuthor(Author $author)
{
$this->author = $author;
return $this;
}
/**
* Get author
*
* #return \Blog\ModelBundle\Entity\Author
*/
public function getAuthor()
{
return $this->author;
}
}
I try to define * #ORM\Table(name="Post").
Can you help me with this type of error.
Sorry for my bad english.
Your mapping looks incorrect. The ManyToOne declaration does not need an inversedBy attribute if you're not using a join table. You also do not need to specify the #var since it already knows it's using the entity. Try this:
/**
* #ORM\ManyToOne(targetEntity="Author")
* #ORM\JoinColumn(name="author_id", referencedColumnName="id")
**/
private $author;
One other thing to do is to check that you're not trying to declare the same entity in another bundle, this will also cause the "table already exists" error.
Also, to avoid using full path entity references in the getter and setter, just include the entity in the use statemnets at the top of the class, then you only need write the entity name:
/**
* set Author
*
* #param Author $author
*
* #return Post
/**
After typing this command (php app/console generate:doctrine:entities CoreBundle:Post
) by Terminal the error below appears, How can I solve this?
[Doctrine\Common\Annotations\AnnotationException]
[Semantical Error] The annotation
"#Symfony\Component\Validator\Constraints" in property
Blog\CoreBundle\Entity\Post::$body does not exist, or could not be
auto-loaded.
Source Code:
namespace Blog\CoreBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Post
*
* #ORM\Table()
* #ORM\Entity
*/
class Post extends Timestamp
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var string
*
* #ORM\Column(name="title", type="string", length=255)
*/
private $title;
/**
* #var string
*
* #ORM\Column(name="body", type="text")
*
* #Assert|NotBlank
*/
private $body;
/**
* #var Author
*
* #ORM\ManyToOne(targetEntity="Author", inversedBy="posts")
* #ORM\JoinColumn(name="author_id", referecedColumnName="id", nullable=false)
*/
protected $author;
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set title
*
* #param string $title
* #return Post
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* Get title
*
* #return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Set body
*
* #param string $body
* #return Post
*/
public function setBody($body)
{
$this->body = $body;
return $this;
}
/**
* Get body
*
* #return string
*/
public function getBody()
{
return $this->body;
}
}
I think you have a typo in the #Assert annotation on the $body property. You're using a pipe symbol | instead of a backslash \.
I am trying to build a log of some action performed on some site using Symfony2 and Doctrine. I have 2 tables Sites and Logs. The Logs table will contain a siteid which is a foreign key to the id column of sites table. The Logs table can have multiple logs for same site.
When I try to insert an entry in the log table I get siteid is null error.
Here is my code:
Sites Entity:
<?php
namespace A\SHB\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Sites
*
* #ORM\Table()
* #ORM\Entity(repositoryClass="A\SHB\Entity\SitesRepository")
*/
class Sites
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var ArrayCollection $siteLog
*
* #ORM\OneToMany(targetEntity="Logs", mappedBy="log", cascade={"persist"})
* #ORM\OrderBy({"siteid" = "ASC"})
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="log_id", referencedColumnName="siteid")
* })
*/
private $siteLog;
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Constructor
*/
public function __construct()
{
$this->siteLog = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Add siteLog
*
* #param \A\SHB\Entity\SiteLog $siteLog
* #return Sites
*/
public function addSiteLog(\A\SHB\Entity\SiteLog $siteLog)
{
$this->siteLog[] = $siteLog;
return $this;
}
/**
* Remove siteLog
*
* #param \A\SHB\Entity\SiteLog $siteLog
*/
public function removeSiteLog(\A\SHB\Entity\SiteLog $siteLog)
{
$this->siteLog->removeElement($siteLog);
}
/**
* Get siteLog
*
* #return \Doctrine\Common\Collections\Collection
*/
public function getSiteLog()
{
return $this->siteLog;
}
}
Logs Entity:
<?php
namespace A\SHB\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Logs
*
* #ORM\Table()
* #ORM\Entity(repositoryClass="A\SHB\Entity\LogsRepository")
*/
class Logs
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var integer
*
* #ORM\Column(name="siteid", type="integer")
*/
private $siteid;
/**
* #var integer
*
* #ORM\Column(name="dateline", type="integer")
*/
private $dateline;
/**
* #var Log
*
* #ORM\ManyToOne(targetEntity="Sites")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="site_id", referencedColumnName="id")
* })
*/
private $log;
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set siteid
*
* #param integer $siteid
* #return Logs
*/
public function setSiteid($siteid)
{
$this->siteid = $siteid;
return $this;
}
/**
* Get siteid
*
* #return integer
*/
public function getSiteid()
{
return $this->siteid;
}
/**
* Set dateline
*
* #param integer $dateline
* #return Logs
*/
public function setDateline($dateline)
{
$this->dateline = $dateline;
return $this;
}
/**
* Get dateline
*
* #return integer
*/
public function getDateline()
{
return $this->dateline;
}
/**
* Set log
*
* #param \A\SHB\Entity\Log $log
* #return Logs
*/
public function setLog(\A\SHB\Entity\Log $log = null)
{
$this->log = $log;
return $this;
}
/**
* Get log
*
* #return \A\SHB\Entity\Log
*/
public function getLog()
{
return $this->log;
}
}
Controller :
public function indexAction()
{
$sites = $this->getDoctrine()->getRepository('ASHB:Sites')->findAll();
foreach ($sites as $site)
{
$host = $site->getForum();
// Do something ....
$log = new Logs();
$log->setSiteid($site->getId());
$log->setDateline($temp['dateline']);
$em = $this->getDoctrine()->getManager();
$em->persist($log);
$em->flush();
}
return $this->render('ASHB:Default:index.html.twig', array('sites' => $output, 'counters' => $counters));
}
Now when I run this code, I get the following error:
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'siteid' cannot be null"
If I var_dump $log, before $em->persist($log);, the siteid is there. I am not sure what is wrong and why the siteid is getting set to null.
Update 1:
I tried to make the following changes and still get the same error:
/**
* #var Log
*
* #ORM\ManyToOne(targetEntity="Sites", inversedBy="siteLog")
*/
private $log;
OneToMany doesn't need a JoinColumn. So it should look like, according to the documentation.
class Sites
{
/**
* #ORM\OneToMany(targetEntity="Logs", mappedBy="log")
*/
private $site_log;
}
class Logs
{
/**
* #ORM\ManyToOne(targetEntity="Sites", inversedBy="site_log")
* #ORM\JoinColumn(name="site_id", referencedColumnName="id")
*/
private $log;
}
orderBy and cascade were ignored for simplicity.
you have problem in your sturcture,
Remove this from Logs Entity
/**
* #var integer
*
* #ORM\Column(name="siteid", type="integer")
*/
private $siteid;
And then replace this part
/**
* #var Log
*
* #ORM\ManyToOne(targetEntity="Sites")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="site_id", referencedColumnName="id")
* })
*/
private $log;
with
/**
* #var Log
*
* #ORM\ManyToOne(targetEntity="Sites" inversedBy="logs")
*/
private $site;
And in your sites entity replace this with
/**
* #var ArrayCollection $siteLog
*
* #ORM\OneToMany(targetEntity="Logs", mappedBy="logs", cascade={"persist"})
* #ORM\OrderBy({"siteid" = "ASC"})
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="log_id", referencedColumnName="siteid")
* })
*/
private $logs;
with
/**
* #var ArrayCollection $siteLog
*
* #ORM\OneToMany(targetEntity="Logs", mappedBy="site", cascade={"persist"})
* #ORM\OrderBy({"siteid" = "ASC"})
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="log_id", referencedColumnName="id")
* })
*/
private $logs;
And then use proper setters and getters for these new feilds mean pass object to setter functions, for the class they are being mapped for(if you dont know this part write in comment i will do it as well)