I have defined two database entities
Project:
use Doctrine\ORM\Mapping as ORM;
use \Kdyby\Doctrine\Entities\MagicAccessors;
/**
* #ORM\Entity
*/
class Project extends \Kdyby\Doctrine\Entities\BaseEntity
{
/**
* #ORM\Id
* #ORM\Column(type="integer")
* #ORM\GeneratedValue
*/
public $id;
/**
* #ORM\Column(type="string")
*/
public $title;
/**
* #ORM\Column(type="text")
* #var string
*/
public $description;
/**
* #ORM\Column(type="datetime", nullable=true)
* #var DateTime
*/
public $created;
/**
* #ORM\Column(type="boolean")
* #var string
*/
public $public;
/**
* #ORM\Column(type="blob")
* #var string
*/
public $thumbnail;
public function __construct()
{
$this->created = new \DateTime();
$this->public = 0;
}
}
and Personage:
use Doctrine\ORM\Mapping as ORM;
use \Kdyby\Doctrine\Entities\MagicAccessors;
/**
* #ORM\Entity
*/
class Personage extends \Kdyby\Doctrine\Entities\BaseEntity
{
/**
* #ORM\Id
* #ORM\Column(type="integer")
* #ORM\GeneratedValue
*/
public $id;
/**
* #ORM\Column(type="string")
*/
public $name;
/**
* #ORM\Column(type="text", nullable=true)
* #var string
*/
public $shortDescription;
/**
* #ORM\Column(type="text", nullable=true)
* #var string
*/
public $playerDescription;
/**
* #ORM\Column(type="datetime")
* #var DateTime
*/
public $created;
/**
* #ORM\Column(type="integer")
* #var string
*/
public $creator;
/**
* #ORM\Column(type="boolean", options={"default" = false})
* #var boolean
*/
public $inGraph;
/**
* #ORM\Column(type="boolean", nullable=false, options={"default" = 0})
* #var boolean
*/
public $deleted;
/**
* #ORM\ManyToOne(targetEntity="Project", cascade={"persist", "remove"})
* #ORM\JoinColumn(name="project", referencedColumnName="id", onDelete="CASCADE")
* #var string
*/
public $project_id;
public function __construct()
{
$this->deleted = 0;
$this->inGraph = 0;
}
}
Every Personage entity belongs to some project. But whenever I try to remove Personage either this way:
public function removeChar($id)
{
$a = $this->EntityManager->find('App\Personage', $id);
if($a->deleted)
{
$this->EntityManager->remove($a);
$this->EntityManager->flush();
}
}
or using dql. It removes the whole project row as well. What i want is whenever project is removed it removes all characters corresponding but NOT other way around.
I tried to remove
cascade={"persist", "remove"}
part from Project entity declaration (and updating database via console) but it said everything was in sync and did nothing. So I removed whole database and build it without cascade={"persist", "remove"}, but the problem was not solved.
remove onDelete="CASCADE" from
#ORM\JoinColumn(name="project", referencedColumnName="id", onDelete="CASCADE")
and add
#ORM\OneToMany(targetEntity="Personage", mappedBy="project_id",cascade={"remove"})
private $personages;
in the project entity.
Related
The problem I have with doctrine is that after the
php bin/console doctrine:schema:update --force
it creates the DB but not the foreign keys.
I'm using annotations and I tried to use the #ORM\JoinColumn in the ManyToOne ... etc annotations but without success.
I hope you guys can help me.
Here is the code of one of my entities:
<?PHP
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* #ORM\Entity
* #ORM\Table(name="member")
*/
class Member{
/**
* #ORM\Column(type="string",length=25)
* #ORM\Id
*/
private $code;
/**
* #ORM\Column(type="string",length=25)
*/
private $first_name;
/**
* #ORM\Column(type="string",length=25)
*/
private $last_name;
/**
* #ORM\Column(type="integer")
*/
private $national_id;
/**
* #ORM\Column(type="string",length=25)
*/
private $civil_situation;
/**
* #ORM\Column(type="string",length=1)
*/
private $gender;
/**
* #ORM\Column(type="date")
*/
private $dob;
/**
* #ORM\Column(type="integer")
*/
private $tel_mobile;
/**
* #ORM\Column(type="integer")
*/
private $tel_home;
/**
* #ORM\Column(type="integer")
*/
private $tel_ref;
/**
* #ORM\Column(type="string",length=25)
*/
private $email;
/**
* #ORM\Column(type="date")
*/
private $entry_date;
/**
* #ORM\Column(type="string",length=64)
*/
private $password;
/**
* #ORM\Column(type="integer",nullable=true)
* #ORM\OneToOne(targetEntity="Staff")
*/
private $staff;
/**
* #ORM\Column(type="integer",nullable=true)
* #ORM\OneToOne(targetEntity="Student")
*/
private $student;
/**
* #ORM\Column(type="integer")
* #ORM\ManyToOne(targetEntity="Address")
*/
private $address;
/**
* #ORM\Column(type="integer")
* #ORM\ManyToOne(targetEntity="Faculty")
*/
private $faculty;
/**
* #ORM\Column(type="integer")
*/
private $disable;
/**
* #ORM\Column(type="string",length=25,nullable=true)
*/
private $disable_reason;
/**
* #ORM\Column(type="integer",nullable=true)
*/
private $disable_year;
public function __construct()
{
//nothing
}
// getters and setters
?>
When #ORM\Column is specified along with #ORM\JoinColumn on same column, then JoinColumn's association gets ignored and Foreign Key isn't created on table. so dont use both #ORM\Column and #ORM\JoinColumn in same column.
Do like below:
/**
* #var Address
*
* #ORM\ManyToOne(targetEntity="Address")
* #ORM\JoinColumn(name="address_id", referencedColumnName="id", onDelete="CASCADE")
*/
private $address;
It makes column named address_id on database table, with foreign key index and on deletion of Address record, associated record in dependent table is also deleted(cascade operation). You may user other operation on onDelete, see doctrine's documentation.
In our symfony2 project we want to implement elasticsearch with ongr-io bundle, but our whole system is built on doctrine. Is it possible to somehow use ongr-io elasticsearch bundle without totally redoing whole database with documents instead of entities?
Entity that I want to index (fields for search would be: name, ChildCategory and ParentCategory):
/**
* Course
*
* #ORM\Table(name="course")
* #ORM\Entity(repositoryClass="CoreBundle\Repository\CourseRepository")
* #ORM\HasLifecycleCallbacks
*/
class Course
{
/**
* #var int
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var string
*
* #ORM\Column(name="name", type="string", length=255, unique=false)
*/
private $name;
/**
* #var ParentCategory
*
* #ORM\ManyToOne(targetEntity="ParentCategory")
* #ORM\JoinColumn(name="parentCategory_id", referencedColumnName="id")
*/
private $parentCategory;
/**
* #var ChildCategory
*
* #ORM\ManyToOne(targetEntity="ChildCategory", inversedBy="courses")
* #ORM\JoinColumn(name="childCategory_id", referencedColumnName="id")
*/
private $childCategory;
/**
* #var City
*
* #ORM\ManyToOne(targetEntity="City")
* #ORM\JoinColumn(name="city_id", referencedColumnName="id")
*/
private $city;
/**
* #var Users
*
* #ORM\ManyToOne(targetEntity="UserBundle\Entity\Users", inversedBy="course")
* #ORM\JoinColumn(name="owner_id", referencedColumnName="id")
*/
private $owner;
/**
* #var text
*
* #ORM\Column(name="description", type="text")
*/
private $description;
/**
* #var Picture
*
* #ORM\OneToMany(targetEntity="CoreBundle\Entity\Picture", mappedBy="course", cascade={"persist", "remove"})
*/
private $pictures;
/**
* #var Ratings
*
* #ORM\OneToMany(targetEntity="CoreBundle\Entity\Ratings", mappedBy="courseid")
*/
private $ratings;
public $avgRating;
}
it's very interesting.
The first thing is Entity location. The document for ElasticsearchBundle has to be in Document directory. It's not a big deal. All you need to do is to create an empty class and extend entity with #Document annotation. Next are the fields. With name field there is no problem at all, just add #property annotation and you are good. More interesting is with relations. My suggestion would be to create separate property and in the getter return value from the relation for that field. I hope you got the idea.
Update:
Here's an example of documents:
AppBundle/Entity/Post
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use ONGR\ElasticsearchBundle\Annotation as ES;
/**
* Post
*
* #ORM\Table(name="post")
* #ORM\Entity(repositoryClass="AppBundle\Repository\PostRepository")
*/
class Post
{
/**
* #var int
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #var string
*
* #ES\Property(type="string")
* #ORM\Column(name="title", type="string", length=255, nullable=true)
*/
private $title;
/**
* #var User
*
* #ORM\ManyToOne(targetEntity="User")
* #ORM\JoinColumn(name="user_id", referencedColumnName="id")
*/
private $user;
/**
* #var string
*
* #ES\Property(name="user", type="string")
*/
private $esUser;
/**
* Get id
*
* #return int
*/
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 user
*
* #param \AppBundle\Entity\User $user
*
* #return Post
*/
public function setUser(\AppBundle\Entity\User $user = null)
{
$this->user = $user;
return $this;
}
/**
* Get user
*
* #return \AppBundle\Entity\User
*/
public function getUser()
{
return $this->user;
}
/**
* #return string
*/
public function getEsUser()
{
return $this->esUser;
}
/**
* #param string $esUser
*/
public function setEsUser($esUser)
{
$this->esUser = $esUser;
}
}
AppBundle/Document/Post
<?php
namespace AppBundle\Document;
use ONGR\ElasticsearchBundle\Annotation as ES;
use AppBundle\Entity\Post as OldPost;
/**
* #ES\Document()
*/
class Post extends OldPost
{
}
I install Doctrine Extensions like here How to install Doctrine Extensions in a Symfony2 project
This is my Entity Class
<?php
namespace My\NewsBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
/**
* News
*
* #ORM\Table()
* #ORM\Entity
*/
class News
{
/**
* #var integer
*
* #ORM\Column(name="id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #ORM\Column(type="string", length=150)
*/
protected $title;
/**
* #ORM\Column(type="text")
*/
protected $content;
/**
* #ORM\Column(type="text")
*/
protected $description;
/**
* #ORM\Column(type="string", length=150)
*/
protected $keywords;
/**
* #Gedmo\Slug(fields={"title"})
* #ORM\Column(length=128, unique=true)
*/
private $slug;
/**
* #Gedmo\Timestampable(on="create")
* #ORM\Column(name="created_at", type="datetime")
*/
private $created_at;
/**
* #ORM\Column(name="updated_at", type="datetime")
* #Gedmo\Timestampable(on="update")
*/
private $updated_at;
/**
* Get id
*
* #return integer
*/
public function getId()
{
return $this->id;
}
}
php app/console doctrine:generate:entities My
gives me a a error
[Doctrine\Common\Annotations\AnnotationException]
[Semantical Error] The annotation "#Gedmo\Mapping\Annotation\Slug" in property My\NewsBundle\Entity\News::$slug does not exist, or could not be auto -loaded.
Should i add something in config or someting else? Thanks for help.
I have had quite a few problems with my current entities mapping, so I wanted an opinion on what is the issue with it.
Let's say with have the following tables example with Doctrine, but also keep in mind that a Group can have many Users, and a User can be part of many Groups
User
--
id
name
Group
--
id
title
User Groups
--
id
user_id
group_id
And this is my current approach:
/**
* User
*
* #ORM\Table(name="user")
* #ORM\Entity(repositoryClass="SomeBundle\Entity\Repository\UserRepository")
*/
class User
{
/**
* #var integer
* #ORM\Id
* #ORM\Column(name="user_id", type="integer")
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $user_id;
// some other fields and functions here
}
Group
/**
* Group
*
* #ORM\Table(name="group", indexes={#ORM\Index(name="group_parent", columns={"parent_id"})})
* #ORM\Entity(repositoryClass="SomeBundle\Entity\Repository\GroupRepository")
*/
class Group
{
/**
* #var integer
*
* #ORM\Column(name="category_id", type="integer")
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $categoryId;
// some other functions and variables here
}
...and user_groups
/**
* User_Groups
*
* #ORM\Table(name="user_groups",
* indexes={
* #ORM\Index(name="user_group_user", columns={"user_id"}),
* #ORM\Index(name="user_group_group", columns={"group_id"})
* }
* )
* #ORM\Entity(repositoryClass="SomeBundle\Entity\Repository\UserGroupRepository")
*/
class UserGroup
{
/**
* #var integer
*
* #ORM\Id
* #ORM\Column(name="user_group_id", type="integer")
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $userGroupId;
/**
* #var \SomeBundle\Entity\User
* #ORM\Column(name="user_id")
*
* #ORM\ManyToMany(targetEntity="SomeBundle\Entity\User", inversedBy="userGroups")
* #ORM\JoinTable(name="users",
* joinColumns={#ORM\JoinColumn(name="user_id", referencedColumnName="userId")})
*/
private $user;
/**
* #var SomeBundle\Entity\Category
*
* #ORM\ManyToOne(targetEntity="SomeBundle\Entity\Group", inversedBy="groups")
* #ORM\JoinColumn(name="group_id", referencedColumnName="group_id")
*
*/
private $group;
/// etc
}
Any help would be appreciated!
/** #Entity **/
class User
{
// ...
/**
* #ManyToMany(targetEntity="Group", inversedBy="users")
* #JoinTable(name="users_groups")
**/
private $groups;
public function __construct() {
$this->groups = new \Doctrine\Common\Collections\ArrayCollection();
}
// ...
}
/** #Entity **/
class Group
{
// ...
/**
* #ManyToMany(targetEntity="User", mappedBy="groups")
**/
private $users;
public function __construct() {
$this->users = new \Doctrine\Common\Collections\ArrayCollection();
}
// ...
}
Your case is Many-to-Many, Bidirectional Association
Doctrine association mapping
In this example, I have a product and a mesureUnit they relate many to many.
In your case you only need user and group. The UserGroups is generated automatically.
Many to many relationship are done as follows:
<?php
namespace TeamERP\StoresBundle\Entity;
use Doctrine\ORM\Mapping AS ORM;
/**
* #ORM\Entity
*/
class MesureUnit
{
/**
* #ORM\Id
* #ORM\Column(type="integer")
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #ORM\Column(type="string", length=100, nullable=true)
*/
private $name;
/**
* #ORM\Column(type="string", length=10, nullable=true)
*/
private $abreviation;
/**
* #ORM\OneToMany(targetEntity="TeamERP\StoresBundle\Entity\ProductActivity", mappedBy="mesureUnit")
*/
private $pproductActivity;
/**
* #ORM\ManyToMany(targetEntity="TeamERP\StoresBundle\Entity\Product", mappedBy="mesureUnit")
*/
private $product;
/**
* Constructor
*/
public function __construct()
{
$this->pproductActivity = new \Doctrine\Common\Collections\ArrayCollection();
$this->product = new \Doctrine\Common\Collections\ArrayCollection();
}
Then the produc class could be like:
<?php
namespace TeamERP\StoresBundle\Entity;
use Doctrine\ORM\Mapping AS ORM;
/**
* #ORM\Entity
*/
class Product
{
/**
* #ORM\Id
* #ORM\Column(type="integer")
* #ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* #ORM\Column(type="string", length=50, nullable=true)
*/
private $code;
/**
* #ORM\Column(type="string", length=250, nullable=true)
*/
private $description;
/**
* #ORM\Column(type="datetime", nullable=true)
*/
private $date_received;
/**
* #ORM\OneToMany(targetEntity="TeamERP\StoresBundle\Entity\ProductActivity", mappedBy="product")
*/
private $pproductActivity;
/**
* #ORM\ManyToOne(targetEntity="TeamERP\StoresBundle\Entity\Category", inversedBy="product")
* #ORM\JoinColumn(name="category_id", referencedColumnName="id")
*/
private $category;
/**
* #ORM\ManyToOne(targetEntity="TeamERP\StoresBundle\Entity\AJob", inversedBy="product")
* #ORM\JoinColumn(name="job_id", referencedColumnName="id")
*/
private $aJob;
/**
* #ORM\ManyToMany(targetEntity="TeamERP\StoresBundle\Entity\MesureUnit", inversedBy="product")
* #ORM\JoinTable(
* name="MesureUnit2Product",
* joinColumns={#ORM\JoinColumn(name="product_id", referencedColumnName="id", nullable=false)},
* inverseJoinColumns={#ORM\JoinColumn(name="mesure_unit_id", referencedColumnName="id", nullable=false)}
* )
*/
private $mesureUnit;
/**
* Constructor
*/
public function __construct()
{
$this->pproductActivity = new \Doctrine\Common\Collections\ArrayCollection();
$this->mesureUnit = new \Doctrine\Common\Collections\ArrayCollection();
}
Yo do not need to create the table manually. It is generated by Doctrine.
Hope it helps
I have a PHPUnit test that's using a Doctrine2 custom repository and Doctrine Fixtures. I wanted to test that a query gave me back an expected entity from my fixture.
But when I try $this->assertEquals($expectedEntity, $result);, I get Fatal error: out of memory. I'm guessing it is recursing into all the relations and the entity manager and whatnot.
Is there a good way to test this equality? Should I just assertEquals on the IDs of the entities?
Edit:
Here is the test code
<?php
use Liip\FunctionalTestBundle\Test\WebTestCase;
class AbstractRepositoryTestCase extends WebTestCase
{
/**
* #var Doctrine\ORM\EntityRepository
*/
protected $repo;
/**
* #var Doctrine\Common\DataFixtures\Executor\AbstractExecutor
*/
protected $fixtureExecutor;
/**
* #var string Which repository to load, overriden by derived class
*/
protected $repoName;
/**
* #var array Fixture classes to load on setup
*/
protected $fixtures = array();
public function setUp()
{
$kernel = static::createKernel();
$this->repo = $kernel->boot();
$this->repo = $kernel->getContainer()
->get('doctrine.orm.entity_manager')
->getRepository($this->repoName);
$this->fixtureExecutor = $this->loadFixtures($this->getFixtures());
}
public function getFixtures()
{
return $this->fixtures;
}
}
class ArticleRepositoryTest extends AbstractRepositoryTestCase
{
/**
* #var string Which repository to load, overriden by derived class
*/
protected $repoName = 'MyMainBundle:Article';
/**
* #var array Fixture classes to load on setup
*/
protected $fixtures = array(
'My\MainBundle\DataFixtures\ORM\LoadUserData',
'My\MainBundle\DataFixtures\ORM\LoadArticleData',
'My\MainBundle\DataFixtures\ORM\LoadFeedsData',
'My\MainBundle\DataFixtures\ORM\LoadFeedDataData',
'My\MainBundle\DataFixtures\ORM\LoadUserReadArticleData',
);
public function testGetNextArticle_ExpectCorrect()
{
/** #var Doctrine\Common\DataFixtures\ReferenceRepository **/
$refRepo = $this->fixtureExecutor->getReferenceRepository();
/** #var FeedStream\MainBundle\Entity\Article **/
$curr = $refRepo->getReference('feed-1-article-3');
$expected = $refRepo->getReference('feed-1-article-2');
$expected2 = $refRepo->getReference('feed-1-article-1');
$next = $this->repo->getNextArticle($curr->getFeed()->getId(), $curr);
$this->assertNotNull($next);
// this is the part that doesn't work
$this->assertEquals($expected, $next);
// this is the code I've used instead
$this->assertEquals($expected->getId(), $next->getId());
}
}
Here is the entity (getters/setters omitted to save space)
<?php
namespace My\MainBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* My\MainBundle\Entity\Article
*
* #ORM\Table(name="articles", uniqueConstraints={
* #ORM\UniqueConstraint(name="feed_guid", columns={"feed_id", "guid"}),
* #ORM\UniqueConstraint(name="article_slug_unique", columns={"feed_id", "slug"})
* })
* #ORM\Entity(repositoryClass="My\MainBundle\Repository\ArticleRepository")
*/
class Article
{
/**
* #var integer $id
*
* #ORM\Column(name="id", type="integer", nullable=false)
* #ORM\Id
* #ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* #var string $guid
*
* #ORM\Column(name="guid", type="string", length=255, nullable=false)
*/
private $guid;
/**
* #var string $title
*
* #ORM\Column(name="title", type="string", length=255, nullable=false)
*/
private $title;
/**
* #var datetime $pubDate
*
* #ORM\Column(name="pub_date", type="datetime", nullable=true)
*/
private $pubDate;
/**
* #var text $summary
*
* #ORM\Column(name="summary", type="text", nullable=true)
*/
private $summary;
/**
* #var text $content
*
* #ORM\Column(name="content", type="text", nullable=false)
*/
private $content;
/**
* #var string $sourceUrl
*
* #ORM\Column(name="source_url", type="string", length=255, nullable=true)
*/
private $sourceUrl;
/**
* #var string $commentUrl
*
* #ORM\Column(name="comment_url", type="string", length=255, nullable=true)
*/
private $commentUrl;
/**
* #var string $slug
*
* #ORM\Column(name="slug", type="string", length=64, nullable=false)
*/
private $slug;
/**
* #var string $thumbnailFile
*
* #ORM\Column(name="thumbnail_file", type="string", length=64, nullable=true)
*/
private $thumbnailFile;
/**
* #var My\MainBundle\Entity\ArticleEnclosure
*
* #ORM\ManyToOne(targetEntity="My\MainBundle\Entity\ArticleEnclosure")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="thumbnail_enclosure_id", referencedColumnName="id")
* })
*/
private $thumbnailEnclosure;
/**
* #var My\MainBundle\Entity\ArticleImageScrape
*
* #ORM\ManyToOne(targetEntity="My\MainBundle\Entity\ArticleImageScrape")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="thumbnail_scrape_id", referencedColumnName="id", unique=false)
* })
*/
private $thumbnailScrape;
/**
* #var My\MainBundle\Entity\ArticleBitly
*
* #ORM\OneToOne(targetEntity="My\MainBundle\Entity\ArticleBitly", mappedBy="article", orphanRemoval=true)
*/
private $bitly;
/**
* #var My\MainBundle\Entity\ArticleEnclosure
*
* #ORM\OneToMany(targetEntity="My\MainBundle\Entity\ArticleEnclosure", mappedBy="article", orphanRemoval=true)
*/
private $enclosures;
/**
* #var My\MainBundle\Entity\ArticleImageScrape
*
* #ORM\OneToMany(targetEntity="My\MainBundle\Entity\ArticleImageScrape", mappedBy="article", orphanRemoval=true)
*/
private $scrapes;
/**
* #var My\MainBundle\Entity\ArticleLink
*
* #ORM\OneToMany(targetEntity="My\MainBundle\Entity\ArticleLink", mappedBy="article", orphanRemoval=true)
*/
private $links;
/**
* #var My\MainBundle\Entity\Feed
*
* #ORM\ManyToOne(targetEntity="My\MainBundle\Entity\Feed", inversedBy="articles")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="feed_id", referencedColumnName="id", nullable=false)
* })
*/
private $feed;
/**
* #var My\MainBundle\Entity\ArticleAuthor
*
* #ORM\ManyToOne(targetEntity="My\MainBundle\Entity\ArticleAuthor", inversedBy="articles")
* #ORM\JoinColumns({
* #ORM\JoinColumn(name="author_id", referencedColumnName="id")
* })
*/
private $author;
public function __construct()
{
$this->links = new \Doctrine\Common\Collections\ArrayCollection();
}
}
You should also test the class in addition to the ID.