I am currently using GA release of Spring Data MongoDB framework and @DbRef is not saving child object automatically in spring data mongodb. Can you tell me how can i make it work?
            Asked
            
        
        
            Active
            
        
            Viewed 4,923 times
        
    1 Answers
9
            
            
        Saving child objects is not built into Spring Data MongoDB so you have to do it manually or you can extend AbstractMongoEventListener as I described it in my article: Spring Data MongoDB cascade save on DBRef objects
        dkb
        
- 4,389
 - 4
 - 36
 - 54
 
        Maciej Walkowiak
        
- 12,372
 - 59
 - 63
 
- 
                    Can you tell why the ObjectId is mandatory? because I am doing Id implementation with long – Dexter Jul 19 '14 at 15:33
 - 
                    1hey @Maciej can you please update the link to your article? moreover, I wanted a way to do it for db referenced collection object, do we have a way. I tried extending AbstractMongoEventListener, but my test case while saving and updating fails. – Hiren Sep 06 '17 at 21:55