dbref

Spring data and mongoDB - inheritance and @DBRef

前提是你 提交于 2020-02-24 11:34:37
问题 I have this two documents, User: @Document(collection = "User") public class User { // fields } and Contact: @Document(collection = "Contact") public class Contact extends User{ // fields } and then I have a document which referes either to User oder Contact: @Document(collection = "DocumentFile") public class DocumentFile { @DBRef private User user; } So I am able to add User oder Contact in DocumentFile#user but if I set a Contact to DocumentFile#user than I lost the reference because in

Spring data and mongoDB - inheritance and @DBRef

我的梦境 提交于 2020-02-24 11:34:06
问题 I have this two documents, User: @Document(collection = "User") public class User { // fields } and Contact: @Document(collection = "Contact") public class Contact extends User{ // fields } and then I have a document which referes either to User oder Contact: @Document(collection = "DocumentFile") public class DocumentFile { @DBRef private User user; } So I am able to add User oder Contact in DocumentFile#user but if I set a Contact to DocumentFile#user than I lost the reference because in

mongodb query on DBRef type

醉酒当歌 提交于 2020-01-05 08:36:22
问题 How do I turn this query in a valid mongodb Query in mongodb shell. { 'cars.owner.$ref' : 'users' } cars.owner is a DBRef here, but $ref is invalid I get this error: "$err" : "Positional operator does not match the query specifier." My objective here is to figure out if there are any cars "owned" by different collections then users. 回答1: MongoDB documentation (database-reference) says following: MongoDB applications use one of two methods for relating documents: Manual references where you

Updating nested emdedded list containing BasicDBObject to DBRef in mongoDB using groovy

﹥>﹥吖頭↗ 提交于 2019-12-25 01:53:32
问题 The structure of document in mongo is as follows Project(@Entity) |--Deliverables(@Embedded, list inside Project) |--DeliveryTypes(@Embedded, list inside Deliverables) |--DeliveryItems(Plain list inside DeliveryTypes) |--log(Plain list inside DeliveryItems) and the other possible structure of document in mongo is as follows Project(@Entity) |--Deliverables(@Embedded, list inside Project) |--DeliveryTypes(@Embedded, list inside Deliverables) |--DeliveryItems(Plain list inside DeliveryTypes) |-

Spring Data - MongoDB: Unable to retrieve DBRef document that belongs to another database

我的梦境 提交于 2019-12-24 08:33:15
问题 I have a Entity Market(market is stored in a collection within marketDb database) that references Product (stored in a collection product in productDb database ). /*Entity */ class Market { @DBRef (db = "productDb") private Product product; } /**Market is stored in the collection as: */ { "_id": "4f0bc0e6-b6a8-11e6-a04d-080027e9004f", "_class": "com.package.Market", "createdById": "123", "editedById": "123", "name": "Market01", "clientId": NumberLong("1"), "version": NumberLong("1"), "product

Nodejs + mongodb : How to query $ref fields?

霸气de小男生 提交于 2019-12-21 04:08:12
问题 I'am using MongoDB with a nodejs REST service which exposes my data stored inside. I have a question about how to interrogate my data which uses $ref. Here is a sample of an Object which contains a reference to another object (detail) in anther collection : { "_id" : ObjectId("5962c7b53b6a02100a000085"), "Title" : "test", "detail" : { "$ref" : "ObjDetail", "$id" : ObjectId("5270c7b11f6a02100a000001") }, "foo" : bar } Actually, using Node.js and mongodb module, I do the following : db

Spring Data - MongoDB indexing DBRef

独自空忆成欢 提交于 2019-12-21 03:57:35
问题 I'm using spring-data-mongodb-1.2.0.RELEASE. I have two classes A and B where B has a reference to A and it is annotated with @DBRef. Class A: @Document(collection = "a") public class A { @Id public String id; /** The TicketGrantingTicket this is associated with. */ @Field public String name; public A(String id, String name) { this.id = id; this.name = name; } } Class B: @Document(collection = "b") public class B { @Id public String id; @Field public String name; @DBRef @Indexed public A a;

MongoDB - DBRef

人走茶凉 提交于 2019-12-20 06:29:11
问题 I am having some troubles with DBRef, look this case: db.fruit.save ({"_id" : "1" , "name" : "apple"}); db.fruit.save ({"_id" : "2" , "name" : "grape"}); db.fruit.save ({"_id" : "3" , "name" : "orange"}); db.fruit.save ({"_id" : "4" , "name" : "pineapple"}); db.basket.save ({"_id" : "1", "items" : [ {"$ref" : "fruit", "$id" : "1", "quantity" : 5}, {"$ref" : "fruit", "$id" : "3", "quantity" : 10} ]}) Now, lets find the "basket" collection: > db.basket.find () { "_id" : "1", "items" : [ { "$ref

How to reference GridFSFile with @DbRef annotation (spring data mongodb)

蓝咒 提交于 2019-12-13 14:34:20
问题 i have a spring @Document object Profile i would like to reference GridFSFile like it : @DbRef private GridFSFile file; the file is writen into another collection type GridFS. I always have a java.lang.StackOverflowError when i set profile.setFile(file); java.lang.StackOverflowError at org.springframework.util.ObjectUtils.nullSafeHashCode(ObjectUtils.java:336) at org.springframework.data.util.TypeDiscoverer.hashCode(TypeDiscoverer.java:365) at org.springframework.data.util

Spring MongoDB + QueryDSL query by @DBRef related object

吃可爱长大的小学妹 提交于 2019-12-12 09:40:00
问题 I am using spring-data-mongodb and querydsl-mongodb to perform more flexible queries. My application has users and orders. An user can have multiple orders, so my models looks like this: public class User { @Id private String id; private String username; //getters and setters } public class Order { @Id private String id; @DBRef private User user; //getters and setters } As you can see, there is an has-many relationship between users and orders. Each order is assigned to an user, and the user