many-to-many

Doctrine 2 manyToMany relation Selecting Entity with AND

倾然丶 夕夏残阳落幕 提交于 2019-12-10 11:44:50
问题 I'm building a website which needs the ability to filter villa's based on their options. So for example: A villa has the options: Wi-Fi, Pool, Animals allowed. When filtering I'm giving the options: Wi-Fi and Pool. I now need a filtered list of villa's based on BOTH these options. So I only want the villa's that have both Wi-Fi AND a Pool. My Villa Entity looks like this: class Object { /** * @var integer * * @ORM\Column(name="id", type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy=

Delete an item from many-to-many relationship

半城伤御伤魂 提交于 2019-12-10 11:32:45
问题 I've following mapping for two tables having a Many-to-Many relationship between them. How do I delete an entry from the mapping table, which is 'TB_EMAIL_GRUPO_ARQUIVO' in my case? I just need to delete the data from this "joining" table and I don´t need to delete it from the "parent tables". GrupoModulo public GrupoModuloMap() { Schema(Const.SCHEMA); Table(Const.TB_EMAIL_GRUPO_MODULO); CompositeId() .KeyReference(x => x.Grupo, Const.ID_GRUPO) .KeyReference(x => x.Modulo, Const.ID_MODULO);

Hibernate Many to Many and JSON serialization

时间秒杀一切 提交于 2019-12-10 10:40:07
问题 I'm using Hybernate to persist some beans that have a Many-To-Many relationship. Here are the two beans: Email.java @Entity @NamedQuery(name = "Email.findAll", query = "SELECT e FROM Email e") public class Email implements Serializable { private static final long serialVersionUID = 1L; //... other fields ... // bi-directional many-to-many association to Pratica @ManyToMany() @JoinTable(name = "email_pratica", joinColumns = { @JoinColumn(name = "fk_email_id") }, inverseJoinColumns = {

Many to Many relationship using SQL and Linq (entity framework/to entities)

余生颓废 提交于 2019-12-10 10:23:47
问题 I have two tables: - Attendees - Events Normally, I would create a mapping table ' EventAttendeeMap ' to link these tables into a many to many relationship. Is this the best way of doing so? Should I store the list of AttendeeId s in an xml column instead on the Events table? I am using .NET 3.5/4 with Linq as the DAL (although I think this is irrelevant to the design question being asked, possibly). Interested to see what people's opinions are. Thanks. Dave 回答1: A mapping table is definitely

Python's SQLAlchemy doesn't clean out the secondary (many-to-many) table?

杀马特。学长 韩版系。学妹 提交于 2019-12-10 02:39:46
问题 I have a many-to-many relationship between User s and Task s. I want the "secondary table" (meaning, the table that facilitates the many-to-many relation) to be cleaned out when I delete a Task or User . How can I configure SQLAlchemy for this? Here is some sample python code which demonstrates the problem I'm having. Note: This code is fully self contained, and only requires the sqlalchemy module. If you copy and paste this code, you should be able to run it without any side effects and see

Django filter through multiple fields in a many-to-many intermediary table

隐身守侯 提交于 2019-12-10 01:10:02
问题 I have the following models in my django project: class Video(models.Model): media = models.ForeignKey(Media) class Media(models.Model): title = models.CharField(max_length=255) formats = models.ManyToManyField(Format,through='MediaFormat',related_name='media',blank=True) class Format(models.Model): title = models.CharField(max_length=50) class MediaFormat(models.Model): status = models.IntegerField() format = models.ForeignKey(Format) media = models.ForeignKey(Media) Now, I want to filter

Hibernate criteria for many-to-many entity property

为君一笑 提交于 2019-12-09 18:58:50
问题 @Entity class A { @ManyToMany private List<B> list; ... } @Entity class B { ... } I'd like to get list from A class using criteria (not sql query). Is it posible to do this? Projection in this case does not work. 回答1: Unfortunately, The Criteria only allows selecting the root entity, and not any joined entity. It would thus be easier if your ManyToMany was bidirectional. You could the use the criteria equivalent of select b from B b inner join b.as a where a = :theA If that's not an option, I

Many-to-many self-referential relationship in sqlalchemy

微笑、不失礼 提交于 2019-12-09 14:47:31
问题 I'm trying to make a self-referential many-to-many relationship (it means that Line can have many parent lines and many child lines) in sqlalchemy like this: Base = declarative_base() class Association(Base): __tablename__ = 'association' prev_id = Column(Integer, ForeignKey('line.id'), primary_key=True) next_id = Column(Integer, ForeignKey('line.id'), primary_key=True) class Line(Base): __tablename__ = 'line' id = Column(Integer, primary_key = True) text = Column(Text) condition = Column

Adding and removing from a has_many :through relation

只谈情不闲聊 提交于 2019-12-09 13:11:29
问题 From the Rails associations guide, they demonstrate a many-to-many relationship using has_many :through like so: class Physician < ActiveRecord::Base has_many :appointments has_many :patients, :through => :appointments end class Appointment < ActiveRecord::Base belongs_to :physician belongs_to :patient end class Patient < ActiveRecord::Base has_many :appointments has_many :physicians, :through => :appointments end How would I create and remove appointments? If I've got a @physician , do I

Symfony2 form widgets for many-to-many relations

点点圈 提交于 2019-12-09 10:45:41
问题 In Symfony 1 there was as form widget named admin_double_list. It generated two select fields named Unassociated and Associated. It also generated buttons to add items from one list to another. Is there any easy way to accomplish this in Symfony2? Or maybe some other user friendly way to edit many-to-many relations? In the documentation there are only four widgets for many-to-many relations and none of them are very nice when there are massive amount of relation possibilities to edit. 回答1: