diff --git a/src/docbkx/reference/mongodb.xml b/src/docbkx/reference/mongodb.xml
index 20bafe133..40f1eacfc 100644
--- a/src/docbkx/reference/mongodb.xml
+++ b/src/docbkx/reference/mongodb.xml
@@ -136,60 +136,43 @@
additional information, edit the log4j.properties file to have
log4j.category.org.springframework.data.document.mongodb=DEBUG
-log4j.appender.stdout.layout.ConversionPattern=%-5p [%c{3}]: %m%n
+log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %40.40c:%4L - %m%n
Create a simple Person class to persist
- package org.spring.mongodb;
+ package org.spring.example;
public class Person {
private String id;
- private String firstName;
- private String lastName;
+ private String name;
private int age;
-
- public Person(String firstName, String lastName, int age) {
- this.firstName = firstName;
- this.lastName = lastName;
+
+ public Person(String name, int age) {
+ this.name = name;
this.age = age;
}
- public String getFirstName() {
- return firstName;
- }
-
- public void setFirstName(String firstName) {
- this.firstName = firstName;
- }
-
- public String getLastName() {
- return lastName;
+
+ public String getId() {
+ return id;
}
-
- public void setLastName(String lastName) {
- this.lastName = lastName;
+ public String getName() {
+ return name;
}
-
public int getAge() {
return age;
}
-
- public void setAge(int age) {
- this.age = age;
- }
-
+
@Override
public String toString() {
- return "Person [id=" + id + ", firstName=" + firstName + ", lastName="
- + lastName + ", age=" + age + "]";
+ return "Person [id=" + id + ", name=" + name + ", age=" + age + "]";
}
-
}
And a main application to run
- package org.spring.mongodb;
+ package org.spring.example;
import static org.springframework.data.document.mongodb.query.Criteria.where;
@@ -199,85 +182,85 @@ import org.springframework.data.document.mongodb.MongoOperations;
import org.springframework.data.document.mongodb.MongoTemplate;
import org.springframework.data.document.mongodb.query.Query;
-import org.spring.mongodb.Person;
+import com.mongodb.Mongo;
public class MongoApp {
private static final Log log = LogFactory.getLog(MongoApp.class);
- public static void main(String[] args) {
+ public static void main(String[] args) throws Exception {
MongoOperations mongoOps = new MongoTemplate(new Mongo(), "database");
-
- mongoOps.insert(new Person("Joe", "Swanson", 34));
- log.info( mongoOps.findOne(new Query(where("firstName").is("Joe")), Person.class) );
+ mongoOps.insert(new Person("Joe", 34));
+
+ log.info(mongoOps.findOne(new Query(where("name").is("Joe")), Person.class));
mongoOps.dropCollection("person");
}
-
}
This will produce the following output
- DEBUG [mongodb.mapping.MongoPersistentEntityIndexCreator]: Analyzing class class org.mongo.demo2.domain.Person for index information.
-DEBUG [document.mongodb.MongoTemplate]: insert DBObject containing fields: [_class, lastName, age, firstName] in collection: Person
-DEBUG [document.mongodb.MongoTemplate]: findOne using query: { "firstName" : "Joe"} in db.collection: database.Person
-INFO [spring.mongodb.MongoApp]: Person [id=4ddb2f629e60ab6a21da5fdb, firstName=Joe, lastName=Swanson, age=34]
-DEBUG [document.mongodb.MongoTemplate]: Dropped collection [database.person]
-
-
- If you are not using Maven then you would need to include the
- following jars on the classpath for a basic Spring MongoDB
- application:
-
-
-
- spring-data-commons-core-1.1.0.M1.jar
-
-
-
- spring-data-mongodb-1.0.0.M3.jar
-
- In addition to the above listed Spring Data jars you
- need to provide the following dependencies:
-
- com.springsource.org.aopalliance-1.0.0.jar
-
+ 10:01:32,062 DEBUG apping.MongoPersistentEntityIndexCreator: 80 - Analyzing class class org.spring.example.Person for index information.
+10:01:32,265 DEBUG work.data.document.mongodb.MongoTemplate: 631 - insert DBObject containing fields: [_class, age, name] in collection: Person
+10:01:32,765 DEBUG work.data.document.mongodb.MongoTemplate:1243 - findOne using query: { "name" : "Joe"} in db.collection: database.Person
+10:01:32,953 INFO org.spring.example.MongoApp: 25 - Person [id=4ddbba3c0be56b7e1b210166, name=Joe, age=34]
+10:01:32,984 DEBUG work.data.document.mongodb.MongoTemplate: 375 - Dropped collection [database.person]
-
- commons-logging-1.1.1.jar
-
+ The quick brown fox.
-
- mongo-java-driver-2.5.3.jar
-
-
-
- spring-aop-3.0.5.RELEASE.jar
-
-
-
- spring-asm-3.0.5.RELEASE.jar
-
-
-
- spring-beans-3.0.5.RELEASE.jar
-
-
-
- spring-context-3.0.5.RELEASE.jar
-
-
-
- spring-core-3.0.5.RELEASE.jar
-
+
+ Required Jars
-
- spring-expression-3.0.5.RELEASE.jar
-
-
+
+ spring-data-document-core-1.0.0.M3.jar
+
+
+
+ spring-data-mongodb-1.0.0.M3.jar
+
+ In addition to the above listed Spring Data jars
+ you need to provide the following dependencies:
+
+ com.springsource.org.aopalliance-1.0.0.jar
+
+
+
+ commons-logging-1.1.1.jar
+
+
+
+ mongo-java-driver-2.5.3.jar
+
+
+
+ spring-aop-3.0.5.RELEASE.jar
+
+
+
+ spring-asm-3.0.5.RELEASE.jar
+
+
+
+ spring-beans-3.0.5.RELEASE.jar
+
+
+
+ spring-context-3I.0.5.RELEASE.jar
+
+
+
+ spring-core-3.0.5.RELEASE.jar
+
+
+
+ spring-expression-3.0.5.RELEASE.jar
+
+
+
+