many-to-many

CoreData: many-to-many relationship

亡梦爱人 提交于 2019-12-12 01:24:55
问题 I have 2 objects, with many to many relationships. Here's my code: + (NSSet *)activitiesSetForMember:(Members *)member inManagedObjectContext:(NSManagedObjectContext *)context{ NSSet *activitiesSet = nil; NSFetchRequest *request = [[NSFetchRequest alloc] init]; request.entity = [NSEntityDescription entityForName:@"CompanyActivity" inManagedObjectContext:context]; request.predicate = [NSPredicate predicateWithFormat:@"hasMembers contains %@", member]; NSError *error = nil; activitiesSet = [

edit/update collection_select with has-many-through association

时光怂恿深爱的人放手 提交于 2019-12-12 00:47:37
问题 I have the following models: RECIPE, TAG and TAGGING (join table) recipe.rb has_many :taggings has_many :tags, through: :taggings accepts_nested_attributes_for :taggings tag.rb has_many :taggings has_many :recipes, through: :taggings scope :diet, -> { where(type_id: 1).to_a } scope :category, -> { where(type_id: 2).to_a } scope :festivity, -> { where(type_id: 3).to_a } scope :daily, -> { where(type_id: 4).to_a } Everything normal so far. But, in my TAGS table I have a field called "type_id"

SQLAlchemy: filter many-to-many joinedload

假装没事ソ 提交于 2019-12-12 00:44:48
问题 I have the current table setup for a many to many association between "words" and "phrases": association_table_wp = Table('words_phras', Base.metadata, autoload=True, extend_existing=True) class Phrase(Base): __tablename__ = 'phrases' __table_args__ = {'autoload': True} def __init__(self, phrase, explanation=None, active=False): self.phrase = phrase self.explanation = explanation self.active = active class Word(Base): __tablename__ = 'words' __table_args__ = {'autoload': True} def __init__

eclipselink SQLServerException inserting into a join table with additional column

限于喜欢 提交于 2019-12-11 23:05:40
问题 I have a many-to-many relationship which looks like this: The primary key is combination of three columns and I'm using eclipselink. I created these classes to be able to insert in the join-table : @Entity @Table(name = "definition_property") @NamedQueries({ @NamedQuery(name = "DefinitionProperty.findAll", query = "SELECT d FROM DefinitionProperty d")}) public class DefinitionProperty extends AbstractEntity{ private static final long serialVersionUID = 1L; @EmbeddedId protected

predicate subquery to return items by matching tags

此生再无相见时 提交于 2019-12-11 21:02:08
问题 I have a many-to-many relationship between two entities; Item and Tag. I'm trying to create a predicate to take the selectedItem and return a ranking of items based on how many similar tags they have. So far I've tried: NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SUBQUERY(itemToTag, $item, $item in %@).@count > 0", selectedItem.itemToTag]; Any other iterations that have failed. It currently only returns the selectedItem in the list. I've found little on Subquery. Is there a

Check if UNIQUE row already exists using findBy in ManyToMany, any workaround or working solution?

╄→尐↘猪︶ㄣ 提交于 2019-12-11 20:45:40
问题 So I've this relations defined in my entities: class Producto { /** * @ORM\ManyToMany(targetEntity="AppBundle\Entity\Norma", inversedBy="normasProducto", cascade={"persist"}) * @ORM\JoinTable(name="nomencladores.norma_producto", schema="nomencladores", * joinColumns={@ORM\JoinColumn(name="producto_id", referencedColumnName="id")}, * inverseJoinColumns={@ORM\JoinColumn(name="norma_id", referencedColumnName="id")} * ) */ protected $productoNormas; } class Norma { /** * @ORM\ManyToMany

nhibernate many to many with multiple table

柔情痞子 提交于 2019-12-11 20:25:54
问题 Good morning, I have the following schemas in mind which the login as describe below image. Normally, the association table would contain the Key of table Position, Division, and Qualification. I am not sure whether this schema is well form or not.If it does could you please guide me how to represent it in Nhibernate XML schemas and PoCo class? Best regards, Veasna 回答1: Your schema, your ideas, are prove of concept: do not use many-to-many mapping. Chapter 24. Best Practices Don't use exotic

Nhibernate many to many relationship mapping

蹲街弑〆低调 提交于 2019-12-11 17:59:32
问题 I am very new to Nhibernate. I would like to develop an application in asp.net by using NHibernate as mapping database tools. I have following tables schemas: CREATE TABLE [dbo].[tblTeam]( [TeamID] [int] IDENTITY(1,1) NOT NULL, [TeamName] [varchar](100) NOT NULL ) CREATE TABLE [dbo].[tblEmployee]( [EmployeeID] [int] IDENTITY(1,1) NOT NULL, [EmployeeName] [varchar](100) NOT NULL ) CREATE TABLE [dbo].[tblTeamEmployee]( [TeamID] [int] NOT NULL, [EmployeeID] [int] NOT NULL ) And here is

Hibernate One to Many and Many to One Relation

回眸只為那壹抹淺笑 提交于 2019-12-11 17:52:01
问题 These two questions answered many of my questions, but I am still struggling to think about in real scenario! Taking an example from the references. Assume I have one Order and Multiple Items associated with it. Now assume One Item can have one Returns but one Returns can have multiple Items. What I understood is, Order to Items will be One to Many Relation . Since I need to get Order of an Item, I will create column 'order_fk' in Item table to get it. //Order entity @OneToMany @JoinColumn

NHibernate Many To Many

妖精的绣舞 提交于 2019-12-11 17:49:56
问题 I have a many to many relationship between Portfolio and PortfolioTags A portfolio Item can have many PortfolioTags I am looking at the best way of saving tags to a portfolio item. My Nhibnerate maps are like so: public class PortfolioMap : ClassMap<Portfolio> { public PortfolioMap() { Table("Portfolio"); LazyLoad(); Id(x => x.Id).GeneratedBy.Identity().Column("Id"); Map(x => x.AliasTitle).Column("AliasTitle").Not.Nullable(); Map(x => x.MetaDescription).Column("MetaDescription").Not.Nullable(