many-to-many

NHibernate: Many-to-many relationship with field in the relationship table

若如初见. 提交于 2019-11-27 23:13:13
I'm scratching my head; I have a Car table and a Customer table that have a many-to-many relationship. In this relationship table I want to add a column that can tell me what kind of relationship this is; is the customer testdriving the car, do he want to buy the car, ect. What I want to end up with is a class Car object that holds a collection of Customers and the relationship information. I might be looking at this the wrong way so feel free to push me in the right direction. Make the relationship an entity: class CarRelation { Car Car {get; set; } RelationType Type {get; set;} } A pure many

Many to Many Relationships with Ember, ember-data and Rails

拥有回忆 提交于 2019-11-27 22:28:25
I am having an issue with trying to save many to many relationships in Ember.js using ember-data and rails. The association works fine on the ember side of things, however when I try to commit the transaction it will not include the list of new associations when submitting to rails. Any help would be much appreciated, I've been tearing out my hair trying to find an example application that does something this simple on github but I can't seem to find one. Here is a dumbed down version of my Ember code: App.Store = DS.Store.extend revision: 11 adapter: DS.RESTAdapter.create url: '/api' App

Many-to-many Users and groups, but groups have owners

北城以北 提交于 2019-11-27 22:26:50
问题 I'm having trouble trying to understand/wrap my brain around this. I'm trying to create a relationship that allows this: user can belong to many groups group can have many users a group has an owner which is a user the group ownership can be transferable I've got the many-to-many relationship set up, but I can't seem to understand how to set up the ownership functionality. here is what i have so far in my models: class Group < ActiveRecord::Base has_and_belongs_to_many :users attr_accessible

Hibernate @ManyToMany delete relation

笑着哭i 提交于 2019-11-27 21:26:44
问题 I have 2 entities: User and UsersList. @Entity @Table(name = "USERS") public class User { @Id @GeneratedValue @Column(name = "ID") private Long id; @ManyToMany(cascade = CascadeType.REMOVE, mappedBy = "users") private List<UsersList> usersLists = new ArrayList<UsersList>(); public List<UsersList> getUsersLists() { return usersLists; } public void setUsersLists(List<UsersList> usersLists) { this.usersLists = usersLists; } } and @Entity @Table(name = "USERS_LIST") public class UsersList { @Id

How to sort NULL values last using Eloquent in Laravel

本秂侑毒 提交于 2019-11-27 20:08:57
I've got a many to many relationship between my employees and groups table. I've created the pivot table, and all is working correctly with that. However, I've got a sortOrder column on my employees table that I use to determine the order in which they display. Employee with a value of 1 in the sortOrder column should be first, value of 2 should be second, so on. (Or backwards if sorted descending) The sortOrder column is a integer column that allows null values. I've set up my group model to sort the employees by the sort column, but I've run into a problem. The null values always are

Querying ManyToMany relationship with Hibernate Criteria

时间秒杀一切 提交于 2019-11-27 19:54:27
I'm not sure how to describe this problem, so I think an example is the best way to ask my question: I have two tables with a manyToMany relationship: DriversLicence <-> LicenceClass LicenceClass is things like "Car", "Motorbike", and "Medium Rigid". Using Hibernate Criteria, how can I find all licences that have both "Car" and "Motorbike" LicenceClasses? UPDATE 12/11/2008 I have discovered that this can easily be achieved by using a custom ResultTransformer. However the problem is that a result transformer only gets applied AFTER the query returns its results, it does not actually become part

ORM on Android SQLite and database scheme [closed]

谁说我不能喝 提交于 2019-11-27 18:47:23
I'm looking for a very simple ORM framework working on Android for SQLite. I've been testing ActiveAndroid but none of the example could ever build on Eclipse. By the way, how do guys implement a "many to many" relationship in SQLite for Android? How do you reflect the cascade regarding deletion of rows and guarantee the database integrity? I am the main author of ORMLite which has a Android backend which makes calls to the native Android OS database APIs to support its ORM functionality. We have a large number of Android developers that are using the framework successfully. See here for more

Django's ManyToMany Relationship with Additional Fields

Deadly 提交于 2019-11-27 18:16:31
I want to store some additional information in that, automatically created, ManyToMany join-table. How would I do that in Django? In my case I have two tables: "Employees" and "Projects". What I want to store is how much each of the employees receives per hour of work in each of the projects, since those values are not the same. So, how would I do that? What occurred to me was to, instead of the method "ManyToManyField", create explicitly a third class/table to store those new informations and to set its relationship with "Employees" and "Projects" using the "ForeignKey" method. I'm pretty

How do I work with many-to-many relations in Yii2

谁都会走 提交于 2019-11-27 17:50:43
For example in one-to-many due to documentation ( http://www.yiiframework.com/doc-2.0/guide-db-active-record.html#relational-data ) you can link two models in this way (one-many = company-zone) : $defaultZone = new Zone; $defaultZone->name = Zone::DEFAULT_ZONE; $company->link('zones', $defaultZone); But how it works for many-to-many relations when you have transit table like tbl_user_market(user_id, market_id) ? When using a junction table for many-to-many relations, you have to Define the relations Link the two models together In the User model define the following relation function: public

Many-to-many relationship: use associative table or delimited values in a column?

折月煮酒 提交于 2019-11-27 17:33:11
问题 Update 2009.04.24 The main point of my question is not developer confusion and what to do about it. The point is to understand when delimited values are the right solution. I've seen delimited data used in commercial product databases (Ektron lol). SQL Server even has an XML datatype, so that could be used for the same purpose as delimited fields. /end Update The application I'm designing has some many-to-many relationships. In the past, I've often used associative tables to represent these