Questions tagged [one-to-many]

one-to-many is relationship between two different object properties.

One object property is relating with many properties of other object. Or you can say one object relating to many objects.

In sql, a one-to-many relationship, each row in the related to table can be related to many rows in the relating table.

http://en.wikipedia.org/wiki/One-to-many

3715 questions
1
vote
0 answers

FOSRestBundle PUT one to many relation

I am using FOSRestBundle to handle the API connections in my app, however I stuck with PUTting one to many relation, I don't know, how JSON should be composed. Note that entire API works, so all the form constructions, mapping, etc is configured…
undefinedman
  • 620
  • 1
  • 11
  • 25
1
vote
0 answers

Create one to many association without foreign key

Giving the following tables. Project Id: int not null PK Type: nvarchar(10) not null SomeProperty: nvarchar(50) ChangeRequest Id: int not null PK Type: nvarchar(10) not nul SomeProperty: nvarchar(50) Approval Id: int not null PK RowId: int not…
Rael Silva
  • 11
  • 2
1
vote
1 answer

EntityFramework : Mapping existing one-to-many relationship to Model

I am using the Linq-to-Sqlite ORM using the Entity Framework. Since Linq-to-Sqlite cannot itself create tables based on a model using code first approach, I am forced to reuse my existing table schema to build the entity model design. Below is my…
Lucifer
  • 2,317
  • 9
  • 43
  • 67
1
vote
1 answer

Why does merge() attempt to persist/validate entities in an inverse @OneToMany collection?

I'm seeing behavior in Hibernate (3.6.10) that doesn't match my mental model of what should be happening, and I'd like to know if this means there's a bug, there was a conscious decision made to break from the (otherwise-valid) mental model, or my…
Tim
  • 2,027
  • 15
  • 24
1
vote
1 answer

create dynamic default values for column in rails?

I am not sure how to go about this, or if there is a better way to do this, but I have a table called leads(many) and it references agent (one). I want to make a migration that sets a default value for the agent_id column in the leads table. But i…
TABISH KHAN
  • 1,553
  • 1
  • 19
  • 32
1
vote
1 answer

Odoo / OpenERP x2many display create/edit only

I have an editable tree within my form which is used to add certain customers to the form, each customer may have one or more addresses. Since everything else looks awful, I'm using the 'many2many_tags' widget for the addresses. The relevant code…
S.G.
  • 51
  • 2
  • 6
1
vote
2 answers

Delete a child from a @OneToMany relationship

In a One-To-Many relationship, how can I delete a child element without having to find and load up the parent, removing the element, update parent, THEN delete the child? To further illustrate my problem, I have the two classes Foo (parent) and Don…
Martin
  • 2,606
  • 4
  • 24
  • 38
1
vote
1 answer

Grails fails to delete orphan on collection in Unit tests, if composite id is used

I am using Grails 2.4.4. I would like to test the persistence in Unit Test Class with an in-memory database. I have a Parent class with a oneToMany relation with Child. The Child is ownedBy the Parent and has a composite key involving the parent.…
Andrea
  • 335
  • 3
  • 12
1
vote
2 answers

Grails/GORM: Manually assigning instance of one object to an instance of another fails on save

Simplest of models in Grails: class Author { String first_name String last_name static hasMany = [ books : Book] static constraints = { first_name() last_name() } } class Book { String title String…
ScottyDont
  • 1,207
  • 1
  • 9
  • 17
1
vote
0 answers

Mapping of oneToMany with composite key using eclipselink gives me ORA-01400

I am trying to map the classic bi-directional oneToMany using eclipselink. My problem is that when i want to insert a new 'child' i get SQLIntegrityConstraintViolationException. The database is described like this :…
jka_dk
  • 421
  • 1
  • 4
  • 17
1
vote
2 answers

One-to-Many association using the "append" operator in Ruby on Rails

I have a Developers Table and a Projects Table.I am trying to assign a one to many relationship between these two tables in my rails application. Were I will add developers to projects. developer belongs to a project ,project has many developers so…
Ab Mu
  • 13
  • 4
1
vote
0 answers

Map a triple join table with @MapKeyJoinColumn

I have 3 entities named : "Movie", "Person" and "Role", a person has a certain role in a movie. In my database, i have these 3 entities and to link them, a table : Cast(id_movie,id_person,id_role) all primary, because a person can be for example…
MaximeStor
  • 11
  • 2
1
vote
1 answer

Mongo Java queries, DBRef, and one-to-many relationships

I have implemented a relationship between two DBObjects using a DBRef, as described @ http://docs.mongodb.org/ecosystem/drivers/java-types/ For the sake of this question, we'll use the following two Java objects: Foo { String name, ... } Bar { Foo…
djaqua
  • 11
  • 3
1
vote
1 answer

symfony2 error: [RuntimeException] Namespace "ProjectBundle\Entity\Mandator" does not contain any mapped entit ies

I have a problem in a OneToMany-relationship in Symfony2. I created the entities Mandator // src/Pso/ProjectBundle/Entity/Mandator.php namespace Pso\ProjectBundle\Entity; use Doctrine\Common\Collections\ArrayCollection; use…
Micha
  • 43
  • 7
1
vote
3 answers

Is there a way to do a SELF JOIN on on the same column?

I currently have an inelegant solution that requires iterating through thousands of rows one at a time and I would like to know if it's possible to do this with a single SQL statement. I have a database table called history that holds a record of…
Klik
  • 1,757
  • 1
  • 21
  • 38