Announcement Announcement Module
Collapse
No announcement yet.
Query in collection with DBRef Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Query in collection with DBRef

    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 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 }] }")
    Last edited by hellowrakesh123; Feb 27th, 2013, 04:04 PM.
Working...
X