(hibernate / jpa) @Where - How to obtain a subset of a collection? #5253

Closed
opened 2026-01-22 15:02:42 +01:00 by admin · 1 comment
Owner

Originally created by @marcos-rocha on GitHub (Sep 13, 2016).

Originally assigned to: @Ocramius on GitHub.

How can I obtain a subset of a larger collection?
What I want do to is filter a oneToMany using "clause x = y".

Example:

class Foo {

 @ORM\OneToMany(targetEntity="EntityA", ...)
 private $listOfA;

 @ORM\OneToOne(targetEntity="EntityA", ...)
@Where(clause="main=true and age > 10"), main and age are EntityA properties
 private $singleA;
}

Please, visit the link:
http://docs.jboss.org/hibernate/stable/annotations/reference/en/html_single/#entity-hibspec-collection

Thanks.

Originally created by @marcos-rocha on GitHub (Sep 13, 2016). Originally assigned to: @Ocramius on GitHub. How can I obtain a subset of a larger collection? What I want do to is filter a oneToMany using "clause x = y". Example: ``` php class Foo { @ORM\OneToMany(targetEntity="EntityA", ...) private $listOfA; @ORM\OneToOne(targetEntity="EntityA", ...) @Where(clause="main=true and age > 10"), main and age are EntityA properties private $singleA; } ``` Please, visit the link: http://docs.jboss.org/hibernate/stable/annotations/reference/en/html_single/#entity-hibspec-collection Thanks.
admin closed this issue 2026-01-22 15:02:42 +01:00
Author
Owner

@Ocramius commented on GitHub (Sep 13, 2016):

Not supported by doctrine2: you will have to use the criteria API at runtime (see PersistentCollection#matching())

@Ocramius commented on GitHub (Sep 13, 2016): Not supported by doctrine2: you will have to use the criteria API at runtime (see `PersistentCollection#matching()`)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#5253