You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 1, 2021. It is now read-only.
When a record is loaded using the EntityManager, and afterwards some changes are made to the database without using the EntityManager, I see no way to reload the record to retrieve fresh information from the DB. I was expecting the refresh() method to do this, but it does not work. Also it seems there is no documentation about this method.
I demonstrate the problem in form of a test case using the code from OneToManyRelationshipEntityTest:
// create initial data$owner = newOwner('M');
$house1 = newHouse();
$house1->setAddress('A Street 1');
$this->persist($owner, $house1);
$this->em->flush();
$this->assertGraphExist('(o:Owner {name:"M"})');
$this->assertGraphExist('(h:House {address: "A Street 1"})');
$this->em->flush();
$this->em->clear();
// load owner instance/** @var Owner $me */$me = $this->em->getRepository(Owner::class)->findOneBy(['name' => 'M']);
$this->assertSame(0, $me->getAcquisitions()->count());
// make some changes to the db$this->em->getDatabaseDriver()->run('MATCH (o:Owner {name:"M"}), (h:House {address: "A Street 1"}) CREATE (o)-[r:ACQUIRED {year: 1980}]->(h)');
$this->assertGraphExist('(o:Owner {name:"M"})-[r:ACQUIRED {year: 1980}]->(h:House {address: "A Street 1"})');
// this line should fetch a new record, but somehow it uses a chaced one, as the assertation below fails$me = $this->em->getRepository(Owner::class)->findOneBy(['name' => 'M']);
// uncommenting this line complains that the entity is not managed by the entity manager, however if it is cached, I expect it to be refreshed by this.//$this->em->refresh($me);$this->assertSame(1, $me->getAcquisitions()->count());
Any idea what I am doing wrong? Not sure if its a bug or I am missing something but at least some documentation is needed on how to properly refresh entities. Thanks!
I'll submit a PR with the failing test.
The text was updated successfully, but these errors were encountered:
cebe
added a commit
to cebe/neo4j-php-ogm
that referenced
this issue
Oct 13, 2017
When a record is loaded using the EntityManager, and afterwards some changes are made to the database without using the EntityManager, I see no way to reload the record to retrieve fresh information from the DB. I was expecting the
refresh()
method to do this, but it does not work. Also it seems there is no documentation about this method.I demonstrate the problem in form of a test case using the code from
OneToManyRelationshipEntityTest
:Any idea what I am doing wrong? Not sure if its a bug or I am missing something but at least some documentation is needed on how to properly refresh entities. Thanks!
I'll submit a PR with the failing test.
The text was updated successfully, but these errors were encountered: