many-to-many

How to delete all associations in a Hibernate JoinTable at once?

We have the following two entities with many-to-many association: @Entity public class Role { ... @ManyToMany @JoinTable( name = "user_has_role", joinColumns = { @JoinColumn( name = "role_fk" ) }, inverseJoinColumns = { @JoinColumn( name = "user_fk" ) } ) private Set<User> userCollection; ... } and @Entity publi...

LINQ many to many hell - querying where CONTAINS ALL

I have a many to many relationship as follows: Products ProductID Description ProductFeatures ProductFeatureID ProductID FeatureID Features FeatureID Description Any Product can have many Features. I then come along with an iQueryable called "SearchFeatures" which contains two particular Feature objects that I want to search on. I ...

How do you submit objects with a many to many relationship using the Entities Framwork?

This is a follow up question to this question I asked yesterday. I've tracked down exactly the issue I think is causing me grief and I think I can explain the situation with more clarity. I just can't seem to figure out how to write objects with a many to many relationship to a SQL database using the Entities Framework in a C# ASP.NET M...

Hibernate: Shallow copying of ManyToMany associations without initialization of target entities

There are two entities: @Entity class A { @ManyToMany List<B> bs; } @Entity class B {} I now want to duplicate (clone) an instance of class A. Is there any way with Hibernate to make a shallow copy of the persistent collection bs without having to completely initialize all Bs? In SQL it would be quite easy because you would just ...

[Hibernate.Envers] @ManyToMany: REVTYPE is only ADD

Hi, i have the two classes Person and Attribut, in short: @Entity @Indexed @Table(name="persons") public class Person { private int id; private List<Attribute> attributes; @Id @DocumentId @GeneratedValue @Column(name="person_id") public int getId() { return id; } @ManyToMany @JoinTable( name="attribute_all...

Doctrine Many-to-Many relationship between three tables

Hello, I have three tables: note, user and tag. Following is the diagram of the relationship between those tables: User can have many Notes and Tags, Note can have many Users and Tags, Tag can have many Users and many Notes. I have no problem setting many-to-many relationship between two tables, but can't manage to relate three table...

How to implement mongoid many-to-many associations?

I want to port a social network to Mongoid. The join table between friends is very large. Is there any way for Mongoid to handle this join table out of the box? I've seen a couple of in-model roll-your-own solutions to it, but nothing the looks efficient. Is there a way to handle this? Or is this a case where I shouldn't be using Mo...

Many to many tables in the ENtity Framework

Greetings, I'm having a hard time with the ADO.NET Entity framework. I want to do a relation between 2 existing items, in a Many to Many table. Example: create table A(key int, value varchar(10)); create table B(key int, value varchar(10)); create table A_B(keyA int, keyB int);-- those are FK.. Now I want to do the relation between...

jpa deleting manytomany links

I have a table of events and i want to make groups of them. that is the easy easy // this cascade group still removes the join table but not the products table @ManyToMany(targetEntity=Product.class,fetch = FetchType.EAGER, cascade = {CascadeType.PERSIST, CascadeType.REFRESH,CascadeType.MERGE}) @JoinTable(name = "lcw_group_prod...

Fluent nHibernate using AsList() returns null objects depending on the SortOrder

In a project I am working on, we are using tabs. These tabs have content. Multiple content objects can be on a tab. So we could have a 'car' tab, and that car tab may display a sedan content object, a suv content object and a truck content object. The user could also specify that it contains more or less of these objects and order them h...

How do I access the properties of a many-to-many "through" table from a django template?

From the Django documentation... When you're only dealing with simple many-to-many relationships such as mixing and matching pizzas and toppings, a standard ManyToManyField is all you need. However, sometimes you may need to associate data with the relationship between two models. For example, consider the case of an application...

How can I build/create a many-to-many association in factory_girl?

I have a Person model that has a many-to-many relationship with an Email model and I want to create a factory that lets me generate a first and last name for the person (this is already done) and create an email address that is based off of that person's name. Here is what I have for create a person's name: Factory.sequence :first_name ...

Many-to-many relationship on the same entity without additional join table columns

I have an entity that has many-to-many association to itself. If I needed some additional properties (like asked here) the answer would be to use a new intermediate entity. But without them is it bad practice to use direct many-to-many association to the entity itself? ...

Subsonic 3.0 How to retrieve all users that belong to specific group in a many to many relationship

Lets say I have a many-to-many relationship: Group table User table group_user table which is a many to many table Given the group name I would like to find all the users that belong to this group. How can I do this with subsonic 3.0? IQueryable<group_user> groupUser= group_user.All(); Is it possible from groupUser to get all use...

ActiveRecord siblings in many-to-many relationship

I have this working to a degree, but I am looking for some input on how to query for the siblings in a one to many relationship to see if there is a more elegant way of accomplishing this. Consider the following classes class Post < ActiveRecord::Base has_many :post_categories has_many :categories, :through => :post_categories en...

Correct way to insert Many-to-Many objects in Django?

Hi, I was working on a many-to-many model with extra fields and i saw the documentation for extra fields in many to many relations on their exemple, to create a membership they use m2 = Membership.objects.create(person=paul, group=beatles,date_joined=date(1960, 8, 1), invite_reason= "Wanted to form a band.") but that means that they...

One more column into join table using hibernate many-to-many

Hi! How i can map structure like this into class A{ Map<SomeEnum, B> foo; } where key in foo is representation of role in a_ has _b ? Thanks! ...

Hibernate collections within collections

I have a Hibernate entity named Menu which has a collection of Groups, each group in turn has a collection of MenuItems. So as an example, a menu can be for a restaurant, groups can be Lunch and Dinner and the menuItems within these can be Pasta, Burger, Salad. The problem I'm having is that once i have created the menu and saved it ...

EF4 many-to-many navigation property is empty

Using the model-first approach, I made 2 entities: Project and User. A project has multiple Users (involved in the project), and a User has (access to) multiple Projects, so following along with the Tekpub video, I made the many-to-many navigation property using the primary keys of the two entities. I made some test data, and the data ...

Empty Join Table resulting from JPA ManyToMany

I have an application in which I am trying to implement ManyToMany relation between 2 entities using Hibernate as my JPA provider. The example I am trying is an uni-directional one, wherein a Camera can have multiple Lenses and Lense can fit into multiple Cameras. Following is my entity class...(Just pasting the relevant part of it) C...