many-to-many

Many to many field not shown in object while using signals to detect save operation in django

丶灬走出姿态 提交于 2019-12-13 13:17:16
问题 This is a follow up question to : Cant get post_save to work in Django My models are : class Car(models.Model): name = models.CharField(max_length=50) ... some other attributes of Car ... class Person(models.Model): car = models.ManyToManyField(Car) name = models.CharField(max_lenght=100) ... Some other attributes of Person ... class License(models.Model): person = models.ForeignKey(Person) ... Other attributes of License ... Signal handler: def signal_handler(sender, **kwargs): print 'Person

Problem with SaveChanges() Entity Framework 4.1

半世苍凉 提交于 2019-12-13 12:40:07
问题 I am having problem with saving the changes to database. I am updating the model A in my controller, however when I save the changes using SaveChanges() I end up having a duplicated item in database for B. After the UpdateModel() is called I inspected the Bs property and it was as I expected however right after the SaveChanges() is called if I inspect the Bs property I will see that the Id is completely different (new Id and new entry). My class is similar to this: public class A {

How to select List<B> from List<A> where A and B are many-to-many related using Entity Framework?

雨燕双飞 提交于 2019-12-13 07:43:04
问题 I have 2 models, say Product and Category : public class Category { public Category() { } // primary key public long Id { get; set; } // other properties are omitted public virtual IList<Product> Products { get; set; } } public class Product { public Product() { } // primary key public long Id { get; set; } // title/name public string Title { get; set; } public virtual IList<Category> Categories { get; set; } } As you can see there is a many-to-many relationship between these models; each

Hibernate many to many relationship with extras columns

怎甘沉沦 提交于 2019-12-13 06:59:47
问题 I have an issue with many to many relationship mapping with JAVA and HIBERNATE I have table purchase >------------------< product, so we get another table purchaseProduct, here is the DDL CREATE TABLE product ( idProduct serial primary key, nameAr varchar(50), nameFr varchar(50), preference varchar(50), qtyStart double PRECISION, qtyInHand double PRECISION, sellPrice double PRECISION , purchasePrice double PRECISION, taxe double PRECISION ); CREATE TABLE purchase ( idPurchase serial primary

Cascade Deleting Many-To-Many relationship in entity framework

前提是你 提交于 2019-12-13 06:50:00
问题 I have three tables in my database: Articles: ArticleID (PK) Tags: TagiID (PK) ArticleTagMapping: ArticleID(FK,PK), TagID(FK,PK) ArticleTagMapping has a composite primary key. This resulted in a many-to-many relationship in my entity model as expected. I have set both the foreign key relationships to cascade on delete in database. I am trying to delete Article via C# code. This errors out... var ArticleToDelete = context.Articles.SingleOrDefault(x => x.ArticleID == ArticleID); context

Hibernate and Spring: value of many-to-many not inserted into generated table

强颜欢笑 提交于 2019-12-13 06:39:16
问题 I've got a bit of experience with spring, but I'm completely new to Hibernate, especially in combination with Spring: I want to have a Many-to-Many relationship between two tables (author, publication). The table is generated, but nothing is inserted... Part of Author.java: @ManyToMany(cascade = {CascadeType.ALL}) @JoinTable(name = "writes", joinColumns = {@JoinColumn(name = "authorId")}, inverseJoinColumns = {@JoinColumn(name = "publicationId")}) private Set<Publication> publications = new

NHibernate Many to many mapping with additional columns in the mapping table

梦想与她 提交于 2019-12-13 06:32:23
问题 There are two tables Person and Address. I have a mapping table PersonAddressMap which contains an additional column IsCurrent other than the two foreign keys (no explicit primary key column). I have created three mapping classes one each for Person, Address and PersonAddressMap. I need to access all the Addresses of a Person and also access all the Persons who have a particular address from Address, so I have a one-to-many to PersonAddressMap in both the Person and Address class. Now the

Best way to implement many-to-many lookup table with user-entered data

风流意气都作罢 提交于 2019-12-13 06:29:41
问题 Say I want users to pick one or more contact methods (email, phone, fax, other, etc). And if they choose other, then they can enter a single contact method of their own. What's the best way to store this in a database? I see three possibilities: Use a set datatype column, plus a single "other_contact" varchar column to store the optional user-entered value. Use many-to-many, and a user-entered column. So there would be a user table, a contact_method table, and a user_contact_method table that

Array returning null value, many to many. laravel

孤者浪人 提交于 2019-12-13 06:14:42
问题 I'm trying to retrieve data from many to many relationship.I have two tables : companies: [cid,name,origin] vehicle_types: [id, type] their pivot table: companies_vehicle_types: companies_id,vehicle_types_id Relationship defined: In Companies: class companies extends Model { // protected $fillable = ['name','origin']; protected $primaryKey = 'cid'; public function vehicles(){ return $this->hasOne('App\vehicles'); } public function vehicle_types(){ return $this->belongsToMany('App\vehicle

Django CreateView With ManyToManyField

青春壹個敷衍的年華 提交于 2019-12-13 05:36:06
问题 I am trying to use a Django CreateView and ultimately update a ManyToMany Field if the user selects a certain value. I can get the form to validate, but ultimately it isn't updating the manytomanyfield in the database. Not sure what I'm doing wrong. I have referenced this similar SO issue, Django ManyToMany CreateView Fields In Both Tables but it was of no help to me. I recently found this link...Django CreateView: How to perform action upon save and it seems very close to the issue I'm