I've been trying to find an answer for my question here but I am not really sure what to search for. I've also read the HQL guide but didn't make my code work.
I have three objects. First object (Document) has a OneToMany connection to an object CoAuthor (so a Set coAuthors is a field in Document). The Object CoAuthor is connected (ManyToOne) to an object User (so User user is a field in the object CoAuthor). User has a field username. Just for imagination, getting username of first co-author of a document would be document.coAuthors.get(0).user.username. Another complication is that the user can be null (there's a @NotFound(ignore) statement for User user in CoAuthor object).
Now what I need is to get all co-author's documents if I know his username. So something like "from Document as doc where 'john' in doc.coAuthors.user.username".
I know my description is not very good, but I hope you will understand what I need.
Thank you for your advice.
|