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

Wordpress: insert a custom post type instance as an option for a custom taxonomy

I'm trying to connect a custom post type to a taxonomy defined in an other custom post type. I'll show you an example. I have a custom post type COURSE, i use this post type to create a class for a university, so in this post type i'll have some…
Ema.jar
  • 2,370
  • 1
  • 33
  • 43
1
vote
1 answer

Add more object into an existing list in hibernate one to many unidirection

I have looked into several example on hibernate one-to-many unidirectonal relation, and wonder that how can I add a new object into an existing list. Assume that I have a class MyClass @OneToMany(fetch=FetchType.LAZY, cascade={ …
Joe209
  • 65
  • 5
1
vote
2 answers

Django one to many relationship: number of objects

here is my models: class Story(models.Model): writer = models.ForeignKey(UserProfile, blank=False, null=True) . . . class Comment(models.Model): on_story = models.ForeignKey(Story, related_name="comments", blank=False,…
1
vote
1 answer

Updating one-to-many independent association relationship disconnected scenario

I am using EF 6, MVC 4 (or 5) and trying to update a relationship between my 2 entities that have an independent association set up thus public class Activity{ public int ID {get;set;} public string Description{get;set;} public ActivityGroup…
nat
  • 2,185
  • 5
  • 32
  • 64
1
vote
2 answers

How to build nested responses in an Apigility driven application with a ZfcBase-DbMapper based model?

I'm developing a RESTful web application -- Apigility driven and based on the Zend Framework 2. For the model layer I'm using the ZfcBase DbMapper. The model essentially consists of two entities: Project and Image (1:n) and is currently implemented…
automatix
  • 14,018
  • 26
  • 105
  • 230
1
vote
0 answers

Ember: dumplicated records are created in store after model save action

I have two models in my ember app: App.Order = DS.Model.extend orderItems: DS.hasMany('orderItem') App.OrderItem = DS.Model.extend order: DS.belongsTo('order') I tried to save orderItem, bellow is the payload I got after save…
Tianyou
  • 11
  • 2
1
vote
0 answers

Saving one-to-many relationship to DB (laravel)

I'm trying to save a relationship the way I saw on the docs, but isn't working. On my Contato (Contact) model I've: public function filhoContato() { return $this->hasMany('FilhoContato', 'id_contato'); } Along with my fillables to enable…
SylaQo
  • 21
  • 3
1
vote
1 answer

How to get a Builder object from rows related to pivot - Laravel

I'm trying to get all the "books" that one user have: but I can't do it how I need. I use the following code: /*Gets all books from the user whose id is 1*/ $books= User::find(1)->books(); That return to me an Collection object; but I need a…
MartaGom
  • 501
  • 6
  • 27
1
vote
2 answers

to-many relation as sectionNameKeyPath

I want to show Project such that it shows all the projects on the basis of sharedToUsers basis. Means section name with User.user_id and it should shows all the shared project with that user. but i am not able to set section value for…
Iqbal Khan
  • 4,587
  • 8
  • 44
  • 83
1
vote
1 answer

JPA @OneToMany woes

I have three relationships that are causing me issues. @Entity @Table(name="area") public class Area implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.AUTO) private Long…
Damien Cooke
  • 599
  • 10
  • 20
1
vote
0 answers

EclipseLink: The field in this expression has an invalid table in this context

I get an exception with the description "The field [EMPLOYEE.ID] in this expression has an invalid table in this context.", when trying to execute this query, which should select all acivities of the given employee final Query query =…
triplec0re
  • 31
  • 5
1
vote
1 answer

Hibernate issue on creation OnetoMany,ManyToOne Mapping Giving null

I have a model like this: @Entity [...] class ParentObject{ [...] @OneToMany(cascade = CascadeType.ALL, mappedBy= "parentObject", orphanRemoval = true) private List relationship; } and in Relationship…
Alex Arvanitidis
  • 4,403
  • 6
  • 26
  • 36
1
vote
0 answers

Ordered One-to-Many List with Sequence Number column in Join Table with Hibernate

I have the following entities class ItemList { long id; List items; } and class Item { long id; String name; } I would like to represent them with the following tables table ITEM_LIST ( item_list_id number primary key ); table…
Vihung
  • 12,947
  • 16
  • 64
  • 90
1
vote
1 answer

Laravel Eloquent - Fetch data only if there is a match with data one to many relationship

I have a one to many relation setup. A Customer can have many Students, students can have a status as either Full or Left. I want to fetch the Customer only if they have Students that are FULL. I thought Eager Loading would do the trick but it is…
Pedro
  • 1,148
  • 4
  • 16
  • 35
1
vote
0 answers

Hibernate annotation one to many relation return null

Al Salam Alaykom, I'm trying to use hibernate annotation in one to many relation between Device and Positions Classes, one device has many positions. The problem that I'm getting a null list of positions when selecting the device, I tried a lot of…
Mohammad Sayed
  • 146
  • 1
  • 8