many-to-many

Form to create entries in many-to-many relationship with nested models

℡╲_俬逩灬. 提交于 2019-12-13 05:25:15
问题 My application consists of these five models: A supermarket can have different categories of products and the products in these categories can be produced by several brands . Now I want to have one (or two) Selection -field(s) in my supermarket -form in which I can select one element in Category with its name appearing and one or more element(s) in Brand with its name appearing, so this could be stored in Origin . I think I could use collection_select , but how do I utilize it here? class

Can't add item to iesi.collections.generic.iset

我的梦境 提交于 2019-12-13 04:50:10
问题 Trying to add item to iset, but it doesn't happens. var controlPoint = new ControlPoint {Lon = 53.25253, Lat = 56.23422, Radius = 16}; //controlPoint.ApprovedRoutes = new HashedSet<ApprovedRoute>(); controlPoint.Save(); var route = new ApprovedRoute(); route.ControlPoints = new HashedSet<ControlPoint>(); route.ControlPoints.Add(controlPoint); route.Name = "sometext"; route.Save(); //controlPoint.ApprovedRoutes.Add(route); //controlPoint.Save(); classes: public class GeoPoint: Entity<long> {

Hibernate : StackOverflowException logging ManyToMany association

喜夏-厌秋 提交于 2019-12-13 04:43:41
问题 After activating debug logging on org.hibernate.loader , i have a StackOverflowException when hibernate tries to log something like "loading collection [com.Bar#42]" The stack that's repeated is this one : at com.Quz.toString(Quz.java:120) at org.hibernate.type.descriptor.java.AbstractTypeDescriptor.extractLoggableRepresentation(AbstractTypeDescriptor.java:109) at org.hibernate.type.AbstractStandardBasicType.toLoggableString(AbstractStandardBasicType.java:291) at org.hibernate.pretty

JPA Hibernate intermediary table - resubmitted

爷,独闯天下 提交于 2019-12-13 04:40:51
问题 Rephrase of original question: I have your typical M:M relationship, in my case think of the User / Role example: USER, ROLE, USER_ROLE I need a second USER_ROLE table matching up User s to Role s. I won't get into specifics as to why that is (unless you need me to), but I am looking for a way to accomplish this with JPA AND without changing up the User and Role Entities. *I need a second USER_ROLE table to audit actions the User performs and which Role he was at the time the action was

Delete from Many to Many Relationship in MySQL

佐手、 提交于 2019-12-13 04:29:49
问题 I am not a MySQL professional I am just trying to make simple java application which accesses a MySQL database (e.g. The famous books/authors database) and manipulates it (i.e, add, update, delete). The problem is that there are two tables that have many to many relationship (e.g. authors table and books table) when I am trying to delete using DELETE FROM tableName WHERE someColumnName = 'someValue' it throws MySQLIntegrityConstraintViolationException with the message "Cannot delete or update

mvc entity framework many to many user and role insert

淺唱寂寞╮ 提交于 2019-12-13 04:22:40
问题 I have an mvc project with database first entityframework. In Project I have 3 tables. Users >>> UsersInRoles <<< Roles with many to many relationship. and my CreateUser codes below; public bool CreateUser(string email, string password, string birthday,string firstname,string lastname) { bool result; var dogumgunu = Convert.ToDateTime(birthday); var sifre = FormsAuthentication.HashPasswordForStoringInConfigFile(password, "sha1"); var confirmation = CreateConfirmationToken(email); try { var

Many to many with implied and explicit relationships

微笑、不失礼 提交于 2019-12-13 04:01:31
问题 I have a standard many-to-many relationship in my database between Person and Widget. A Person in an administrative role has access to ALL Widgets. In my application, I want to see which Widgets a Person has access to. I have two high level options: Explicitly manage the relationships. When a Person becomes an administrator, relate that Person to all existing Widgets. When a Widget is created, relate that Widget to all existing administrators. At run-time, if the Person is an administrator,

How to do a Search By Category and Area using Laravel

ε祈祈猫儿з 提交于 2019-12-13 03:56:42
问题 I want to be able to search user by the category to which they belong and also by the area in which they are located. I have 4 tables for that which include, A User table with id, name, surname, email, phone, type, photo and area_id. A category table with id, name, description A Service table with id, name, description, and category_id. and I have a Pivot table between Service and User named service_user with attributes id, name, price, description, user_id, and service_id. I wish to know how

N+1 query on bidirectional many to many for same entity type

可紊 提交于 2019-12-13 03:46:19
问题 I have an entity as below. I want to get an entity from DB with all of her/his friends with their primitive type fields (id, name). In this example, it is trying to return all friends and the friends of the friends so it is creating an infinite loop. I just want to get the first level friend objects with primitive fields. It seems like a N+1 query problem but I could not find a solution for it. Is there any solution for stopping this infinite recursion and returning the response as I

Creating association object through Flask-SQL Alchemy works as expected in shell, but produces JSON error in Flask route

纵饮孤独 提交于 2019-12-13 03:39:03
问题 I'm trying to create an association object UserRelationship which defines a 'follow' relationship between User and User . When I interface with this object through shell, it behaves as I expect, but when implemented onto a route function it produces a `TypeError: Object of type UserRelationship is not JSON serializable' class UserRelationship(db.Model): follows_id = db.Column(db.Integer, db.ForeignKey('user.id'), primary_key=True) bank = db.Column(db.String(100)) follows = db.relationship(