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

Hydrating RelationshipEntity objects #180

Open

Description

@sebsel

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.

Activity

  1. cebe commented on Nov 2, 2018

    @cebe
    Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions