Q:

How to properly get values in OneToMany relationship based on field of "many" side?

Let's say I have an entity 

Restaurant

with field:

 @OneToMany(mappedBy = "restaurant", fetch = FetchType.LAZY)
 private Set<MenuEntry> menu;

MenuEntry entity has next field:

@Column(name = "date_time_created", nullable = false)
private LocalDate dateCreated;

which obviously represents date when entry was created.
I need to write JPQL query which would give me Restaurant where set of menus includes entries with specified dateCreated.
I've written method with next annotations: 

@EntityGraph(attributePaths = {"menu"}, type = EntityGraph.EntityGraphType.LOAD)

@Query("SELECT r FROM Restaurant r WHERE r.id=:restaurantId AND  r.menu 
IN (SELECT m FROM MenuEntry m WHERE m.dateCreated=:dateCreated)")

But when I try to perform this query I have "malformed numeric constant" exception. Could you please explain me, how to properly get values in my situation ? Thank you! 

A:

Select r from Restaurant r JOIN r.menu m where m.dateCreated=:dateCreated and r.id=:restaurantId
Try this... This will work... No need to use inner query

