many-to-many

Grails many-to-many associations and preventing cascade

六月ゝ 毕业季﹏ 提交于 2019-12-07 14:51:46
问题 So, we have a many-to-many relationship between Customer and Role, set up as: Customer { static hasMany = [roles: Role] } Role { static hasMany = [customer: Customer] static belongsTo = Customer } The Role object has only a name and a set of permissions. We don't want to cascade saves from Customer -> Role, as Role should only get modified directly. I added: static mapping = { roles cascade: 'none' } but, whenever, I create a customer, the role table gets updated as well. Nothing changes,

django-nonrel on Google App Engine - Implications of using ListField for ManyToMany

こ雲淡風輕ζ 提交于 2019-12-07 14:26:45
问题 I am working on a Google App Engine application and I am relatively new at this. I have built an app already in Django and have a model using a field type of ManyToMany. I am aware that django-nonrel does not support many-to-many field types of Django. So I am considering using ListField instead. Questions: - What is the implication of using ListField instead of ManyToMany? - I am aware that this means that Django's JOIN API cannot be used. But what does this mean for my app? - Am I going to

Copy datasets with n:m-relation

五迷三道 提交于 2019-12-07 13:51:22
问题 I would like to use the single SQL-statement insert into T (...) select ... from T where ... to copy a lot of datasets. My problem is that there are N:M-relationships from table T to other tables and these have to be copied too. How can I do this, if I do not know which original dataset belongs to which copied dataset? Let me demonstrate by example. Content of the database before: Table T : ID | COL1 | COL2 ----------------- 1 | A | B 2 | C | D N:M-table references table U from table T (table

Django - using Many-to-Many horizontal interface outside of admin

橙三吉。 提交于 2019-12-07 13:43:38
问题 I'm working in a form with a m2m field. I want that this field looks like the horizontal interface of the django admin site... ¿how i can do it? thanks... 回答1: You need to use the FilteredSelectMultiple widget from django.contrib.admin.widgets import FilteredSelectMultiple from django import forms from .models import Person class PersonForm(forms.ModelForm): some_field = forms.ModelMultipleChoiceField(Person.objects.all(), widget=FilteredSelectMultiple("Person", False, attrs={'rows':'2'}))

How to count association size with waterline/sails?

只谈情不闲聊 提交于 2019-12-07 13:33:20
问题 Using sails 0.10.5/waterline 0.10.15: I cannot find an answer to a simple question: how to count the elements of an association without using populate() (which would load all data). Let take a simple many2many relation with via: User: attributes: { following: { collection: 'user', via: 'follower', dominant: true }, follower: { collection: 'user', via: 'following' } Now I need the size of the collections. Currently I try User.findById(1).populateAll().exec(function(err, user) { // count of

manytomany relation not able to save mapped id in mapping table in play framework

牧云@^-^@ 提交于 2019-12-07 13:10:22
问题 I am using play2.2.1 and trying to create a ManyToMany relation between Jobads and JobCategory models. My Jobads.java package models; @Entity public class Jobads extends Model { @Id public Long id; @ManyToOne public Employers employer; @ManyToMany(cascade = CascadeType.ALL) @JoinTable(name = "jobads_jobcategories") public List<Jobcategories> jobcategory; @ManyToOne public Joblocations joblocations; @Required public String jobtype; @Required public String title; @Required public String text;

AttributeError with Django REST Framework and a ManyToMany relationship

断了今生、忘了曾经 提交于 2019-12-07 09:38:50
问题 Trying to access my json page I get this error! AttributeError at /project/api/1.json Got AttributeError when attempting to get a value for field `title` on serializer `TaskSerializer`. The serializer field might be named incorrectly and not match any attribute or key on the `RelatedManager` instance. Original exception text was: 'RelatedManager' object has no attribute 'title'. I have a Many to Many relationship with my models: class Project(models.Model): owner = models.ForeignKey('auth

Many-to-many in Cassandra 3

ぐ巨炮叔叔 提交于 2019-12-07 07:44:25
What's the right way to model many-to-many relationships in Cassandra (using 3.10 at the moment)? From what answers I was able to find, denormalization into two relationship tables is suggested (as in here, for example: Modeling many-to-many relations in Cassandra 2 with CQL3 ). But there are problems with that on deletes, and those answers are so sparse they do not mention any details on that. Suppose we have the following tables: CREATE TABLE foo ( key UUID PRIMARY KEY, content TEXT ) CREATE TABLE bar ( key UUID PRIMARY KEY, content TEXT ) CREATE TABLE foo_bar ( foo UUID, bar UUID, PRIMARY

Problem with Linq2Sql Many-to-Many relationship & Inserting new objects

馋奶兔 提交于 2019-12-07 07:25:18
问题 i'm trying to do a simple linq 2 sql many-to-many, insert some data, operation. here's the stock Northwind model representing a many to many: alt text http://www.iaingalloway.com/images/linq-detail.jpg Now what i'm trying to do is insert a new order and if the product doesn't exist, then insert that at the same time, within the same transaction. The error i'm getting is: System.Data.Linq.DuplicateKeyException: Cannot add an entity with a key that is already in use. So this is my (pseduo) code

How to remove redundant ID field in auto-generated ManyToMany table in Django?

别等时光非礼了梦想. 提交于 2019-12-07 06:30:38
问题 I have two classes in my models.py file: class Person: person_name = models.CharField(max_length = 50) class Course: course_name = models.CharField(max_length = 50) course_person = models.ManyToManyField(Person) In my modified example, one person is takes many courses and one course is taken by many people, hence ManyToMany. When I let Django auto-generate my table, I get an extra ID field. I want the autogenerated person_course manytomany table to consist of the two composite keys person_id