Package org.mongojack
Class DbReferenceManager
- java.lang.Object
-
- org.mongojack.DbReferenceManager
-
public class DbReferenceManager extends Object
-
-
Constructor Summary
Constructors Constructor Description DbReferenceManager(com.mongodb.client.MongoClient mongoClient, com.fasterxml.jackson.databind.ObjectMapper objectMapper, String defaultDatabaseName, org.bson.UuidRepresentation uuidRepresentation)
DbReferenceManager(com.mongodb.client.MongoClient mongoClient, String defaultDatabaseName, org.bson.UuidRepresentation uuidRepresentation)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <R,RK>
List<R>fetch(Collection<DBRef<R,RK>> refs)
Fetch a refs of dbrefs.<R,RK>
List<R>fetch(Collection<DBRef<R,RK>> refs, org.bson.conversions.Bson fields)
Fetch a refs of dbrefs.<R,RK>
Rfetch(DBRef<R,RK> ref)
Fetches the underlying value for a single DBRef.<R,RK>
Rfetch(DBRef<R,RK> ref, org.bson.conversions.Bson fields)
Fetches the underlying value for a single DBRef.<CT> JacksonMongoCollection<CT>
getReferenceCollection(String databaseName, String collectionName, Class<CT> valueClass)
Get a collection for loading a reference of the given type<CT> JacksonMongoCollection<CT>
getReferenceCollection(JacksonCollectionKey<CT> collectionKey)
Get a collection for loading a reference of the given typevoid
registerCollection(JacksonMongoCollection<?> collection)
Register a collection so that it will be used (as opposed to an internally built one) when retrieving references.
-
-
-
Constructor Detail
-
DbReferenceManager
public DbReferenceManager(com.mongodb.client.MongoClient mongoClient, com.fasterxml.jackson.databind.ObjectMapper objectMapper, String defaultDatabaseName, org.bson.UuidRepresentation uuidRepresentation)
-
DbReferenceManager
public DbReferenceManager(com.mongodb.client.MongoClient mongoClient, String defaultDatabaseName, org.bson.UuidRepresentation uuidRepresentation)
-
-
Method Detail
-
getReferenceCollection
public <CT> JacksonMongoCollection<CT> getReferenceCollection(String databaseName, String collectionName, Class<CT> valueClass)
Get a collection for loading a reference of the given type- Type Parameters:
CT
- The type of the values in the collection- Parameters:
databaseName
- Name of the DB that holds the collectioncollectionName
- The name of the collectionvalueClass
- The type of the values in the collection- Returns:
- The collection
-
getReferenceCollection
public <CT> JacksonMongoCollection<CT> getReferenceCollection(JacksonCollectionKey<CT> collectionKey)
Get a collection for loading a reference of the given type- Type Parameters:
CT
- The type of values in the collection- Parameters:
collectionKey
- The key for the collection- Returns:
- The collection
-
fetch
public <R,RK> R fetch(DBRef<R,RK> ref)
Fetches the underlying value for a single DBRef.- Type Parameters:
R
- The type the ref points to.RK
- The type of ID the ref points to- Parameters:
ref
- The reference- Returns:
- A ref, or null if the underlying value is nto found
-
fetch
public <R,RK> R fetch(DBRef<R,RK> ref, org.bson.conversions.Bson fields)
Fetches the underlying value for a single DBRef.- Type Parameters:
R
- The type the ref points to.RK
- The type of ID the ref points to- Parameters:
ref
- The referencefields
- A Bson representing the projection to be used.- Returns:
- A ref, or null if the underlying value is nto found
-
fetch
public <R,RK> List<R> fetch(Collection<DBRef<R,RK>> refs)
Fetch a refs of dbrefs. This is more efficient than fetching one at a time.- Type Parameters:
R
- The type of the referenceRK
- The identifier type- Parameters:
refs
- the refs to fetch- Returns:
- The refs of referenced objcets
-
fetch
public <R,RK> List<R> fetch(Collection<DBRef<R,RK>> refs, org.bson.conversions.Bson fields)
Fetch a refs of dbrefs. This is more efficient than fetching one at a time.- Type Parameters:
R
- The type of the referenceRK
- The identifier type- Parameters:
refs
- the refs to fetchfields
- The fields to retrieve for each of the documents- Returns:
- The refs of referenced objects
-
registerCollection
public void registerCollection(JacksonMongoCollection<?> collection)
Register a collection so that it will be used (as opposed to an internally built one) when retrieving references.- Parameters:
collection
- The collection to register
-
-