Hi all,
I was wondering if the Update pull method supports expressions of the type
Code:{ $pull : { field : {field2: value} } } removes array elements with field2 matching valueCode:{ $pull : { field : {$gt: 3} } } removes array elements greater than 3In particular my case is as follows:Code:{ $pull : { field : {<match-criteria>} } } removes array elements meeting match criteria
Basically I want to remove an array element within a document whose last udpated date is less that the informed date.Code:public void removeByOfficeAndLastUpdatedDate(Long officeOid, Collection<Long> departureOids, Date olderThan) { Update cabinFareUpd = new Update(); WriteResult updateResult = this.mongoTemplate.updateMulti( query(where(BaseFareFields.OFFICE_OID.getValue()).is(officeOid). and(BaseFareFields.DEPARTURE_OID.getValue()).in(departureOids). and(BaseFareFields.CABIN_FARE.getValue()).elemMatch(where(BaseFareFields.LAST_UPDATED_DATE.getValue()).lte(olderThan))), cabinFareUpd.pull(BaseFareFields.LAST_UPDATED_DATE.getValue(), query(where(BaseFareFields.LAST_UPDATED_DATE.getValue()).lte(olderThan))), BaseFare.class); logger.info(updateResult.toString()); }
The execution of the pull method as written above currently throws an exception:
I have attached the complete stack trace here Mongo Pull Stack Overflow exception 09-26-2012.zipCode:java.lang.StackOverflowError at java.util.HashMap$EntryIterator.<init>(Unknown Source) at java.util.HashMap$EntryIterator.<init>(Unknown Source) at java.util.HashMap.newEntryIterator(Unknown Source) at java.util.HashMap$EntrySet.iterator(Unknown Source) at java.util.AbstractMap.hashCode(Unknown Source) at org.springframework.util.ObjectUtils.nullSafeHashCode(ObjectUtils.java:336) at org.springframework.data.util.TypeDiscoverer.hashCode(TypeDiscoverer.java:365) at org.springframework.data.util.ClassTypeInformation.hashCode(ClassTypeInformation.java:39) at java.util.concurrent.ConcurrentHashMap.hash(Unknown Source) at java.util.concurrent.ConcurrentHashMap.get(Unknown Source) at org.springframework.data.mapping.context.AbstractMappingContext.getPersistentEntity(AbstractMappingContext.java:151) ...
Thanks in advance for your help,
Sebastian


Reply With Quote
