java.lang.Object
java.lang.Record
org.litebridge.orm.api.spec.ManyToMany
- Record Components:
joinTable- The name of the join table facilitating the many-to-many relationship.joinColumns- The column(s) in the join table that references the primary key of the originating table.inverseJoinColumns- The column(s) in the join table that references the primary key of the targeted table.
- All Implemented Interfaces:
ColumnMapping
public record ManyToMany(String joinTable, String[] joinColumns, String[] inverseJoinColumns)
extends Record
implements ColumnMapping
Represents a many-to-many relationship mapping between two tables using a join table.
This class is used within the context of the ORM to define a mapping where entities in one table are associated with multiple entities in another table, and the relationship is facilitated through an intermediate join table.
The `ManyToMany` relationship is commonly used to model use cases such as: - Students enrolled in multiple courses, and courses attended by multiple students. - Products associated with multiple categories, and categories assigned to multiple products.
Implements the ColumnMapping interface, allowing its usage in column-level mappings.
-
Constructor Summary
ConstructorsConstructorDescriptionManyToMany(String joinTable, String[] joinColumns, String[] inverseJoinColumns) Creates an instance of aManyToManyrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.String[]Returns the value of theinverseJoinColumnsrecord component.String[]Returns the value of thejoinColumnsrecord component.Returns the value of thejoinTablerecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
ManyToMany
Creates an instance of aManyToManyrecord class.- Parameters:
joinTable- the value for thejoinTablerecord componentjoinColumns- the value for thejoinColumnsrecord componentinverseJoinColumns- the value for theinverseJoinColumnsrecord component
-
-
Method Details
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
joinTable
Returns the value of thejoinTablerecord component.- Returns:
- the value of the
joinTablerecord component
-
joinColumns
Returns the value of thejoinColumnsrecord component.- Returns:
- the value of the
joinColumnsrecord component
-
inverseJoinColumns
Returns the value of theinverseJoinColumnsrecord component.- Returns:
- the value of the
inverseJoinColumnsrecord component
-