many-to-many

NHibernate many-to-many relationship does not update join-table

I'm having trouble saving a many-to-many relationship with nhibernate. I searched and looked at almost every same question in SO and google but nothing works. The single classes are update correctly but nothing is inserted in the join-table. I have 2 classes: Event and Category. The mapping is this (I updated the two mapping and added ...

How To Query Many-to-Many Table (one table's values becomes column headers)

Given this table structure, I want to flatten out the many-to-many relationships and make the values in the Name field of one table into column headers and the quantities from the same table into column values. The current idea which will work is to put the values into a Dictionary (hashtable) and represent this data in code but im wond...

Entity Framework 4 Self Many-To-Many with Properties

UPDATE: Solved by myself. Tricky but works. If you know a better solution, feel free to correct me. DESIGNER: CODE: Product product1 = new Product{key = "Product 1"}; sd.AddToProducts(product1); Product product2 = new Product{key = "Product 2"}; sd.AddToProducts(product2); Product product3 = new Product{key = "Product ...

How to dynamically order many-to-many relationship with JPA or HQL?

I have a mapping like this: @ManyToMany(cascade = CascadeType.PERSIST) @JoinTable( name="product_product_catalog", joinColumns={@JoinColumn(name="product_catalog", referencedColumnName="product_catalog")}, inverseJoinColumns={@JoinColumn(name="product", referencedColumnName="product")}) public...

insert with many to many relationship

hi, i have 2 object: user, group that have a relationship many to many i want create a user and associate some groups to it. How can i do it? thanks I've tried with this. but it's wrong: user = new User(); List<int> gruppi = new List<int>() {1,2}; utente.Group =db.Group.Where(p => gruppi.Contains(p.GruppoID) ...

NHibernate inteceptor not called for changes in many-to-many set/list

I have an application that uses NHibrenate and I'm using an interceptor based solution for logging/auditing. Basically I have a class inheriting from EmptyInterceptor and overriding OnFlushDirty, OnSave and OnDelete. Everything works perfectly - except - when I add or remove from a set or list that is mapped using many-to-many without ...

what else to do to establish many-to-many associations in Ruby on Rails? thanks!

Hi, I have two classes and I want to establish a many-to-many assications, here is the code: class Category < ActiveRecord::Base has_and_belongs_to_many :events has_and_belongs_to_many :tips end class Tip < ActiveRecord::Base has_and_belongs_to_many :categories However, I kept getting the following errors and I would apprecia...

Implementing a 'many-to-many' database

Greetings, stack*overflow* In my database, I already have one table, 'contacts' that contains records of individual people. I also have several other tables in my database which represent "skill sets" that contain records denoting a particular skill. 1) Am I correct in plotting this as a "many-to-many" relationship? (each contact can h...

Many-to-many mapping with LINQ

I would like to perform LINQ to SQL mapping in C#, in a many-to-many relationship, but where data is not mandatory. To be clear: I have a news site/blog, and there's a table called Posts. A blog can relate to many categories at once, so there is a table called CategoriesPosts that links with foreign keys with the Posts table and with Cat...

Saving a Django form with a Many2Many field with through table

So I have this model with multiple Many2Many relationship. 2 of those (EventCategorizing and EventLocation are through tables/intermediary models) class Event(models.Model): """ Event information for Way-finding and Navigator application""" categories = models.ManyToManyField('EventCategorizing', null=True, blank=True, help_text="categ...

iPhone: Core Data save Class object

I have an entity in core data called Location. Inside this I have a few fields, such as date. But, I would also like to save a class object in it that I created called Annotation. What type of attribute would I use for this, since it is a custom class object that I created? Location (object) |__ Date |__ Annotation (MKAnnotation prot...

Updating extra attributes in a has_many, :through relationship using Rails

I've managed to set up a many-to-many relationship between the following models Characters Skills PlayerSkills PlayerSkills, right now, has an attribute that Skills don't normally have: a level. The models look something like this (edited for conciseness): class PlayerSkill < ActiveRecord::Base belongs_to :character belongs_to ...

Rails has-and-belongs-to-many form question

Sorry for the semi-generic title, but I'm still pretty new at rails and couldn't think of a succinct way to put the question. I have a basic habtm model setup: a Project has many Resources and a Resource can have many Projects. I have the database and models setup properly, and can do everything I need to via the console, but I'm having...

NHibernate ManyToMany Relationship Cascading AllDeleteOrphan StackOverflowException

I have two objects that have a ManyToMany relationship with one another through a mapping table. Though, when I try to save it, I get a stack overflow exception. The following is the code for the mappings: //EventMapping.cs HasManyToMany(x => x.Performers).Table("EventPerformer").Inverse().Cascade.AllDeleteOrphan().LazyLoad().ParentKeyC...

Multiple many-to-many JOINs in a single mysql query without Cartesian Product

At the moment I can get the results I need with two seperate SELECT statements SELECT COUNT(rl.refBiblioID) FROM biblioList bl LEFT JOIN refList rl ON bl.biblioID = rl.biblioID GROUP BY bl.biblioID SELECT GROUP_CONCAT( CONCAT_WS( ':', al.lastName, al.firstName ) ORDER BY al.authorID ) FROM biblioList bl LEFT JOIN biblio_author b...

django manytomany filter question

Hay, I have a Model which looks like this class Person(models.Model): name = models.CharField(blank=False, max_length=100) friends = models.ManyToManyField('self', blank=True, null=True) How would i filter out a Person how has friends? I tried people_with_friends = Person.objects.filter(friends=True) but had no luck. Any...

Rails find_or_create by more than one attribute?

There is a handy dynamic attribute in active-record called find_or_create_by: Model.find_or_create_by_<attribute>(:<attribute> => "") But what if I need to find_or_create by more than one attribute? Say I have a model to handle a M:M relationship between Group and Member called GroupMember. I could have many instances where member_id ...

many-to-many join table discriminator?

Hi all, I'm trying to link a Communication object I've created that has 2 properties "SuccessRecipientList" and "FailRecipientList" to a Users object, via joining table "Communication_Recipients". I'd like to do this using a discriminator on the joining table instead of creating an actual domain object for it (Using the HasFailed Bit co...

Database design help. Many to many creates an association table, correct?

I'm designing a very simple database for my application and it's configured like this: Employee Carnet Name LastName Area Name Document ID Employee (FK) Project (FK) Project ID Company (FK) Title Company Name CEO (FK) NIT Person Carnet Name Lastname Now the gist of this question is, an Area can have many Document; and a Document ...

How to add a product in a list without loading all the database ?

Hi, In my domain model I have a bi-directionnel association between the ProductList entity and the Product entity with the following hibernate mapping : @Entity @Indexed @Table(name="product_list") public class ProductList { @ManyToMany(fetch=FetchType.LAZY) @JoinTable(name = "list_items", inverseJoinColumns = { @JoinColumn(na...