Skip to content
This repository has been archived by the owner on Dec 1, 2021. It is now read-only.

Hydrating RelationshipEntity objects #180

Open
sebsel opened this issue Oct 26, 2018 · 1 comment
Open

Hydrating RelationshipEntity objects #180

sebsel opened this issue Oct 26, 2018 · 1 comment

Comments

@sebsel
Copy link

sebsel commented Oct 26, 2018

Maybe I am not seeing something, but if I have a query like this one:

MATCH (store:Store)-[stock:STOCK]->(product:Product)
WHERE id(store) = {storeID} AND id(product) = {productID}
RETURN store, product, stock

... and I do something like this:

$query = $this->repo->createQuery($cypher)
            ->setParameter('productID', $productID)
            ->setParameter('storeID', $storeID)
            ->addEntityMapping('store', Store::class)
            ->addEntityMapping('product', Product::class)
            ->addEntityMapping('stock', Stock::class);

... then my app totally crashes. It does not support hydrating the stock relation into this Stock class, annotated with @OGM\RelationshipEntity(type="STOCK").

Am I missing some important concept, or is it just that no-one has ran into this before?

To get to my Stock-object, I can of course also use my defined relation (with @OGM\Relationship()):

$result = $query->getOneResult();
$result['store']->stock;

... but that one gives my Collection of all the Store's products! So I would still need to loop over all of those to see what Stock-object in that Collection is the one that points to the right Product. I just want the Stock object from the query.

I think it would be really great if I can hydrate the relation model via the same way I can hydrate the node model.

@cebe
Copy link
Contributor

cebe commented Nov 2, 2018

how did you define Stock class and what is the error message you see?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants