many-to-many

JPA: Circular relations: diff between EclipseLink and Hiberante

≡放荡痞女 提交于 2020-02-23 06:31:06
问题 We have an entity Role which could be either users or groups. In the groups we have set permissions. Therefore a user belongs to a group. Additionally groups can belong to other groups, i.e. one could make a hierarchy of permissions. The idea is to store the relations from e.g. user -> group into a separate db table role_ref . @Table(name = "role__parent") @IdClass(RoleAssociationKey.class) @Data public class RoleAssociation implements Serializable { @Id @JoinColumn(name = "has_parent_role_id

What other queries can I do with this many to many joining table?

橙三吉。 提交于 2020-02-08 09:47:25
问题 so..I am learning many to many relationship in mysql. I created the following tables. create table post( id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, title varchar(40), content text, created int(11) default 0 ); create table category( id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, name VARCHAR(35) ); create table author( id int not null primary key auto_increment, name varchar(20) ); create table postcategory( id int not null primary key auto_increment, post_id int, category_id int, foreign key

Django Queryset Filter on an empty list

拟墨画扇 提交于 2020-02-04 19:39:51
问题 I'm building dynamic filters which I pass by GET to a queryset filter: for k, v in request.GET.iteritems(): kwargs[str(k)] = str(v) students = models.Student.objects.filter( **kwargs ) and it's working for almost all the queries I'm throwing at it. However, I have a related model with a manytomany relationship, Group. So a student can be a member of many groups. I'm able to filter students who belong to a given group using the following: ' groups__in='+str(group.id) e.g. - //example.com

LINQ many-to-many relationships: Solution?

ぃ、小莉子 提交于 2020-02-03 05:17:32
问题 LINQ so far has been remarkably elegant, but to perform basic m2m queries it offers no solution I can imediately see. What's worse is that while it works for any other table relationship, LINQ is not giving me an association in the class structure for my m2m table. So I can do things like artwork.artists.where(...) //or artist.Artworks.add(artwork) but I can't do artwork.artowrks_subjects.tagSubjects.where(...) //or tagSubject.artworks_subjects.add(artwork) alt text http://img299.imageshack

Is Hibernate ManyToMany self-join possible for non-key columns? getting mappingException

耗尽温柔 提交于 2020-02-02 10:08:12
问题 I am having following problem. I have a user entity that has a many to many relationship with other user entities. Hence I want to make a self-join with manytomany annotation. This relation is based on already existing table that is used across the system so I cannot make changes to the DB at all. So we have 2 tables User(Id, ShortName) and UserLink(ParentId, ChildId). The annotation of ID is assigned to ShortName, but the actual keys in both User and UserLink are ID from User and ParentId

Is Hibernate ManyToMany self-join possible for non-key columns? getting mappingException

淺唱寂寞╮ 提交于 2020-02-02 10:08:05
问题 I am having following problem. I have a user entity that has a many to many relationship with other user entities. Hence I want to make a self-join with manytomany annotation. This relation is based on already existing table that is used across the system so I cannot make changes to the DB at all. So we have 2 tables User(Id, ShortName) and UserLink(ParentId, ChildId). The annotation of ID is assigned to ShortName, but the actual keys in both User and UserLink are ID from User and ParentId

play framework 2: saving many to many

纵饮孤独 提交于 2020-01-31 18:18:05
问题 I'm new to Play Framework 2. I have 2 models: Book and Author, one book can have many authors, so I think its many to many. Here are my models: @Entity public class Book extends Model { @Id public Long id; @Constraints.Required public String title; @Constraints.Required @ManyToMany(cascade=CascadeType.ALL,mappedBy="books") public Set<Author> authors = new HashSet<Author>(); public static Model.Finder<Long,Book> find = new Model.Finder<Long,Book>(Long.class, Book.class); public static Page

Core data: Managing employee contracts in a many-to-many relationship?

此生再无相见时 提交于 2020-01-30 03:55:30
问题 I am mapping an idea for a relationship using Core Data. I have an Employer entity who has a many-to-many relationship with Employees . Basically, an employee can work for multiple employers, and an employer can have multiple employees. The problem I'm facing is, I'm not sure how to manage the contracts between employees and employers. As an employee can work for either 1 or many employers, they would naturally have a contract for each employer they work for (complete with salary, duration)

Logical or of Django many to many queries returns duplicate results

99封情书 提交于 2020-01-29 03:36:30
问题 I have models with many to many relationships like this: class Contact(models.Model): name = models.TextField() address = models.TextField() class Mail(models.Model): to = models.ManyToManyField(Contact, related_name='received_mails') cc = models.ManyToManyField(Contact, related_name='cced_mails') I want to obtain the set of contacts that are in either the to field or the cc field for a given email. Let's try: >>> Contact.objects.filter(received_mails__id=111) [<Contact: fred@foo.com>] >>>

Update existing records in Hibernate ManyToMany Relation

陌路散爱 提交于 2020-01-25 12:49:26
问题 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