From JPA/Hibernate point of view, you shouldn't even think about the join table. You just need to maintain both sides of @ManyToMany relationship and let Hibernate manage the database. In your case it should come down to deleting one row and adding one row from the join table. Your code...
c#,entity-framework,asp.net-mvc-5,duplicates,many-to-many
I'd say you are on the right track. If tag names are unique theres no need to "Count" though. Just get the first one if it exists. Swap out dupes and do nothing for uniques // check for duplicate entries foreach (var tag in post.Tags.ToList()) { var dupeTag = uwork.TagRepository.GetAll().FirstOrDefault(t...
mysql,spring,hibernate,jpa,many-to-many
Try this: public class Professor { @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER) @JoinTable(name = "ALUNO_PROFESSOR", joinColumns = @JoinColumn(name = "idProfessor", referencedColumnName = "idProfessor"), inverseJoinColumns = @JoinColumn(name = "idAluno", referencedColumnName = "idAluno")) private List<Aluno> alunoList; } public class Aluno { @ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER) @JoinTable(name = "ALUNO_PROFESSOR", joinColumns =...
c#,linq,entity-framework,many-to-many
You can do this: var int cat_id=1; // Change this variable for your real cat_id var query= from article in db.Articles where article.Categories.Any(c=>c.Category_ID==cat_id) select article; This way you will get the articles that satisfies the condition you want. Don't worry, EF is smart enough to generate a SQL query where...
I've tried it now myself and it worked for me. That is, var_dump($model->rules); in view file gave me an array with Rule objects as expected. Here are my gii generated files. I have removed comments, attributeLabels(), rules() methods from model classes and action methods and behaviours() from the controller class....
php,mysql,transactions,many-to-many,model-associations
Don't you try to update your image_tag with invalid id? ..null, 0, -1 or something else? Look to your code. I suppose $img and $values->image are not the same, but you load $img only when $values->image is provided. However, you try to update image_tag every time....
How about: Business.Jobs.SelectMany(c => c.JobApplications).Count(); ...
asp.net,sql-server,gridview,many-to-many
you need a RoleComponent table which is a simple table of pk's that maps a Component to a Role. Sample table: CREATE TABLE [dbo].[RoleComponent]( [role_pk] [int] NOT NULL, [component_pk] [int] NOT NULL ) ON [PRIMARY] A checkbox is initially checked if an entry in this table exists for a specific...
ruby-on-rails,ruby,many-to-many,has-many-through
This should do it project = Project.create(name: 'first project') project2 = Project.create(name: 'second project') user.projects << project << project2 user.projects # [project, project2] ...
php,mysql,many-to-many,concatenation
You can make use of INNER JOIN and GROUP_CONCAT, see example below:- SELECT E.id, E.name, GROUP_CONCAT(O.name) OfficialName FROM Mapping M INNER JOIN Event E ON M.eid = E.id INNER JOIN Official O ON M.oid = O.id GROUP BY E.id ...
c#,entity-framework,many-to-many,ef-fluent-api
Looks like DiscussionWall.Members is null. It is not initialized to anything by your code. Try: private List<Person> _members; public List<Person> Members { get { return _members ?? (_members = new List<Person>()); } set { _members = value; } } See also: Why is my Entity Framework Code First proxy collection...
sql,arrays,postgresql,many-to-many
Since fleets is an array column you have a couple of options. Either use the ANY construct directly (no need to unnest()): SELECT * FROM vehicles WHERE fleet_fk = ANY(SELECT fleets FROM auth_user WHERE id = 4); Or rewrite as join: SELECT v.* FROM auth_user a JOIN vehicles v ON...
c#,linq,group-by,many-to-many,left-join
Getting the list of all the projects with the assigned users: var projects= from p in db.Projects select new{ project_Id = p.Project_Id, projectName = p.ProjectName, userList = p.Projects-Users.Select(pu=>pu.Users.UserName).ToList()}; ...
flask,sqlalchemy,many-to-many,flask-sqlalchemy,model-associations
My apologies, I finally stumbled across the answer in the SQLAlchemy docs... http://docs.sqlalchemy.org/en/rel_1_0/orm/basic_relationships.html#many-to-many ...where they explicitly define the difference: Many to Many adds an association table between two classes. association_table = Table('association', Base.metadata, Column('left_id', Integer, ForeignKey('left.id')), Column('right_id', Integer, ForeignKey('right.id')) ) The association object pattern is a variant on many-to-many: it’s...
java,hibernate,jpa,orm,many-to-many
EmbeddedId documentation Relationship mappings defined within an embedded id class are not supported. So, ProjectFunctionPK should contain only basic mappings, and entity mappings should be done in the entity itself. Here are some related posts http://stackoverflow.com/a/9760808/4074715 http://stackoverflow.com/a/4692144/4074715...
django,database,table,many-to-many,many-to-one
There is no such thing as a OneToManyField. It doesn't matter from a practical point of view which side the ManyToManyField lives on. Personally, I'd put it on Ride, both to avoid changing the User model and because conceptually I'd say that rides are the main objects here. And yes,...
c#,linq,entity-framework,many-to-many
Change that line to Course myCourse = _db.Courses.Include(e=>e.Members).Single(c => c.CourseId == courseId); And check If (myCourse.Members==null){ myCourse.Members= New List<Member>(); } ...
model,many-to-many,cakephp-3.0,self-join
My foreignKeys were bad, that was like this: $this->belongsToMany('Parents', [ 'className' => 'Users', 'joinTable' => 'users_users', 'foreignKey' => 'child_id', 'targetForeignKey' => 'parent_id' ]); $this->belongsToMany('Childs', [ 'className' => 'Users', 'joinTable' => 'users_users', 'foreignKey' => 'parent_id', 'targetForeignKey' => 'child_id' ]); Problem solved...
grails,delete,many-to-many,relationship
This a common problem. When you create a many to many relationship Your case will create three tables client, 'departmentandclient_department`. Now when you try to delete the department. Hibernate tries to remove the department from department table. This will fails because its entry is already saved in client_department table with...
python,postgresql,flask,sqlalchemy,many-to-many
https://groups.google.com/forum/#!topic/sqlalchemy/WAHaPIuzqZQ authors_books = db.Table( 'authors_books', db.Column('id', UUID(as_uuid=True), primary_key=True, default=lambda: uuid.uuid4().hex), db.Column('author_id', UUID(as_uuid=True), db.ForeignKey('authors.id')), db.Column('book_id', UUID(as_uuid=True), db.ForeignKey('books.id')), ) ...
grails,spring-security,many-to-many
The addTo (and removeFrom) methods are derived from the name in the hasMany map. If you had declared static hasMany = [rating:Rating] then the addTo method would be addToRating and your code would be correct. As it is now you just need to change the calls to addToRatings. p.s. This...
php,mysql,database,many-to-many
Sadly, this is not how MySQL works. You could do a GROUP BY and something like GROUP_CONCAT, but this would leave you with strings and not arrays. So why not turn it into the wanted object in PHP? Assuming the query can return multiple campaignIds, you could do it like...
java,hibernate,many-to-many,persistence
The owner side of the association is Acl. AclGroup is the inverse side (since it has the mappedBy attribute). Hibernate only cares about the owner side. So make sure to add the group to the acl when you add the acl to the group: that will work whatever the owner...
mysql,many-to-many,relationship,one-to-many
This should do the job: SELECT * FROM computer c LEFT OUTER JOIN model m ON m.ModelName = c.ModelName LEFT OUTER JOIN brand b ON b.BrandID = m.BrandID You may want to change the returned fields as per your requirements. Good luck with the project. === Update - To order...
symfony2,orm,many-to-many,query-builder
You need join() method to join products with category entity and then add your filter criteria in where() part $repository = $this->getDoctrine()->getRepository('AppMyBundle:Product'); $product = $repository->createQueryBuilder('product') ->join('product.category','c') ->where('c.id = ?1') ->setParameter(1, $variable) ->getQuery()->getResult(); I have used id of category for filtering if you need to filter with different property then change...
You can use the contains() method of collections : {% for c in categories %} <input type='checkbox' value='categories[{{ c.id }}]'{% if c.posts.contains(post) %} checked='checked'{% endif %}>{{ c.name }} {% endfor %} ...
java,jpa,many-to-many,eclipselink
If I understood you correctly (which is hard without some code), you persist an entity and after that add a relationship to another instance? When you call persist on an entity, it becomes managed entity which means JPA provider now manages its lifecycle. That means you no longer have to...
mysql,cakephp,many-to-many,one-to-many,cakephp-3.0
Solution In the ProjectsTable: $this->hasMany('Images', [ 'foreignKey' => 'project_id', 'joinType' => 'INNER' ]); In the ProjectsController: $project = $this->Projects->get($id, [ 'contain' => ['Categories', 'Users', 'Tags', 'Images'] ]); In the Projects > view.ctp <?php foreach ($project->images as $images): ?> <p><?= h($images->image_path) ?></p> <?php endforeach; ?> ...
This is a case for many-to-many relationship with additional information. You will need to create a new entity called, let's say Enrollments. Then, you will need to set 1-to-Many relationships between Student - Enrollment and Course - Enrollment entities. public class Student { [Key] public int Id { get; set;...
Try this using(var context = new Context()) { var movie = context.Movies.Single(x=>x.ID == movieID); var actors = context.Actors.Where(x=>x.Movie.Any(y=>y.ID == movie.ID)); foreach(var actor in actors) { actor.Movies.Remove(movie); } context.SaveChanges(); } ...
many-to-many,relationship,powerpivot,powerview
You need a unique list of design_ID's. If you can't select a third data set with a unique list then you could copy the design_ID's from both data sets into a new worksheet Remove Duplicates and then Create Linked Table which you can use to join to data set 1...
java,hibernate,many-to-many,updates
Finally done. Changes that affect behavior: <bag name="relatedAttributes" table="category_attribute" fetch="select" inverse="false" cascade="save-update"> ... </bag> and do not forget to call session.flush() after operations....
ruby-on-rails,ruby-on-rails-4,many-to-many
Simply iterate over all @post's postteams and display it's name/title/whatsoever: <p> <strong>Title:</strong> <%= @post.title %> </p> <p>Team Names:</p> <% @post.postteams.each do |pt| %> <% = pt.name %> # or whatever attribute of postteam you want to display <% end %> </p> ...
java,jpa,many-to-many,one-to-many,hibernate-cascade
I think there is an issue in inserting, please note each project has one project leader, so if you put another leader to project, the old one will be deleted and new one will be inserted, I wrote small program about your issue: package leader; import java.io.Serializable; import javax.persistence.*; /**...
c#,entity-framework,ef-code-first,many-to-many,code-first
To add a column to the junction table, you need to map it as an entity explicitly and create two one-to-many relationships: public class PersonCourse { [Key, Column(Order = 0),ForeignKey("Person")] public int PersonId { get; set; } [Key, Column(Order = 1),ForeignKey("Course")] public int CourseId { get; set; } public Person...
android,database,many-to-many,realm
There are several ways to implement many-to-many relationships in Parse. You can use Arrays or Relations depending on the number of related objects. You can read more in Parse's documentation. In Parse Relations, you can add multiple objects in a relation before making a call. Let me take Book and...
java,hibernate,annotations,many-to-many,cascade
It turns out that the specific answer to my primary question (#1 and the main topic) is: "Do not specify any CascadeType on the property." The answer is mentioned sorta sideways in the answer to this question....
The error is correct, the queryset doesn't have a 'girlfriends' attribute. This is because the queryset is a set of Man objects and each of these has the attribute def delete_all_objects(request): men = Man.objects.all() for man in men: man.girlfriends.clear() man.delete() return HttpResponse('success') I haven't tested this but it should be...
database,node.js,many-to-many,sequelize.js,eager-loading
I'm assuming you have N:M relationships between all those models? Like this: User ---mentors many---> Teams User --moderates many--> Teams Team --is moderated by many--> Users Team --is mentored by many---> Users If so, you might want to use the as option not only in the User.hasMany(Team) that you already...
mysql,sql,hibernate,many-to-many,hql
I think your query should be like this: SELECT a.applicaitonName FROM User u LEFT JOIN UserApp ua ON u.userId= ua.userId LEFT JOIN Application a On ua.applicationId= a.applicationId WHERE u.userName = ? or SELECT a.applicaitonName FROM UserApp ua LEFT JOIN Application a On ua.applicationId= a.applicationId WHERE ua.userId = ? ...
entity-framework,ef-code-first,many-to-many,entity-framework-6
afaik not with the ContractMedia entity, but you can: public class Media // One entity table { public int Id { get; set; } public string Name { get; set; } public bool Enabled { get; set; } public virtual ICollection<ContractMedia> Contracts { get; set; } } public class Contract...
many-to-many,relationship,django-1.7
Be careful.... when you write the code ! keyValues= key=models.ManyToManyField(KeyValues) make no sense !!...
python,django,many-to-many,blogs
The problem is related to this instruction : post.categories = post.categorytopost_set From the Django documentation: Unlike normal many-to-many fields, you can’t use add, create, or assignment (i.e., beatles.members = [...]) to create relationships. In your scenario you should manually create the CategoryToPostobject with both references to Post and Category and...
If your intermediate table has no other attributes, then you do not need to model it yourself. Just create a to-many relationship from Entity 1 to Entity 2, and a to-many relationship from Entity 2 to Entity 1, and make each relationship the inverse of the other. CoreData will build...
mysql,database-design,many-to-many,entity-relationship,self-reference
Based on my understanding of your question you need 2 tables: Users and UserConnections where User table has the basic attributes (userid, email, password) of the user. UserConnections has RequesterUserID, TargetedUserID, and results of that request (i.e. did the user accept or reject the request). When you write your SQL...
This will work: SELECT auth.* FROM Authorships auth, Authors au, Books bk WHERE auth.BookId = bk.ID and auth.AuthorId = au.ID ORDER BY au.Name SQLFiddle Link: SQLFiddle...
c#,entity-framework,mapping,many-to-many,fluent
imho, you must have two navigation properties (or at least if just one you can't configure it with two FKs) public class Discipline { public int Id {get;set;} public string Name{get;set;} public virtual ICollection<DisciplineRequirement> Requirements {get;set;} public virtual ICollection<DisciplineRequirement> RequiredBy {get;set;} } public class DisciplineRequirement { public int DisciplineId {get;set;}...
mysql,full-text-search,subquery,many-to-many
SELECT c.*, cl.colour, (MATCH (cl.colour AGAINST ('blue') + MATCH(c.name) AGAINST ('blue')) AS score FROM cars AS c LEFT JOIN cars_has_colours AS cc ON cc.car_id = c.id LEFT JOIN colours AS cl ON cc.colour_id = cl.id AND MATCH(cl.colour) AGAINST ('blue') WHERE MATCH (c.name) AGAINST ('blue') OR cl.id IS NOT NULL ORDER...
ruby-on-rails-4,checkbox,many-to-many,has-many-through,jointable
Models: class Course < ActiveRecord::Base has_and_belongs_to_many :enrollments class Enrollment < ActiveRecord::Base has_and_belongs_to_many :courses with this type of association you end up with a join table which will have course_id and enrollment_id . Thus not needing to create a new model just to handle your association. Rails already does that for...
mysql,sql,database,many-to-many,relational-database
Pivot table In Relational Database terms, that is an Associative Table. What you have is a need, such that designated rows in Table_A are related to all rows in Table_B; and the rest re related via Table_A_B. The great Dr E F Codd asks us to think of data...
php,mysql,sql,database,many-to-many
If you are talking about fetching the data then do a join between the tables using the chaining table. Something like below select p.PostName, c.CategoryName from posts p inner join post_categories pc on p.PostID = pc.PostID inner join categories c on c.CategoryID = pc.CategoryID where c.CategoryName in ('Digitl','Linear') ...
python,flask,sqlalchemy,many-to-many,flask-sqlalchemy
I had some help from https://twitter.com/140am on this one. I needed to represent contactgrouping as a Model rather than a Table, so that I could use relationships and access fields directly. class Category(db.Model): resource_fields = { 'id': fields.Integer(attribute='catid'), 'name': fields.String(attribute='catname') } __tablename__ = 'CATEGORY' catid = db.Column(db.Integer, primary_key=True) clientid =...
c#,nhibernate,many-to-many,nhibernate-mapping
Your mapping seems to be correct. Just not sure what is the session default FlushMode. To be sure, that it is not None, try to append into first using the session.Flush();. using (ISession session = NHibernateHelper.OpenSession()) { ... session.Flush(); } Reason why simple insert into User and Role is happening...
java,jpa,orm,many-to-many,eclipselink
You should not be getting a delete when you call myUnit.getPeople.remove(currentPerson) unless you mapped Unit to Person with a ManyToMany using the PER_IN_UNIT table. Since you have an entity for the PER_IN_UNIT table, this would be wrong, as it really should be a Unit-> PerInUnit OneToMany mapping and then a...
there was no problem in my implementation. i use PL/SQL developer and i didn't notice but it acquired a lock on one of the tables :|. so when i tried to delete a record, hibernate got stuck and from some reason didn't throw any error. Any way, the implementation is...
mysql,codeigniter,many-to-many
I think this might work for you. I have done something similar in the past while using CI. This is an Active Records query that should be in your model. This query can be shortened but I made it verbose so you see what is going on. public function get_ids($n1_id){...
sql,database-design,many-to-many
There's nothing wrong with including other fields in this kind of table. For the specific scenario you've described, it can actually be quite useful as you could add a Rank column, and then use that to sort the people associated with a contract if you want to find the most...
python,mysql,django,django-views,many-to-many
region.countries__in=country is an assignment, and because it is being performed in an if statement's condition, you are getting "colon expected". If you want to check for a country being related to a region you can do this: # country is the country's code n.region.filter(countries_code=country).exists() ...
django,django-models,many-to-many,manytomanyfield
I think you just need this: # assuming you have a contributor Registration.objects.filter(contributor=your_contributor_object) ...
c#,.net,entity-framework,many-to-many
You would need to add the ID properties themselves to the model definition -- EF can add foreign key properties automatically, but it probably doesn't like the idea of seeing navigation properties as keys. public class EmployeeCar { [Key, Column(Order = 0)] public int CarId { get; set; } [Key,...
Assuming you have the following tables: User ( ID, Name ) Comment ( ID,Name ) CommentRecipient ( User_ID, Comment_ID ) - where these are both foreign keys to the table above. Is it not as simple as: To get recipients when you know the Comment query the linking table: SELECT...
symfony2,join,doctrine,many-to-many,createquery
Try this public function rechercherProjets($lang, $cat) { $qb = $this->createQueryBuilder('p') ->innerJoin ('p.description', 'pi') ->innerJoin('p.categories', 'pc') ->andWhere('pc.tag = :cat') ->andWhere('pi.langue = :lang') ->setParameters(array('lang'=>$lang,'cat'=>$cat)); return $qb->getQuery()->getResult() } ...
django,django-admin,many-to-many,django-multiwidget
The only way I found was to use a new view for managing participants in the admin and add a link to it by overriding the default edit template.
.net,many-to-many,entity-framework-6,one-to-many,ef-fluent-api
You can use a navigation property and set the Dependents table in the model: public class Title { public int Id { get; set; } public string Name { get; set; } public virtual ICollection<Person> Dependents { get; set; } } public class Person { public int Id { get;...
java,hibernate,many-to-many,hibernate-cascade
Use session.persist() instead of session.save() Refer to hibernate docs for clear details: 1) Session.persist(): Make a transient instance persistent. This operation cascades to associated instances if the association is mapped with cascade="persist" 2) Session.save(): Persist the given transient instance, first assigning a generated identifier. (Or using the current value of...
hibernate,collections,many-to-many
If the relation between A and B is bidirectional, fetch B, then update it change the value of its A, make this value null or another value. some thing like this : B b = bService.getBById(id); b.setA(null); // or b.setA(anotherValueOfA); bService.update(b); it should work ...
mysql,sql,database,many-to-many
You can use a left join, and get the items where there is no matching tag: SELECT i.id, i.text FROM items AS i LEFT JOIN topic_item AS ti ON ti.item = i.id WHERE ti.item is null You can also use not exists: SELECT i.id, i.text FROM items AS i WHERE...
mysql,foreign-keys,many-to-many
If you have to enforce a one-to-one relationship between (t1.id,t2.id) and t4.id, that seems to indicate that (t1.id,t2.id) would be unique. If that's the case, if (t1.id,t2.id) should be UNIQUE in t3, then you could make that the PRIMARY KEY for t3. You could add a foreign key reference to...
php,mysql,laravel,many-to-many,relationship
You're looking for Laravel's polymorphic relationship. Instead of creating a new field for each related table, you have two fields: related id and related type. On both your Location and Employee model, add the following relationship: public function phones() { return $this->morphMany('PhoneNumber', 'phonable'); } On your PhoneNumber model, add the...
The error is extremly explicit. You are giving to the removeUser() function a string which is the user's id whereas the expected parameter type is a User. You must retrieve the user from the DB thanks to $id and then pass this user to the function....
django,many-to-many,django-queryset
You're very close: Change: [i.dealership for i in q.dealership.all] to: [dealership for dealership in q.dealership.all()] Here's sample output from one of my model's M2M relationships on a project which demonstrates what you should see from the list comprehension. shared_with is an M2M field to a model called Profile: >>> from...
Instead of save the attribute : @ManyToMany(targetEntity = User.class, mappedBy = "userSites", fetch = FetchType.LAZY, cascade = CascadeType.ALL) @NotAudited private List<IUser> localIt; I updated the site list of each users by adding the site to register into the concerned field : @BatchSize(size = 20) @ManyToMany(cascade = { CascadeType.MERGE, CascadeType.PERSIST },...
php,symfony2,doctrine,many-to-many
You are simply removing Tag if count($tag->getBooks()) == 0: $this->em->remove($tag); and persisting it again: $this->em->persist($tag); else is required: if(count($tag->getBooks()) == 0) { $this->em->remove($tag); } else { $this->em->persist($tag); } ...
SOLVED: foreach ($this->relationList as $value){ $model = new $this->modelNameRelation; $model->first_field = $this->firstField; $model->first_field_value = $this->owner->id; $model->second_field = $this->secondField; $model->second_field_value = intval($value); Yii::app()->db->createCommand()->insert($model->tableName(), $model->attributes); } ...
many-to-many,terminology,relationships,relational-algebra
you can distribute, permute, or combine multiple groups to define many to many relationships. Mapping a group to other groups does not explicitly state if the members are crossed or not, like in a Cartesian product. Permute is a more specific case because the order matters, but both permutations and...
station.members is a Manager, i.e. it is the accessor for queries on the related users. You need to actually perform a query: in this case, station.members.all().
php,mysql,many-to-many,one-to-many
I found an answer while reading a few days later. I learned about joins and realized that they were exactly what I was looking for.
java,spring,hibernate,jpa,many-to-many
Change many to many mapping in CollabEntity. You need to change join table name. i.e. name from technos to some other name. @ManyToMany(cascade = CascadeType.ALL) @JoinTable(name = "collab_technos", joinColumns = {@JoinColumn(name = "co_id", nullable = false, updatable = false)}, inverseJoinColumns = @JoinColumn(name = "te_id") ) ...
One option is to use conditional aggregation: SELECT FirstName, LastName, MAX(CASE WHEN ContactType = 'Home Phone' THEN ContactNumber END) AS Home, MAX(CASE WHEN ContactType = 'Home Fax' THEN ContactNumber END) AS Fax FROM Employees AS E JOIN Employees_Contacts AS EC ON E.EmployeeID = EC.EmployeeID JOIN Contacts AS C on EC.ContactID...
django,django-models,many-to-many,manytomanyfield,junction-table
Just create the Vote instance as described in the docs: Vote.objects.create(cmt=Comment.objects.get(uuid=id), user=some_user, vote_type=1) ...
django,database,python-3.x,many-to-many
Some code would help, but I believe that doing this inside EnterpriseProfile note: this depends on how you named some fields. you don't need a function: profile = EnterpriseProfile.objects.get(pk=1) # or whatever to get the object # next returns all users related to that enterprise in the M2M profile.enterprise.users.all() ...
ruby-on-rails,ruby,activerecord,many-to-many,associations
It looks like you're using plural names for the join table belongs_to associations. Try changing to: class LocationsTrip < ActiveRecord::Base belongs_to :location belongs_to :trip end ...
ruby-on-rails,forms,ruby-on-rails-4,nested,many-to-many
The reason a new record is created every time you submit a new staff member is because you don't actually let your controller know that the staff member's type could be an existing type. So now the question is, what is the best way to go about doing this EDIT...
python,django,database,table,many-to-many
About the first part of the question The Issue is - when a User adds a Ride, I want the driver, destination and mid_destinations and the rest of the fields to be set by the User (the driver is the User adding the Ride), Except for the passengers field. The...
Given my edit above, I can only suppose this is just some bug...
I figured it out. The UserManager was being loaded with one DbContext, and I was trying to associate a Skill loaded from a different DbContext. Quick hack to test and fix this was to load the user from the same DbContext as the Skills, update the user, save the DbContext....
php,many-to-many,kohana,has-many-through
I think you would need to do multiple joins, one for each sympton. But a quick look into the Kohana documentation shows, that it doesn't allow for aliases inside queries, so a constructing a WHERE clause is difficult/impossible. The only way I see that this works out of the box...
ruby-on-rails,ruby-on-rails-4,many-to-many,views,has-and-belongs-to-many
Change the beginning of the first line from <%= to <%. The = tells it to print the object returned, which in the case of each is the whole object....
What about this commonly used model? create table cross_ref ( a_id references a , b_id references b , from_ts timestamp , to_ts timestamp , primary key (a_id, b_id, from_ts) ); (NB I used timestamp as you did; normally I would use date)...
If the join table contains additional functional information, it's not a join table anymore, and it must be mapped as an entity. So you'll have a one-to-many between User and Share, and a one-to-many between File and Share....
Remember you declared $menuItems as protected. To access it you should create a getter (if you are calling it outside the class, which you don't specify, but i'm guessing it): public function getMenuItems() { return $this->menuItems; } and then to add a MenuItem: $menu->getMenuItems()->add($item); ...
ruby-on-rails,ruby,many-to-many,has-many-through
So i guess you are trying to create multiple memberships for a project, where the current user will decide which users should be member of newly created project? In that case @project.memberships.create(:user => @user) wont work, as it is generating only a membership for current_user. So when you pass the...
javascript,pointers,parse.com,many-to-many
No need to do an additional query on the UserInGroup's User attribute. Those can be fetched eagerly using include(), as follows: // return a promise that is fulfilled with an array of users belonging to // the Group with id groupId function usersInGroup(groupId) { var groupQuery = new Parse.Query("Groups"); return...
php,mysql,many-to-many,laravel-5
Ok from the expected resultset its more like you are trying to group the tag ids , and yes you can do using the group_concat function as SELECT group_concat(rat.tag_id) as tag_ids, rat.response_id, t.name, sr.response, p.name, p.email FROM response_and_tag_relationships rat INNER JOIN tags t ON t.id=rat.tag_id INNER JOIN survey_responses sr ON...
ruby-on-rails,many-to-many,relational-database
If the same Person can have more than one Property, you should can use HABTM. Something like this: class Person < ActiveRecord::Base # in the people table you are storing the 'role' value has_and_belongs_to_many :properties, join_table: 'people_properties' end class Property < ActiveRecord::Base has_and_belongs_to_many :people, join_table: 'people_properties' end You should create...