many-to-many

What is the correct way to define many-to-many relationships in NHibernate to allow deletes but avoiding duplicate records

孤街醉人 提交于 2019-12-17 17:54:11
问题 I've been fighting with an NHibernate set-up for a few days now and just can't figure out the correct way to set out my mapping so it works like I'd expect it to. There's a bit of code to go through before I get to the problems, so apologies in advance for the extra reading. The setup is pretty simple at the moment, with just these tables: Category CategoryId Name Item ItemId Name ItemCategory ItemId CategoryId An item can be in many categories and each category can have many items (simple

JPA EventListener method not called on change to many-to-many collection?

自闭症网瘾萝莉.ら 提交于 2019-12-17 16:53:08
问题 I am using JPA with Hibernate as the implementation in my Spring webapp. I use EntityListener s for auditing (Spring-data) and other notification purposes. In general it works fine. However, when changes are made to a many-to-many collection/relationship, without any other change to any field of the entities themselves , the @PostUpdate event of the EventListener s are not fired. To give a concrete example : I have a User and a Role entities, with a many-to-many relationship between them,

Entity Framework Database First many-to-many

ε祈祈猫儿з 提交于 2019-12-17 16:40:42
问题 I've created an Entity Framework model from the database. I have many-to-many relationship: User - UserRole - Role . EF created UserRole entity and UserRoles navigation property in the User entity and in Role entity, but I'd rather have Roles in User and Users in Role . Is that possible to be designed through the Model Designer? How can I configure manually many-to-many relationship with a table in the middle? 回答1: EF normally creates the intermediate model, if the UserRole table comprises of

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

孤街醉人 提交于 2019-12-17 16:29:20
问题 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. 回答1: Make the

ORM on Android SQLite and database scheme [closed]

橙三吉。 提交于 2019-12-17 15:35:58
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . I'm looking for a very simple ORM framework working on Android for SQLite. I've been testing ActiveAndroid but none of the example

How can I achieve a self-referencing many-to-many relationship on the SQLAlchemy ORM back referencing to the same attribute?

痞子三分冷 提交于 2019-12-17 15:34:48
问题 I'm trying to implement a self-referential many-to-many relationship using declarative on SQLAlchemy. The relationship represents friendship between two users. Online I've found (both in the documentation and Google) how to make a self-referential m2m relationship where somehow the roles are differentiated. This means that in this m2m relationships UserA is, for example, UserB's boss, so he lists him under a 'subordinates' attribute or what have you. In the same way UserB lists UserA under

getting the value of an extra pivot table column laravel

∥☆過路亽.° 提交于 2019-12-17 10:20:13
问题 I have a phone_models, phone_problems, and a phone_model_phone_problem pivot table. The pivot table has an extra column 'price'. PhoneModel: class PhoneModel extends \Eloquent { public function problems() { return $this->belongsToMany('RL\Phones\Entities\PhoneProblem')->withPivot('price'); } } PhoneProblem: class PhoneProblem extends \Eloquent { public function models() { return $this->belongsToMany('PhoneModel')->withPivot('price'); } } What I'm trying to do is get the price of a specific

Mysql join query for multiple “tags” (many-to-many relationship) that matches ALL tags?

别等时光非礼了梦想. 提交于 2019-12-17 10:17:57
问题 I am trying to query for Objects that match ALL of a given set of Tags. Basically I want users to be able to add on more and more Tags to filter or "narrow down" their search results, kind of like newegg.com does. My table structure is a table of Objects, a table of Tags, and a MANY:MANY relation table ObjectsTags. So I have a JOIN query like so: SELECT * FROM Objects LEFT OUTER JOIN ObjectsTags ON (Objects.id=ObjectsTags.object_id) LEFT OUTER JOIN Tags ON (Tags.id=ObjectsTags.tag_id) I tried

MongoDB Many-to-Many Association

╄→尐↘猪︶ㄣ 提交于 2019-12-17 03:22:31
问题 How would you do a many-to-many association with MongoDB? For example; let's say you have a Users table and a Roles table. Users have many roles, and roles have many users. In SQL land you would create a UserRoles table. Users: Id Name Roles: Id Name UserRoles: UserId RoleId How is same sort of relationship handled in MongoDB? 回答1: Depending on your query needs you can put everything in the user document: {name:"Joe" ,roles:["Admin","User","Engineer"] } To get all the Engineers, use: db

SQLAlchemy many to many relationship & Association object

孤街浪徒 提交于 2019-12-14 04:10:27
问题 I am having trouble configuring a simple relationship. I managed to get it working reasonably well with the use of a simple association table but I wanted extra 'meta' fields so I am looking into using an association object pattern. (Yes I am a DB novice) from flask.ext.sqlalchemy import SQLAlchemy from flask import Flask import os import re import datetime app = Flask(__name__) basedir = os.path.abspath(os.path.dirname(__file__)) app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path