Spring Data MongoDB - Spring Web Services - Parent - SpringSource
Spring Data MongoDB - Spring Web Services - Parent - SpringSource Spring Data MongoDB - Spring Web Services - Parent - SpringSource
please define productname in your docbook file!Methods for querying for documentsThe query methods need to specify the target type T that will be returned and they are also overloadedwith an explicit collection name for queries that should operate on a collection other than the oneindicated by the return type.• findAll Query for a list of objects of type T from the collection.• findOne Map the results of an ad-hoc query on the collection to a single instance of an object of thespecified type.• findById Return an object of the given id and target class.• find Map the results of an ad-hoc query on the collection to a List of the specified type.• findAndRemove Map the results of an ad-hoc query on the collection to a single instance of an objectof the specified type. The first document that matches the query is returned and also removed fromthe collection in the database.GeoSpatial QueriesMongoDB supports GeoSpatial queries through the use of operators such as $near, $within, and$nearSphere. Methods specific to geospatial queries are available on the Criteria class. There arealso a few shape classes, Box, Circle, and Point that are used in conjunction with geospatial relatedCriteria methods.To understand how to perform GeoSpatial queries we will use the following Venue class taken from theintegration tests.which relies on using the rich MappingMongoConverter.1.4.0.BUILD-SNAPSHOTSpring Data MongoDB -Reference Documentation 47
please define productname in your docbook file!@Document(collection="newyork")public class Venue {@Idprivate String id;private String name;private double[] location;@PersistenceConstructorVenue(String name, double[] location) {super();this.name = name;this.location = location;}public Venue(String name, double x, double y) {super();this.name = name;this.location = new double[] { x, y };}public String getName() {return name;}public double[] getLocation() {return location;}}@Overridepublic String toString() {return "Venue [id=" + id + ", name=" + name + ", location="+ Arrays.toString(location) + "]";}To find locations within a Circle, the following query can be used.Circle circle = new Circle(-73.99171, 40.738868, 0.01);List venues =template.find(new Query(Criteria.where("location").withinCenter(circle)),Venue.class);To find venues within a Circle using spherical coordinates the following query can be usedCircle circle = new Circle(-73.99171, 40.738868, 0.003712240453784);List venues =template.find(new Query(Criteria.where("location").withinCenterSphere(circle)),Venue.class);To find venues within a Box the following query can be used//lower-left then upper-rightBox box = new Box(new Point(-73.99756, 40.73083), new Point(-73.988135, 40.741404));List venues =template.find(new Query(Criteria.where("location").withinBox(box)), Venue.class);To find venues near a Point, the following query can be used1.4.0.BUILD-SNAPSHOTSpring Data MongoDB -Reference Documentation 48
- Page 1 and 2: Spring Data MongoDB - Reference Doc
- Page 3 and 4: please define productname in your d
- Page 5 and 6: please define productname in your d
- Page 7 and 8: please define productname in your d
- Page 9 and 10: please define productname in your d
- Page 11: please define productname in your d
- Page 14 and 15: please define productname in your d
- Page 16 and 17: please define productname in your d
- Page 18 and 19: please define productname in your d
- Page 20 and 21: please define productname in your d
- Page 22 and 23: please define productname in your d
- Page 24 and 25: please define productname in your d
- Page 26 and 27: please define productname in your d
- Page 28 and 29: please define productname in your d
- Page 30 and 31: please define productname in your d
- Page 32 and 33: please define productname in your d
- Page 34 and 35: please define productname in your d
- Page 36 and 37: please define productname in your d
- Page 38 and 39: please define productname in your d
- Page 40 and 41: please define productname in your d
- Page 42 and 43: please define productname in your d
- Page 44 and 45: please define productname in your d
- Page 46 and 47: please define productname in your d
- Page 48 and 49: please define productname in your d
- Page 50 and 51: please define productname in your d
- Page 54 and 55: please define productname in your d
- Page 56 and 57: please define productname in your d
- Page 58 and 59: please define productname in your d
- Page 60 and 61: please define productname in your d
- Page 62 and 63: please define productname in your d
- Page 64 and 65: please define productname in your d
- Page 66 and 67: please define productname in your d
- Page 68 and 69: please define productname in your d
- Page 70 and 71: please define productname in your d
- Page 72 and 73: please define productname in your d
- Page 74 and 75: please define productname in your d
- Page 76 and 77: please define productname in your d
- Page 78 and 79: please define productname in your d
- Page 80 and 81: please define productname in your d
- Page 82 and 83: please define productname in your d
- Page 84 and 85: please define productname in your d
- Page 86 and 87: please define productname in your d
- Page 88 and 89: please define productname in your d
- Page 90 and 91: please define productname in your d
- Page 92 and 93: please define productname in your d
- Page 94 and 95: please define productname in your d
- Page 96 and 97: please define productname in your d
- Page 98 and 99: please define productname in your d
- Page 100 and 101: please define productname in your d
please define productname in your docbook file!Methods for querying for documentsThe query methods need to specify the target type T that will be returned and they are also overloadedwith an explicit collection name for queries that should operate on a collection other than the oneindicated by the return type.• findAll Query for a list of objects of type T from the collection.• findOne Map the results of an ad-hoc query on the collection to a single instance of an object of thespecified type.• findById Return an object of the given id and target class.• find Map the results of an ad-hoc query on the collection to a List of the specified type.• findAndRemove Map the results of an ad-hoc query on the collection to a single instance of an objectof the specified type. The first document that matches the query is returned and also removed fromthe collection in the database.GeoSpatial Queries<strong>MongoDB</strong> supports GeoSpatial queries through the use of operators such as $near, $within, and$nearSphere. Methods specific to geospatial queries are available on the Criteria class. There arealso a few shape classes, Box, Circle, and Point that are used in conjunction with geospatial relatedCriteria methods.To understand how to perform GeoSpatial queries we will use the following Venue class taken from theintegration tests.which relies on using the rich MappingMongoConverter.1.4.0.BUILD-SNAPSHOT<strong>Spring</strong> <strong>Data</strong> <strong>MongoDB</strong> -Reference Documentation 47