Supported Libraries
Supported till version 3.2.x
Supported Operations
Objects
Icon | Description |
---|
| Java MongoDB database |
| Java MongoDB collection |
| Java unknown MongoDB database |
| Java unknown MongoDB collection |
Links
Link type | Source and destination of link | Methods supported |
---|
parentLink | Between Mongo Objects (Collection → Database → Project) |
|
useLink | Between the caller Spring Data Java Method objects and Mongo Collection Object | |
useSelectLink | Click here to expand... - find
- findAll
- findById
- findAllById
- findAll
- count
- existsById
- exists
- findAndRemove
- findAllAndRemove
- findAndReplace
- findAndModify
- findOne
- stream
- group
- geoNear
- aggregate
- aggregateStream
- aggregateAndReturn
- executeQuery
- getCollection
- findDistinct
|
useUpdateLink | - upsert
- update
- updateFirst
- updateOne
- updateMulti
- findAndModify
- findAndReplace
|
useDeleteLink | - deleteAll
- deleteById
- delete
- findAndRemove
- dropCollection
- remove
- findAllAndRemove
|
useInsertLink | - save
- saveAll
- insert
- insertAll
- upsert
|
What results can you expect
Once the analysis/snapshot generation has completed, you can view the results in the normal manner (for example via CAST Enlighten). Some examples are shown below.
Creation of database object
With application.properties
Click here to expand...
spring.data.mongodb.host=localhost
spring.data.mongodb.port=27017
spring.data.mongodb.database=hc4
logging.level.org.springframework.data=debug
logging.level.=error

With Java configuration file
Click here to expand...
package com.mkyong;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.config.AbstractMongoConfiguration;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
import com.mongodb.Mongo;
import com.mongodb.MongoClient;
@Configuration
@EnableMongoRepositories
public class ApplicationConfig extends AbstractMongoConfiguration{
@Override
@Bean
protected String getDatabaseName() {
return "e-store";
}
@Override
protected String getMappingBasePackage() {
return "com.oreilly.springdata.mongodb";
}
@Override
@Bean
public Mongo mongo() throws Exception {
// TODO Auto-generated method stub
return new Mongo("localhost");
}
}

Insert Operation
Click here to expand...
@Component("storeOrder")
public class StoreOCEOrder implements Processor {
private static final Logger log = LoggerFactory.getLogger(StoreOCEOrder.class);
@Autowired
private OceOrderRepository repository;
public void process(Exchange exg) throws Exception {
repository.save(oceResponse);
}
}

Click here to expand...
public String saveAlerts(List<FanAlerts> documentsToSave) {
LOGGER.debug("FanAlertsRepository.saveAlerts()");
mongoOperation.insert(documentsToSave, FanAlerts.class);
return AlertServiceConstants.ALERT_CREATED_MESSAGE;
}

Update Operation
Update Operation
public Response deleteCSPProfileLocation(CSPProfileDeleteLocationRequest req) {
UpdateResult result = collection.getExposedDocCollection().updateOne(filter, cond);
}

Delete Operation
Delete Operation
public Response deleteTn(String siteId, String tn) {
DeleteResult deleteres = mongoCon.getCollection()
.deleteOne(new Document().append(DETAILSSITE_IDEN, siteId).append(DETAILS_TN, tn));
}

Select Operation
Click here to expand...
public void elkFailureReprocess() {
Document getTnDoc = (Document) mongoCon.getCollection("TN").find(eq("details.tn", id)).first();
}

Query Methods
Query Method
public interface OrderCountersRepository extends MongoRepository<Counters, String> {
@Query(value = "{'_id':?0}")
public Counters findById(String orderId);
}

Evolution
- Query methods with and without @Query annotation are supported.
- Support for Reactive Mongo Repository
- Support for Reactive Mongo Template and Reactive Mongo Operations
- Support for APIs belonging to Mongo Collection of com.mongodb.client.MongoCollection
- No connection objects are created. Only databases and collection objects are created.
Limitations
- Resolution of Database and Collection is limited, "Unknown" is used when not resolved.
- Query method results in link between query method and repository collection (domain entity) and not between the actual caller method and repository collection