|
|
|
|
@ -103,16 +103,23 @@
@@ -103,16 +103,23 @@
|
|
|
|
|
|
|
|
|
|
<para>Then add the following to pom.xml dependencies section.</para> |
|
|
|
|
|
|
|
|
|
<programlisting lang="xml"> <dependency> |
|
|
|
|
<programlisting lang="" language="xml"><dependencies> |
|
|
|
|
|
|
|
|
|
<!-- other dependency elements omitted --> |
|
|
|
|
|
|
|
|
|
<dependency> |
|
|
|
|
<groupId>org.springframework.data</groupId> |
|
|
|
|
<artifactId>spring-data-mongodb</artifactId> |
|
|
|
|
<version>1.0.0.BUILD-SNAPSHOT</version> |
|
|
|
|
<version>1.0.0.M2</version> |
|
|
|
|
</dependency> |
|
|
|
|
|
|
|
|
|
<dependency> |
|
|
|
|
<groupId>cglib</groupId> |
|
|
|
|
<artifactId>cglib</artifactId> |
|
|
|
|
<version>2.2</version> |
|
|
|
|
</dependency> |
|
|
|
|
|
|
|
|
|
</dependencies> |
|
|
|
|
</programlisting> |
|
|
|
|
|
|
|
|
|
<para>The cglib dependency is there as we will use Spring's Java |
|
|
|
|
@ -121,13 +128,30 @@
@@ -121,13 +128,30 @@
|
|
|
|
|
|
|
|
|
|
<programlisting lang="" language="xml"><spring.framework.version>3.0.5.RELEASE</spring.framework.version></programlisting> |
|
|
|
|
|
|
|
|
|
<para>You will also need to add the location of the Spring Milestone |
|
|
|
|
repository for maven to your pom.xml which is at the same level of your |
|
|
|
|
<dependencies/> element</para> |
|
|
|
|
|
|
|
|
|
<programlisting language="xml"><repositories> |
|
|
|
|
<repository> |
|
|
|
|
<id>spring-milestone</id> |
|
|
|
|
<name>Spring Maven MILESTONE Repository</name> |
|
|
|
|
<url>http://maven.springframework.org/milestone</url> |
|
|
|
|
</repository> |
|
|
|
|
</repositories></programlisting> |
|
|
|
|
|
|
|
|
|
<para>The repository is also <ulink |
|
|
|
|
url="http://shrub.appspot.com/maven.springframework.org/milestone/org/springframework/data/">browseable |
|
|
|
|
here</ulink>. </para> |
|
|
|
|
|
|
|
|
|
<para>You may also want to set the logging level to DEBUG to see some |
|
|
|
|
additional information, edit the log4j.properties file and add</para> |
|
|
|
|
|
|
|
|
|
<programlisting>log4j.category.org.springframework.data.document.mongodb=DEBUG</programlisting> |
|
|
|
|
|
|
|
|
|
<para>Next, in the org.spring.mongodb package in the sr/ctest/java |
|
|
|
|
directory create a class as shown below.</para> |
|
|
|
|
<para>Next, in the org.spring.mongodb package in the |
|
|
|
|
<literal>src/test/java</literal> directory create a class as shown |
|
|
|
|
below.</para> |
|
|
|
|
|
|
|
|
|
<programlisting lang="" language="java">package org.spring.mongodb; |
|
|
|
|
|
|
|
|
|
@ -886,9 +910,8 @@ import static org.springframework.data.document.mongodb.query.Update
@@ -886,9 +910,8 @@ import static org.springframework.data.document.mongodb.query.Update
|
|
|
|
|
|
|
|
|
|
... |
|
|
|
|
|
|
|
|
|
WriteResult wr = mongoTemplate.updateMulti( |
|
|
|
|
query(where("accounts.accountType").is(Account.Type.SAVINGS)), |
|
|
|
|
update.inc("accounts.$.balance", 50.00)); |
|
|
|
|
WriteResult wr = mongoTemplate.updateMulti(query(where("accounts.accountType").is(Account.Type.SAVINGS)), |
|
|
|
|
update.inc("accounts.$.balance", 50.00)); |
|
|
|
|
</programlisting> |
|
|
|
|
</example> |
|
|
|
|
|
|
|
|
|
@ -1097,8 +1120,7 @@ import static org.springframework.data.document.mongodb.query.Query.query;
@@ -1097,8 +1120,7 @@ import static org.springframework.data.document.mongodb.query.Query.query;
|
|
|
|
|
|
|
|
|
|
... |
|
|
|
|
|
|
|
|
|
List<Person> result = mongoTemplate.find( |
|
|
|
|
query(where("age").lt(50).and("accounts.balance").gt(1000.00d)),Person.class); |
|
|
|
|
List<Person> result = mongoTemplate.find(query(where("age").lt(50).and("accounts.balance").gt(1000.00d)),Person.class); |
|
|
|
|
</programlisting> |
|
|
|
|
</example> |
|
|
|
|
|
|
|
|
|
|