ManyToMany class

ManyToMany relationship annotation

Creates a junction table to link two entities.

Example:

// In UserEntity
@ManyToMany(
  targetEntity: RoleEntity,
  joinTable: JoinTable(
    name: 'user_roles',
    joinColumn: JoinColumn(name: 'user_id', referencedColumn: 'id'),
    inverseJoinColumn: JoinColumn(name: 'role_id', referencedColumn: 'id'),
  ),
)
List<RoleEntity>? roles;

// In RoleEntity (inverse side)
@ManyToMany(
  targetEntity: UserEntity,
  mappedBy: 'roles',  // References the field in UserEntity
)
List<UserEntity>? users;

Constructors

ManyToMany({required Type targetEntity, JoinTable? joinTable, String? mappedBy, bool cascadeDelete = false, bool lazyLoad = true, bool createIndex = true})
const

Properties

cascadeDelete → bool
Whether to cascade delete operations
final
createIndex → bool
Index configuration for the junction table
final
hashCode → int
The hash code for this object.
no setterinherited
joinTable → JoinTable?
Junction table configuration (required on owning side)
final
lazyLoad → bool
Whether to lazy load the relationship
final
mappedBy → String?
Field name in the target entity that owns the relationship (for inverse side) If set, this is the inverse side and joinTable should be null
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
targetEntity → Type
The target entity type for this relationship
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited