Quantcast
Channel: Spring Community Forums - Data
Viewing all articles
Browse latest Browse all 297

Query @DBRef field

$
0
0
I have 2 entities as following:
Code:

@Document
public class Freelancer {
 @Id
 String id;
 String name;
 @DbRef
 List<Project> bidProjects;
}

@Document
public class Project {
 @Id
 String id;
 String name;
}

Project can't have the ref to freelancer as there could be many freelancers who can bid the projects. I want do following:

Find the freelancer who has placed a bid on project with name = "XYZ".

What should be the query (JSON based Query) for this, i tried following (other combinations but nothing works):

@Query("{ 'completedProject': {'$ref': 'project', 'name': ?0 } }")
@Query("{ 'completedProjects': {'$ref': 'project', 'name': ?0 } }")
@Query("{ 'completedProject': [{'$ref': 'project', 'name': ?0 }] }")

Viewing all articles
Browse latest Browse all 297

Trending Articles