All Implemented Interfaces:
Serializable

@Entity(name="Course") public class Course extends BaseEntity<Long>
The Course entity represents a course used by an Event's Race.

The Course's fields are defined as follows:

  • id : the unique identifier of the Course that is automatically generated and is the primary key.
  • event : the Event to which the Course belongs.
  • title : the title of the Course, typically consisting of the name of the Course's sport and its distance, such as "Sprint Triathlon" or "Standard Duathlon". When an Event has different courses with the same distance (e.g. with different routes), a second reference should be added to the title of the Course so that they can be unambiguously differentiated.
  • sport : the Sport of the Race that the Course is used for.
  • distance : the data of a Course's Distance. Each Course has a unique Distance, and distances are not shared across multiple courses. The relationship is unidirectional, meaning Distance does not have a reference back to Course. Deleting a Course will also delete its associated Distance due to cascading and orphan removal settings.
  • races : the races that the Course is used for.
See Also:
  • Constructor Details

    • Course

      public Course()
      Default constructor for the Course entity.
  • Method Details

    • addRace

      public void addRace(Race race)
      Adds a Race to this Course's races collection. Ensures bidirectional consistency by also adding this Course to the Race's courses collection.
      Parameters:
      race - the Race to add; ignored if null or already present
    • removeRace

      public void removeRace(Race race)
      Removes a Race from this Course's races collection. Ensures bidirectional consistency by also removing this Course from the Race's courses collection.
      Parameters:
      race - the Race to remove; ignored if null or not present
    • getEvent

      public Event getEvent()
    • setEvent

      public void setEvent(Event event)
    • getTitle

      public String getTitle()
    • setTitle

      public void setTitle(String title)
    • getSport

      public Sport getSport()
    • setSport

      public void setSport(Sport sport)
    • getDistance

      public Distance getDistance()
    • setDistance

      public void setDistance(Distance distance)
    • getRaces

      public Set<Race> getRaces()
    • setRaces

      public void setRaces(Set<Race> races)
    • equals

      public boolean equals(Object o)
      Description copied from class: BaseEntity
      Equality is based on the entity's identifier. Two entities are considered equal if they are of the same class and have the same non-null identifier.

      If the ID is null, we treat it as a transient (new) object. Transient objects are only equal if they are the exact same instance.

      Overrides:
      equals in class BaseEntity<Long>
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class BaseEntity<Long>
    • toString

      public String toString()
      Overrides:
      toString in class Object