many-to-many

Update existing records in Hibernate ManyToMany Relation

烈酒焚心 提交于 2020-01-25 12:49:05
问题 In my database I have two tables Book and Label with ManyToMany relation between them. I have mapped them successfully in Hibernate using annotation of ManyToMany with CascadeALL . Now consider this scenario. When I add a new Book with labels list. The list of label contain existing and new labels both. When the book is saved in the database it creates duplicate entries of existing labels. [Means each time a new label will be created (even for existing labels)with different primary key,rather

New collection element overwrites the last element if it already exists when updating an entry

流过昼夜 提交于 2020-01-25 09:22:24
问题 so I have a Mission entity connected to an Option entity through a ManyToMany relationship. At the time of creating a new mission it is possible to add several options (this point is ok). Now when updating a mission, when I add a new option it overwrites the last option if it already exists otherwise it fits well. I want to be able to add as many options when modifying a mission without overwriting the last existing option. I post my code: Mission entity : /** * @var ArrayCollection $options

Laravel use sync on a many to many that includes a multiple extra fields

£可爱£侵袭症+ 提交于 2020-01-24 22:16:05
问题 I'm trying to use sync on a many to many that includes a status and a comment. I can sync the applications without status and comment just fine. NewUserAccount Model public function applications() { return $this->belongsToMany('App\Application', 'new_user_account_applications', 'new_user_id')->withPivot('application_comment', 'status'); } Application Model public function newUserAccounts() { return $this->belongsToMany('App\NewUserAccount', 'new_user_accounts_applications', 'new_user_id')-

Laravel use sync on a many to many that includes a multiple extra fields

青春壹個敷衍的年華 提交于 2020-01-24 22:15:49
问题 I'm trying to use sync on a many to many that includes a status and a comment. I can sync the applications without status and comment just fine. NewUserAccount Model public function applications() { return $this->belongsToMany('App\Application', 'new_user_account_applications', 'new_user_id')->withPivot('application_comment', 'status'); } Application Model public function newUserAccounts() { return $this->belongsToMany('App\NewUserAccount', 'new_user_accounts_applications', 'new_user_id')-

Symfony2 Doctrine many-to-many bidirectional save form type

◇◆丶佛笑我妖孽 提交于 2020-01-24 13:33:35
问题 I have a problem saving entities with forms. The relationship that gives me problems is many-to-many bidirectional. Agent Entity /** * @var \Doctrine\Common\Collections\ArrayCollection $agentLists * * @ORM\ManyToMany(targetEntity="AgentList", inversedBy="agents") * @ORM\JoinTable(name="agent_agentlist", * joinColumns={@ORM\JoinColumn(name="agent_id", referencedColumnName="id")}, * inverseJoinColumns={@ORM\JoinColumn(name="agentlist_id", referencedColumnName="id")} * ) */ protected $agentLists

Entity Framework - Eager load two many-to-many relationships

不羁的心 提交于 2020-01-24 04:20:05
问题 Sorry for this being so long, but at least I think I got all info to be able to understand and maybe help? I would like to load data from my database using eager loading. The data is set up in five tables, setting up two Levels of m:n relations. So there are three tables containing data (ordered in a way of hierarchy top to bottom): CREATE TABLE [dbo].[relations]( [relation_id] [bigint] NOT NULL ) CREATE TABLE [dbo].[ways]( [way_id] [bigint] NOT NULL ) CREATE TABLE [dbo].[nodes]( [node_id]

Django filter by many to many with exact same query

允我心安 提交于 2020-01-23 17:35:13
问题 Is there any way in django to filter objects with many to many relation by query set or ids list. Get query with exactly same values in many to many. model class Parent(models.Model): name = models.CharField(max_length=1000) children = models.ManyToManyField(Child, blank=True) views def filter_parents(request): children = Child.objects.filter(id__in=[1,2,3]) parents = Parent.objects.filter(child=child) return parents expected: I am looking for filtered parents with exact same children in many

many-to-many relationship in GraphQL

我的梦境 提交于 2020-01-23 06:38:51
问题 Let's say I have two Arrays of Objects: let movies = [ { id: '1', title: 'Erin Brockovich'}, { id: '2', title: 'A Good Year'}, { id: '3', title: 'A Beautiful Mind'}, { id: '4', title: 'Gladiator'} ]; let actors = [ { id: 'a', name: 'Julia Roberts'}, { id: 'b', name: 'Albert Finney'}, { id: 'c', name: 'Russell Crowe'} ]; I want to create many-to-many relationship betweet them. For the begining in Vanilla JavaScript , eventually in GraphQL schema. In JavaScript I did something like this: let

Grails: Many-to-Many without hasMany/belongsTo - instead using native 3NF - Searching full text

假如想象 提交于 2020-01-23 02:50:10
问题 I am implementing a many-to-many mapping in grails using 3NF, Not using the hasMany or belongsTo property. Taken from this article it shows and explains quite a lot about its advantages. Article: http://burtbeckwith.com/blog/?p=169 Presentation notes: http://burtbeckwith.com/blog/files/169/gorm%20grails%20meetup%20presentation.pdf I'm trying to make a Tag system onto questions, kind of like this(stackoverflow :)) I can save the Question and the Tags, then save the association with them, but

NHibernate many-to-many assocations making both ends as a parent by using a relationship entity in the Domain Model

泄露秘密 提交于 2020-01-22 16:56:09
问题 Entities: Team <-> TeamEmployee <-> Employee Requirements: A Team and an Employee can exist without its counterpart. In the Team-TeamEmployee relation the Team is responsible (parent) [using later a TeamRepository]. In the Employee-TeamEmployee relation the Employee is responsible (parent) [using later an EmployeeRepository]. Duplicates are not allowed. Deleting a Team deletes all Employees in the Team, if the Employee is not in another Team. Deleting an Employee deletes only a Team, if the