Questions tagged [many-to-many]

A type of relationship between entities of types A and B which associates a list of entities of type B to an entity of type A and vice versa. Types A and B may be the same type.

A type of relationship between entities of types A and B which associates a list of entities of type B to an entity of type A and vice versa. Types A and B may be the same type.

8687 questions
2
votes
1 answer

How to insert data into many to many table in Laravel 5.7

I am new in Laravel I have two tables Student , Courses . Their relation is many to many, when I try to add new student and assign the student to many courses that already exist , it add new student correctly but can`t add to table student_course…
2
votes
2 answers

EF Core Many-to-Many hide pivot

I'm still learning .NET Core 2.1. I'm working on a Web API where I use EF Core. Currently I'm working on a many to many relationship between Users and Roles. I wanted to hide the pivot, but it ended out being a bit hacky i think, so I wanted to see…
Algorythm
  • 130
  • 9
2
votes
4 answers

Django How To Query ManyToMany Relationship Where All Objects Match

I have the following models: ## Tags for issues class issueTags(models.Model): name = models.CharField(max_length=400) class issues(models.Model): tags = models.ManyToManyField(issueTags,blank = True) In my view I get an array from some…
Rob
  • 703
  • 1
  • 7
  • 18
2
votes
1 answer

JSF selectCheckboxMenu & Hibernate @ManyToMany remove values

First of all some details von the used software: I'm working with primefaces 6.2.11 on Wildfly 14.0.1Final with JSF 2.3. Problemdescription: I have two entities (User & Group) related many2many and I want to remove a relation on the side which is…
Sebastian S.
  • 493
  • 1
  • 5
  • 17
2
votes
2 answers

Laravel (5.7) Eloquent Many to Many with query on both sides

Say I have a users, roles, and a pivot table. I have belongsToMany set up for both Role and User. User Model:
Menghour Say
  • 33
  • 1
  • 6
2
votes
0 answers

Spring Data JPA Specification with MayToMany relation

I'm trying to use Specification to build a search criteria with Spring Data JPA. I have 2 entities @Entity public class User { @Id private Long userId; @ManyToMany @JoinColumn(name="locationId") @JsonIgnore private…
MarioC
  • 2,934
  • 15
  • 59
  • 111
2
votes
1 answer

ManyToMany on itself with AssociationTable with EmbeddedId - Spring-Data-Jpa

I have some trouble with Hibernate during a ManyToMany association :/ I want to have a user with his contacts. The association Table is used to have a creation_date of the association and her status (ex. Active, inactive, etc...) Hibernate version…
Dalianeth
  • 23
  • 1
  • 4
2
votes
1 answer

Sqlalchemy query based on excluding items in a relationship

I have a table of PartyOrganiser(s), and a table of one's Contact(s) and a table of one's organised Party(s). PartyOrganiser to Party is one-to-many. PartyOrganiser to Contact is one-to-many. Party to Contact is many-to-many, with an association…
Attack68
  • 4,437
  • 1
  • 20
  • 40
2
votes
5 answers

How to retrieve all related models in a many to many relationship Laravel?

I am trying to retrieve all related models with another model through an intermediary table but can't figure out how. The Laravel docs say you can do something like this: $roles = App\User::find(1)->roles()->orderBy('name')->get(); But when I try…
develpr
  • 1,296
  • 4
  • 22
  • 42
2
votes
1 answer

JPA Save non owning side of ManyToMany Relation

I have a question about how to save M2M relations. One side must be always the owning side. In our scenario we have a entity "Role" and a entity "User". A Role can have many users and users can be assigned to different roles. The "Role" entity is…
user652158
2
votes
1 answer

How can I write a SQLAlchemy query that will return all descendants of a node in a graph?

I am working on an application where my database objects often have multiple parents and multiple children, and would like to create a SQLAlchemy query that will return all descendants of an object. Realizing that I am basically trying to store a…
kleboeuf
  • 116
  • 7
2
votes
2 answers

MySQL: many to many relationship with multiple AND condition

I have a many-to-many relationship in my MySQL-database with three tables like this: TABLE item, TABLE relation (storing only ids of items and tags), TABLE tag Each item can have multiple tags also tags can be related to multiple items, e.g. the…
Select0r
  • 12,234
  • 11
  • 45
  • 68
2
votes
1 answer

Laravel 5.6: Many-to-many relationship returns empty object

I'm setting up a many-to-many relationship in Laravel 5.6 models but, since I'm not following Laravel's naming convention, I'm surely making a mistake on table/foreign keys name that makes it not working. My tables related to the blog section all…
Brigo
  • 1,086
  • 1
  • 12
  • 36
2
votes
1 answer

Laravel Many to many relationship with custom key relation

Before you mark this question as duplicate, please see the details :) I have a problem related to many to many relationship with custom columns linking I have following tables Employees -Id -brink_id <----- This is third party id I am saving of…
Awais Qarni
  • 17,492
  • 24
  • 75
  • 137
2
votes
1 answer

Laravel: How to use where clause in many to many relation

How i can use where clause in many to many relation ship Table: Users id - name - email Table: Shiftings id - name Table: shifting_user id - user_id - shifting_id User Model: public function shiftings() { return…
1 2 3
99
100