Class EntityKey

  • All Implemented Interfaces:
    java.io.Serializable

    public final class EntityKey
    extends java.lang.Object
    implements java.io.Serializable
    Uniquely identifies of an entity instance in a particular Session by identifier. Note that it's only safe to be used within the scope of a Session: it doesn't consider for example the tenantId as part of the equality definition.

    Information used to determine uniqueness consists of the entity-name and the identifier value (see equals(java.lang.Object)).

    Performance considerations: lots of instances of this type are created at runtime. Make sure each one is as small as possible by storing just the essential needed.

    See Also:
    Serialized Form
    • Method Detail

      • isBatchLoadable

        public boolean isBatchLoadable()
      • getIdentifier

        public java.io.Serializable getIdentifier()
      • getEntityName

        public java.lang.String getEntityName()
      • equals

        public boolean equals​(java.lang.Object other)
        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
      • serialize

        public void serialize​(java.io.ObjectOutputStream oos)
                       throws java.io.IOException
        Custom serialization routine used during serialization of a Session/PersistenceContext for increased performance.
        Parameters:
        oos - The stream to which we should write the serial data.
        Throws:
        java.io.IOException - Thrown by Java I/O
      • deserialize

        public static EntityKey deserialize​(java.io.ObjectInputStream ois,
                                            SessionFactoryImplementor sessionFactory)
                                     throws java.io.IOException,
                                            java.lang.ClassNotFoundException
        Custom deserialization routine used during deserialization of a Session/PersistenceContext for increased performance.
        Parameters:
        ois - The stream from which to read the entry.
        sessionFactory - The SessionFactory owning the Session being deserialized.
        Returns:
        The deserialized EntityEntry
        Throws:
        java.io.IOException - Thrown by Java I/O
        java.lang.ClassNotFoundException - Thrown by Java I/O