eav-manager icon indicating copy to clipboard operation
eav-manager copied to clipboard

Missing ids when using findOneBy

Open johnkrovitch opened this issue 5 years ago • 2 comments

When I use the findOneBy method of the finder, I have the following exception :

In ProcessManager.php line 315:
                                                                                                                                      
  Process academic_article has failed during process publication_mapping with message: 'Binding entities to query parameters only al  
  lowed for entities that have an identifier.'.                                                                                       
                                                                                                                                     
In ORMInvalidArgumentException.php line 207:
                                                                                           
  Binding entities to query parameters only allowed for entities that have an identifier.  

But my code looks like this :

if ($author->getId() && $publication->getId()) {
                $publishedPublication = $this->finder->findOneBy($family, [
                    'author' => $author,
                    'publication' => $publication,
                    'type' => $type,
                ]);
            }

And if I dump the content of ids before the crash :

35943
39628
10:46:30 CRITICAL  [cleverage_process_task] Binding entities to query parameters only allowed for entities that have an identifier. ["process_id" => 1574243070.9765,"process_code" => "academic_article","process_context" => [],"task_code" => "publication_mapping","task_service" => "App\Task\Publication\PublicationMappingTask"]
10:46:30 ERROR     [console] Error thrown while running command "cleverage:process:execute academic_article". Message: "Process academic_article has failed during process publication_mapping with message: 'Binding entities to query parameters only allowed for entities that have an identifier.'.
" ["exception" => RuntimeException { …},"command" => "cleverage:process:execute academic_article","message" => "Process academic_article has failed during process publication_mapping with message: 'Binding entities to query parameters only allowed for entities that have an identifier.'.\n"]

The ids of my entities are filled with values.

johnkrovitch avatar Nov 20 '19 09:11 johnkrovitch

It's look like the EAV does not get the ids from entities, but if I pass directly the ids, it is working.

Edit : even with ids, the exception is thrown

johnkrovitch avatar Nov 20 '19 09:11 johnkrovitch

I find some "patch". If we call the find method each linked object before calling the findOneBy, the entity manager is hydrated correctly and the query works.

johnkrovitch avatar Nov 21 '19 08:11 johnkrovitch