Results 1 to 1 of 1

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

  1. #1
    Join Date
    Aug 2012
    Posts
    1

    Default Auto-generated queries which match @DBRef list fields

    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 at 01:17 PM. Reason: resolve one part of original issue

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •