本文整理汇总了Java中org.springframework.data.mongodb.core.MongoOperations.save方法的典型用法代码示例。如果您正苦于以下问题:Java MongoOperations.save方法的具体用法?Java MongoOperations.save怎么用?Java MongoOperations.save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.data.mongodb.core.MongoOperations
的用法示例。
在下文中一共展示了MongoOperations.save方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepare
import org.springframework.data.mongodb.core.MongoOperations; //导入方法依赖的package包/类
@Override
public void prepare(Description description) {
super.prepare(description);
Veiculo veiculo = VeiculoResourceCondition.OBJECT.get();
MongoOperations mongoOperation = (MongoOperations) ApplicationContextProvider.getApplicationContext().getBean("mongoTemplate");
Logradouro logradouro = new Logradouro();
logradouro.setId("1");
logradouro.setLogradouro("Rua das Acacias");
logradouro.setCep("88030000");
logradouro.setTp_logradouro("Rua");
Infracao infracao1 = createInfracao("1", veiculo, logradouro);
Infracao infracao2 = createInfracao("2", veiculo, logradouro);
mongoOperation.save(infracao1);
mongoOperation.save(infracao2);
}
示例2: testUpsertStb
import org.springframework.data.mongodb.core.MongoOperations; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testUpsertStb() {
MongoHouseService service = new MongoHouseService();
MongoOperations operations = EasyMock.createMock(MongoOperations.class);
EasyMock.expect(operations.collectionExists((Class) EasyMock.anyObject())).andReturn(false);
EasyMock.expect(operations.createCollection((Class) EasyMock.anyObject())).andReturn(null);
operations.save((PersistableDevice) EasyMock.anyObject(), (String) EasyMock.anyObject());
EasyMock.expectLastCall();
EasyMock.expect(operations.findById((Object) EasyMock.anyObject(), (Class) EasyMock.anyObject(),
(String) EasyMock.anyObject())).andReturn(null);
EasyMock.replay(operations);
ReflectionTestUtils.setField(service, "template", operations);
ParkService mockParkService = EasyMock.createMock(ParkService.class);
EasyMock.expect(mockParkService.getModelById((String) EasyMock.anyObject())).andReturn(null);
EasyMock.replay(mockParkService);
ReflectionTestUtils.setField(service, "parkService", mockParkService);
DawgDevice[] stb = new DawgDevice[1];
stb[0] = new PersistableDevice();
try {
service.upsertStb(stb);
} catch (Exception e) {
Assert.fail(e.getMessage(),e);
}
}
示例3: insertarEmpresasEnBD
import org.springframework.data.mongodb.core.MongoOperations; //导入方法依赖的package包/类
public static void insertarEmpresasEnBD(ArrayList<Empresa> empresas, MongoOperations mongoOperation) {
for (Empresa e : empresas)
if (e.getTweets() != null)
mongoOperation.save(e);
}
示例4: addScheduleToDB
import org.springframework.data.mongodb.core.MongoOperations; //导入方法依赖的package包/类
@SuppressWarnings("resource")
private boolean addScheduleToDB(String queryName, String subscriptionID,
String dest, String cronExpression, String eventType,
String GE_eventTime, String LT_eventTime, String GE_recordTime,
String LT_recordTime, String EQ_action, String EQ_bizStep,
String EQ_disposition, String EQ_readPoint, String WD_readPoint,
String EQ_bizLocation, String WD_bizLocation,
String EQ_transformationID, String MATCH_epc,
String MATCH_parentID, String MATCH_inputEPC,
String MATCH_outputEPC, String MATCH_anyEPC, String MATCH_epcClass,
String MATCH_inputEPCClass, String MATCH_outputEPCClass,
String MATCH_anyEPCClass, String EQ_quantity, String GT_quantity,
String GE_quantity, String LT_quantity, String LE_quantity,
String orderBy, String orderDirection, String eventCountLimit,
String maxEventCount, Map<String, String> paramMap) {
/*
SubscriptionType st = new SubscriptionType(queryName, subscriptionID,
dest, cronExpression, eventType, GE_eventTime, LT_eventTime,
GE_recordTime, LT_recordTime, EQ_action, EQ_bizStep,
EQ_disposition, EQ_readPoint, WD_readPoint, EQ_bizLocation,
WD_bizLocation, EQ_transformationID, MATCH_epc, MATCH_parentID,
MATCH_inputEPC, MATCH_outputEPC, MATCH_anyEPC, MATCH_epcClass,
MATCH_inputEPCClass, MATCH_outputEPCClass, MATCH_anyEPCClass,
EQ_quantity, GT_quantity, GE_quantity, LT_quantity,
LE_quantity, orderBy, orderDirection, eventCountLimit,
maxEventCount, paramMap);
*/
ApplicationContext ctx = new GenericXmlApplicationContext(
"classpath:MongoConfig.xml");
MongoOperations mongoOperation = (MongoOperations) ctx
.getBean("mongoTemplate");
List<SubscriptionType> existenceTest = mongoOperation.find(new Query(
Criteria.where("subscriptionID").is(subscriptionID)),
SubscriptionType.class);
if (existenceTest.size() != 0)
return false;
if (existenceTest.size() == 0)
mongoOperation.save(null);
Configuration.logger.log(Level.INFO, "Subscription ID: "
+ subscriptionID + " is added to DB. ");
((AbstractApplicationContext) ctx).close();
return true;
}
示例5: insertarEnBD
import org.springframework.data.mongodb.core.MongoOperations; //导入方法依赖的package包/类
/**
* Insertar en BD.
*
* @param ofertasInfoEmpleo
* the ofertas info empleo
* @param mongoOperation
* the mongo operation
*/
public static void insertarEnBD(ArrayList<Oferta> ofertasInfoEmpleo, MongoOperations mongoOperation) {
for (Oferta oferta : ofertasInfoEmpleo)
mongoOperation.save(oferta);
}