many-to-many

how to search multiple tags in doctrine

I have a database with many-to-many relations on tag and person. I am in trouble when tried to search a person with multiple tags. I tried this but its fail: $person = Doctrine_Query::create() ->from("Model_Person p") ->innerJoin("p.tags t") ->whereIn('t.id',$t) ->execute(); The above statement ...

Many-to-many map - Not detecting changes to collection.

Hi, I have the following map in my entity: <map cascade="all-delete-orphan" inverse="true" name="ManyToMany" mutable="true" table="ManyToManyTable"> <key column="TableAId" /> <index column="EnumValueId" type="MyEnum, MyAssembly" /> <many-to-many column="TableBId" class="MyBClass, MyAssembly"/> </map> This creates the table fine...

What's the most efficient way to retrieve objects of many-to-many relationships?

I have the following two models class Author(Model): name = CharField() class Publication(Model): title = CharField() And I use an intermediary table to keep track of the list of authors. The ordering of authors matter; and that's why I don't use Django's ManyToManyField. class PubAuthor(Model): author = models.ForeignKe...

Many-to-many relationships in Google AppEngine - efficient?

Hi, I'm using Google Appengine to store a list of favorites, linking a Facebook UserID to one or more IDs from Bing. I need function calls returning the number of users who have favorited an item, and the number of times an item has been favorited (and by whom). My question is, should I resolve this relationship into two tables for eff...

Java method naming conventions: Too many getters

Why do Java method names use the "get" prefix so extensively? At least in my Java programs there are a lot of methods with names starting with the word "get". The percentage of get-methods is suspiciously high. I am starting to feel that the word "get" is losing its meaning because of inflation. It is noise in my code. I have noticed th...

Mapping a ManyToMany relationship with hibernate annotations?

Table Layout: TABLE ORDER: id localizedInfoId Table OrderLocalizedInfo: id localizedInfoId name With the following entities: public class Order { @Id @GeneratedValue(strategy = GenerationType.AUTO) @Column(name="id") private Long id; @ManyToMany( targetEntity=OrderLocalizedInfo.class, cascade...

grails many_to_many custom mapping table

Is it possible to generate my custom mapping table in the many to many relationships in grails? I need to introduce an extra parameter in the mapping table and that is the need for creating my own custom mapping table :( ...

NHibernate Subquery with OrderBy

Hi, I have 2 entities... Audio Tag These are setup as a many-to-many, Audio has a reference to Tags, but Tags doesn't have a reference back to Audio. What i want to do is return all tags matching a search query with a count of how many Audios for each tag, they also need to be ordered by the Tags with the most Audio items. Just to m...

NHibernate ManyToMany extra field

Hi All, I have tables JobList, DoList, PlayList, and a lookup table called LegalRequirements I also have a LegalRequirementRelationship as a relation table between the 2, other than the Id of the XXXList and LegalRequirement, I also have a TypeId to identify which of XXXList the line is referring to. JobList,DoList,PlayList all have a ...

Doctrine adding a many-to-many relation for transient records

two models Site and Language share a many-to-many relationship (they are bi-directional) How do I add a relationship between them? Ideally I want to do this : (add an existing language to a new Site) $site = new Site(); $site->name = "Google" $site->url = "www.google.com"; ---- code to add language---- $site->save(); Or should I onl...

Unable to access EntityCollection on silverlight client

Hi! I have created a silverlight application, using the silverlight business application template. I added a ADO.NET entity data model, and created it from scratch in the designer. I then generated a database from the model. The model has a "project" entity and a "client" entity with a many-to-many relationship. Then, I added a doma...

EF4 how to delete entity in many-to-many relationship using POCOs

Hi, I'm using POCOs in combination with EF4 and some entities are in many-to-many relationships, in my case objects of class User and objects of class PrivilegeGroup. This is how class User looks like: public class User { public int UserID { set; get; } public string UserName { get; set; } public string UserPassword { get...

NHibernate many-to-many relationship question: can select, can't update

Each user has a list of roles: <class name="User" lazy="false" table="Users"> <id name="Id" type="int"> <generator class="native"/> </id> <property name="Name" /> <bag name="RoleList" table="User_Role" inverse="true" lazy="false" collection-type="Roles"> <key column="UserId" foreign-key="Id"/> <many...

Many-to-many SQL relation: how to retrieve all related entries in one query?

Hi Guys! I have the same tables as in this question: http://stackoverflow.com/questions/1202978/mysql-query-over-many-to-many-relationship. What I'm struggling with, though, is how to construct a query which would obtain a plant with all its attributes. I.e. if I want P1 I get P1 | A1 | A2 | A3 or P1 | A1, A2, A3 As opposed to P1 | ...

To cascade or not to cascade? ("object references an unsaved transient instance" error)

Hello, gentlemen! First, I've tried to ask the similar question yesterday (http://stackoverflow.com/questions/3255407/nhibernate-many-to-many-relationship-question-can-select-cant-update), but after a debugging night hopefully I can rephrase a question the better (right?) way. If I am doing something wrong by that - please tell - I'll er...

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

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 qu...

Help on a SQL Query

In a previous Post, I was doing a very simple database with 3 tables "doctor", "patient" and "visit". I've tried to make it more realistic and included now a many to many relationship between "doctor" and "patient". "visit" is the table resulting in this n-m relation. I assume the following simple structure for my table : doctor - idD...

LINQ to SQL many to many int ID array criteria query

Ok this should be really simple, but I am doing my head in here and have read all the articles on this and tried a variety of things, but no luck. I have 3 tables in a classic many-to-many setup. ITEMS ItemID Description ITEMFEATURES ItemID FeatureID FEATURES FeatureID Description Now I have a search interface where you can select a...

NHibernate query - Many-to-Many - eager loading (twitter style followers/following)

I have come stuck in optimizing one of my queries...here is my scenario... I have a domain simular to Twitter where a user can follow other users. So here is a sample of my User model: User -> Followers (many-to-many users) -> Following (many-to-many users) I now need to return a paged result of users following user 'XYZ', but also...

What does a Hibernate join table class using composite keys and @NaturalId look like?

I found this before: http://stackoverflow.com/questions/1212058/how-to-make-a-composite-primary-key-java-persistence-annotation There's a code snippet on the first answer: @Entity public class UserRole { @Id @GeneratedValue private long id; @NaturalId private User user; @NaturalId private Role role; } So, not using ar...