add missing language tags for docs
This commit is contained in:
@@ -34,30 +34,28 @@
|
||||
http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
|
||||
|
||||
<beans>
|
||||
<beans>
|
||||
|
||||
<!-- Default bean name is 'mongo' -->
|
||||
<mongo:mongo host="localhost" port="27017"/>
|
||||
<!-- Default bean name is 'mongo' -->
|
||||
<mongo:mongo host="localhost" port="27017"/>
|
||||
|
||||
<!-- by default look for a Mongo object named 'mongo' -->
|
||||
<mongo:jmx/>
|
||||
<!-- by default look for a Mongo object named 'mongo' -->
|
||||
<mongo:jmx/>
|
||||
|
||||
<context:mbean-export/>
|
||||
<context:mbean-export/>
|
||||
|
||||
<!-- To translate any MongoExceptions thrown in @Repository annotated classes -->
|
||||
<context:annotation-config/>
|
||||
<!-- To translate any MongoExceptions thrown in @Repository annotated classes -->
|
||||
<context:annotation-config/>
|
||||
|
||||
<bean id="registry" class="org.springframework.remoting.rmi.RmiRegistryFactoryBean"
|
||||
p:port="1099" />
|
||||
<bean id="registry" class="org.springframework.remoting.rmi.RmiRegistryFactoryBean" p:port="1099" />
|
||||
|
||||
<!-- Expose JMX over RMI -->
|
||||
<bean id="serverConnector" class="org.springframework.jmx.support.ConnectorServerFactoryBean"
|
||||
<!-- Expose JMX over RMI -->
|
||||
<bean id="serverConnector" class="org.springframework.jmx.support.ConnectorServerFactoryBean"
|
||||
depends-on="registry"
|
||||
p:objectName="connector:name=rmi"
|
||||
p:serviceUrl="service:jmx:rmi://localhost/jndi/rmi://localhost:1099/myconnector" />
|
||||
|
||||
</beans>
|
||||
</programlisting>
|
||||
</beans> </programlisting>
|
||||
</example>
|
||||
|
||||
<para>This will expose several MBeans</para>
|
||||
|
||||
@@ -25,8 +25,7 @@
|
||||
<example>
|
||||
<title>@Configuration class to configure MongoDB mapping support</title>
|
||||
|
||||
<programlisting language="xml">
|
||||
@Configuration
|
||||
<programlisting language="java">@Configuration
|
||||
public class GeoSpatialAppConfig extends AbstractMongoConfiguration {
|
||||
|
||||
@Bean
|
||||
@@ -49,8 +48,6 @@ public class GeoSpatialAppConfig extends AbstractMongoConfiguration {
|
||||
public LoggingEventListener<MongoMappingEvent> mappingEventsListener() {
|
||||
return new LoggingEventListener<MongoMappingEvent>();
|
||||
}
|
||||
|
||||
|
||||
}</programlisting>
|
||||
</example>
|
||||
|
||||
@@ -219,7 +216,7 @@ public class Person {
|
||||
|
||||
<para>Here is an example of a more complex mapping.</para>
|
||||
|
||||
<programlisting>@Document
|
||||
<programlisting language="java">@Document
|
||||
@CompoundIndexes({
|
||||
@CompoundIndex(name = "age_idx", def = "{'lastName': 1, 'age': -1}")
|
||||
})
|
||||
|
||||
@@ -111,7 +111,7 @@
|
||||
<example>
|
||||
<title>Paging access to Person entities</title>
|
||||
|
||||
<programlisting>@RunWith(SpringJUnit4ClassRunner.class)
|
||||
<programlisting language="java">@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration
|
||||
public class PersonRepositoryTests {
|
||||
|
||||
@@ -145,7 +145,7 @@ public class PersonRepositoryTests {
|
||||
<example>
|
||||
<title>PersonRepository with query methods</title>
|
||||
|
||||
<programlisting>public interface PersonRepository extends MongoRepository<Person, String> {
|
||||
<programlisting language="java">public interface PersonRepository extends MongoRepository<Person, String> {
|
||||
|
||||
List<Person> findByLastname(String lastname);
|
||||
|
||||
@@ -266,7 +266,7 @@ public class PersonRepositoryTests {
|
||||
</table></para>
|
||||
|
||||
<section>
|
||||
<title>Mongo JSON based query methods and field restriction </title>
|
||||
<title>Mongo JSON based query methods and field restriction</title>
|
||||
|
||||
<para>By adding the annotation
|
||||
<classname>org.springframework.data.document.mongodb.repository.Query</classname>
|
||||
@@ -274,7 +274,7 @@ public class PersonRepositoryTests {
|
||||
use instead of having the query derived from the method name. For
|
||||
example</para>
|
||||
|
||||
<programlisting>public interface PersonRepository extends MongoRepository<Person, String>
|
||||
<programlisting language="java">public interface PersonRepository extends MongoRepository<Person, String>
|
||||
|
||||
@Query("{ 'firstname' : ?0 }")
|
||||
List<Person> findByThePersonsFirstname(String firstname);
|
||||
@@ -285,10 +285,9 @@ public class PersonRepositoryTests {
|
||||
arguments into the JSON query string.</para>
|
||||
|
||||
<para>You can also use the filter property to restrict the set of
|
||||
properties that will be mapped into the Java object. For example,
|
||||
</para>
|
||||
properties that will be mapped into the Java object. For example,</para>
|
||||
|
||||
<programlisting>public interface PersonRepository extends MongoRepository<Person, String>
|
||||
<programlisting language="java">public interface PersonRepository extends MongoRepository<Person, String>
|
||||
|
||||
@Query(value="{ 'firstname' : ?0 }", fields="firstname,lastname")
|
||||
List<Person> findByThePersonsFirstname(String firstname);
|
||||
@@ -330,7 +329,7 @@ public class PersonRepositoryTests {
|
||||
</listitem>
|
||||
|
||||
<listitem>
|
||||
<para>Incremental query definition is easier </para>
|
||||
<para>Incremental query definition is easier</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
@@ -344,7 +343,7 @@ public class PersonRepositoryTests {
|
||||
<para>Using QueryDSL you will be able to write queries as shown
|
||||
below</para>
|
||||
|
||||
<programlisting>QPerson person = new QPerson("person");
|
||||
<programlisting language="java">QPerson person = new QPerson("person");
|
||||
List<Person> result = repository.findAll(person.address.zipCode.eq("C0123"));
|
||||
|
||||
Page<Person> page = repository.findAll(person.lastname.contains("a"),
|
||||
@@ -361,7 +360,7 @@ Page<Person> page = repository.findAll(person.lastname.contains("a"),
|
||||
<interfacename>QueryDslPredicateExecutor</interfacename> which is shown
|
||||
below</para>
|
||||
|
||||
<programlisting>public interface QueryDslPredicateExecutor<T> {
|
||||
<programlisting language="java">public interface QueryDslPredicateExecutor<T> {
|
||||
|
||||
T findOne(Predicate predicate);
|
||||
|
||||
@@ -379,7 +378,7 @@ Page<Person> page = repository.findAll(person.lastname.contains("a"),
|
||||
it in additiion to other repository interfaces. This is shown
|
||||
below</para>
|
||||
|
||||
<programlisting>public interface PersonRepository extends MongoRepository<Person, String>, QueryDslPredicateExecutor<Person> {
|
||||
<programlisting lang="" language="java">public interface PersonRepository extends MongoRepository<Person, String>, QueryDslPredicateExecutor<Person> {
|
||||
|
||||
// additional finder methods go here
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@
|
||||
configuration style. Also change the version of Spring in the pom.xml to
|
||||
be</para>
|
||||
|
||||
<programlisting lang="xml"><spring.framework.version>3.0.5.RELEASE</spring.framework.version></programlisting>
|
||||
<programlisting lang="" language="xml"><spring.framework.version>3.0.5.RELEASE</spring.framework.version></programlisting>
|
||||
|
||||
<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>
|
||||
@@ -127,7 +127,7 @@
|
||||
<para>Next, in the org.spring.mongodb package in the sr/ctest/java
|
||||
directory create a class as shown below.</para>
|
||||
|
||||
<programlisting lang="java">package org.spring.mongodb;
|
||||
<programlisting lang="" language="java">package org.spring.mongodb;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.document.mongodb.MongoTemplate;
|
||||
@@ -525,7 +525,7 @@ public class AppConfig {
|
||||
<para>You can also configure a MongoTemplate using Spring's XML
|
||||
<beans/> schema.</para>
|
||||
|
||||
<programlisting> <mongo:mongo host="localhost" port="27017"/>
|
||||
<programlisting language="java"> <mongo:mongo host="localhost" port="27017"/>
|
||||
|
||||
<bean id="mongoTemplate" class="org.springframework.data.document.mongodb.MongoTemplate">
|
||||
<constructor-arg ref="mongo"/>
|
||||
@@ -595,7 +595,7 @@ public class AppConfig {
|
||||
|
||||
<para>Given a simple class such as Person</para>
|
||||
|
||||
<programlisting>public class Person {
|
||||
<programlisting language="java">public class Person {
|
||||
|
||||
private String id;
|
||||
private String firstName;
|
||||
@@ -790,7 +790,7 @@ import static org.springframework.data.document.mongodb.query.Criteria.query;
|
||||
over the mapping of an object into a DBObject. The MongoWriter
|
||||
interface is </para>
|
||||
|
||||
<programlisting>/**
|
||||
<programlisting language="java">/**
|
||||
* A MongoWriter is responsible for converting an object of type T to the native MongoDB representation DBObject.
|
||||
*
|
||||
* @param <T> the type of the object to convert to a DBObject
|
||||
@@ -873,8 +873,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>
|
||||
|
||||
@@ -1456,7 +1456,7 @@ import static org.springframework.data.document.mongodb.query.Query.query;
|
||||
the role of RowMapper in JdbcTemplate. The MongoReader interface
|
||||
is</para>
|
||||
|
||||
<programlisting>/**
|
||||
<programlisting language="java">/**
|
||||
* A MongoWriter is responsible for converting a native MongoDB DBObject to an object of type T.
|
||||
*
|
||||
* @param <T> the type of the object to convert from a DBObject
|
||||
@@ -1535,30 +1535,30 @@ public class Venue {
|
||||
<para>To find locations within a circle, the following query can be
|
||||
used.</para>
|
||||
|
||||
<programlisting lang="java">Circle circle = new Circle(-73.99171, 40.738868, 0.01);
|
||||
<programlisting lang="" language="java">Circle circle = new Circle(-73.99171, 40.738868, 0.01);
|
||||
List<Venue> venues = template.find(new Query(Criteria.where("location").withinCenter(circle)), Venue.class);</programlisting>
|
||||
|
||||
<para>To find venues within a circle using Spherical coordinates the
|
||||
following query can be used</para>
|
||||
|
||||
<programlisting lang="java">Circle circle = new Circle(-73.99171, 40.738868, 0.003712240453784);
|
||||
<programlisting lang="" language="java">Circle circle = new Circle(-73.99171, 40.738868, 0.003712240453784);
|
||||
List<Venue> venues = template.find(new Query(Criteria.where("location").withinCenterSphere(circle)), Venue.class);</programlisting>
|
||||
|
||||
<para>To find venues within a Box the following query can be used</para>
|
||||
|
||||
<programlisting>Box box = new Box(new Point(-73.99756, 40.73083), new Point(-73.988135, 40.741404)); //lower-left then upper-right
|
||||
<programlisting language="java">Box box = new Box(new Point(-73.99756, 40.73083), new Point(-73.988135, 40.741404)); //lower-left then upper-right
|
||||
List<Venue> venues = template.find(new Query(Criteria.where("location").withinBox(box)), Venue.class);</programlisting>
|
||||
|
||||
<para>To find venues near a Point, the following query can be
|
||||
used</para>
|
||||
|
||||
<programlisting>Point point = new Point(-73.99171, 40.738868);
|
||||
<programlisting language="java">Point point = new Point(-73.99171, 40.738868);
|
||||
List<Venue> venues = template.find(new Query(Criteria.where("location").near(point).maxDistance(0.01)), Venue.class);</programlisting>
|
||||
|
||||
<para>To find venues near a Point using Spherical coordines the
|
||||
following query can be used</para>
|
||||
|
||||
<programlisting>Point point = new Point(-73.99171, 40.738868);
|
||||
<programlisting language="java">Point point = new Point(-73.99171, 40.738868);
|
||||
List<Venue> venues = template.find(new Query(Criteria.where("location").nearSphere(point).maxDistance(0.003712240453784)), Venue.class);
|
||||
</programlisting>
|
||||
|
||||
@@ -1584,9 +1584,7 @@ List<Venue> venues = template.find(new Query(Criteria.where("location").ne
|
||||
<example>
|
||||
<title>Creating an index using the MongoTemplate</title>
|
||||
|
||||
<programlisting language="java">mongoTemplate.ensureIndex("MyCollection", new Index().on("name",
|
||||
Order.ASCENDING));
|
||||
</programlisting>
|
||||
<programlisting language="java">mongoTemplate.ensureIndex("MyCollection", new Index().on("name",Order.ASCENDING)); </programlisting>
|
||||
</example>
|
||||
|
||||
<para><itemizedlist>
|
||||
@@ -1611,7 +1609,7 @@ List<Venue> venues = template.find(new Query(Criteria.where("location").ne
|
||||
the Venue class defined in a previous section, you would declare a
|
||||
geospatial query as shown below</para>
|
||||
|
||||
<programlisting>mongoTemplate.ensureIndex(new GeospatialIndex("location"));</programlisting>
|
||||
<programlisting language="java">mongoTemplate.ensureIndex(new GeospatialIndex("location"));</programlisting>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
@@ -1625,12 +1623,11 @@ List<Venue> venues = template.find(new Query(Criteria.where("location").ne
|
||||
<title>Working with collections using the MongoTemplate</title>
|
||||
|
||||
<programlisting language="java">DBCollection collection = null;
|
||||
if (!mongoTemplate.getCollectionNames().contains("MyNewCollection")) {
|
||||
collection = mongoTemplate.createCollection("MyNewCollection");
|
||||
}
|
||||
if (!mongoTemplate.getCollectionNames().contains("MyNewCollection")) {
|
||||
collection = mongoTemplate.createCollection("MyNewCollection");
|
||||
}
|
||||
|
||||
mongoTemplate.dropCollection("MyNewCollection");
|
||||
</programlisting>
|
||||
mongoTemplate.dropCollection("MyNewCollection"); </programlisting>
|
||||
</example>
|
||||
|
||||
<para><itemizedlist>
|
||||
|
||||
Reference in New Issue
Block a user