Class BasicData

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int hashCode
      Stores the hash code of the item.
      private int id  
      private int version  
    • Constructor Summary

      Constructors 
      Constructor Description
      BasicData()  
    • Field Detail

      • hashCode

        private int hashCode
        Stores the hash code of the item. This value is initialised the first time it is asked for by an application.
        See Also:
        hashCode()
      • id

        private int id
      • version

        private int version
    • Constructor Detail

      • BasicData

        public BasicData()
    • Method Detail

      • toString

        public String toString()
        The string will look like ClassName[id=55] or ClassName[new].
        Overrides:
        toString in class Object
      • equals

        public boolean equals​(Object other)
        Check if this item is equal to another item. They are considered to be equal if they are of the same class and have the same ID. Items that has not yet been assigned an ID (id == 0) are equal only if they refer to the same object instance. We must also handle the fact that the other object can be a Hibernate proxy, which is a dynamically generated subclass of the actual class. Do not override this method in a subclass!
        Overrides:
        equals in class Object
      • hashCode

        public int hashCode()
        For new items (getId() returns 0) the hash code is the same as returned by the System.identityHashCode() method. Items loaded from the database uses the id as the hash code. We must also consider the case were a new object is saved to the database. Our recommendation is to not place the object in Set (or other structure) that calls the hashCode method before the object is saved to the database. If you do that the contract for the equals()/hashCode() method is broken and equals() may return true even if hashCode() returns different values. Do not override this method in a subclass!
        Overrides:
        hashCode in class Object
      • getId

        public int getId()
        Get the id of the item. The id is automatically generated by the database the first time the item is saved to the database. A new item has the value 0.
        Specified by:
        getId in interface IdentifiableData
        Returns:
        The id of the item or 0
        Hibernate: id
        column="`id`" type="int" generator-class="native" unsaved-value="0"
      • setId

        void setId​(int id)
        Set the id of the item. Only used by Hibernate.
        Parameters:
        id - The id of the item
      • getVersion

        @NotLoggable
        public int getVersion()
        Get the version of the item. This value is used by Hibernate to check if another process or thread has modified the corresponding row in the databse since this item was loaded from the. If that is the case, this item can't be saved and an exception will be thrown.
        Specified by:
        getVersion in interface IdentifiableData
        Hibernate: version
        column="`version`" type="int"
      • setVersion

        void setVersion​(int version)
        Set the version of the item. Only used by Hibernate.
        Parameters:
        version - The version of the item