Announcement Announcement Module
Collapse
No announcement yet.
How to query MongoDB by id without MongoOperations::findById Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to query MongoDB by id without MongoOperations::findById

    Hi,

    I'm trying to get Spring to generate a MongoDB query method which looks to match within an array:
    Code:
    public class Cab {
    @DBRef 
    List<Passenger> passengers;
    }
    
    public interface CabRepository {
      Cab findByPassengersId(String id);
    }
    But the generated query looks for cab.passengers._id, rather than cab.passengers.$id, as it should for the DBRef to resolve correctly:


    2012-08-03 14:10:39,608 [SimpleAsyncTaskExecutor-1] DEBUG org.springframework.data.mongodb.repository.query. MongoQueryCreator - Created query Query: { "passengers._id" : "C"}, Fields: null, Sort: null

    What am I doing wrong?

    Thanks,
    Ben
    Last edited by Ben Blum; Aug 3rd, 2012, 01:17 PM. Reason: resolve one part of original issue
Working...
X