Package com.mongodb

Class DBRef

  • All Implemented Interfaces:
    java.io.Serializable


    public class DBRef
    extends java.lang.Object
    implements java.io.Serializable
    A representation of a database reference.
    See Also:
    Serialized Form
    MongoDB documentation
    Database References
    • Constructor Summary

      Constructors 
      Constructor Description
      DBRef​(java.lang.String collectionName, java.lang.Object id)
      Construct an instance.
      DBRef​(java.lang.String databaseName, java.lang.String collectionName, java.lang.Object id)
      Construct an instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)  
      java.lang.String getCollectionName​()
      Gets the name of the collection in which the referenced document is stored.
      java.lang.String getDatabaseName​()
      Gets the name of the database in which the referenced document is stored.
      java.lang.Object getId​()
      Gets the _id of the referenced document
      int hashCode​()  
      java.lang.String toString​()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • DBRef

        public DBRef​(java.lang.String collectionName,
                     java.lang.Object id)
        Construct an instance.
        Parameters:
        collectionName - the name of the collection where the document is stored
        id - the object id
      • DBRef

        public DBRef​(@Nullable
                     java.lang.String databaseName,
                     java.lang.String collectionName,
                     java.lang.Object id)
        Construct an instance.
        Parameters:
        databaseName - the name of the database where the document is stored
        collectionName - the name of the collection where the document is stored
        id - the object id
        Since:
        3.3
    • Method Detail

      • getId

        public java.lang.Object getId​()
        Gets the _id of the referenced document
        Returns:
        the _id of the referenced document
      • getCollectionName

        public java.lang.String getCollectionName​()
        Gets the name of the collection in which the referenced document is stored.
        Returns:
        the name of the collection in which the referenced is stored
      • getDatabaseName

        @Nullable
        public java.lang.String getDatabaseName​()
        Gets the name of the database in which the referenced document is stored. A null value implies that the referenced document is stored in the same database as the referring document.
        Returns:
        the possibly-null database name
        Since:
        3.3
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode​()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString​()
        Overrides:
        toString in class java.lang.Object