Questions tagged [hibernate-onetomany]

Questions regarding the implementation of one to many relations using Hibernate ORM framework

281 questions
1
vote
0 answers

Java - Hibernate Mapping Entity from SQL View One-to-Many

Considering I have the following tables: USERS : ID - PK AUTO INCR NAME - CONSTRAINT UNIQUE AGE ROLES : ID - PK AUTO INCR NAME, ROLE NAME in TABLE ROLES is NOT a foreign key of NAME from TABLE_USERS as a Role can be held by someone that is not a…
JustADude
  • 71
  • 2
  • 11
1
vote
0 answers

OneToMany Mapping Child Parent

Hi I am using Spring Boot app with MVC. I have two model classes Parent and Child. Parent to Child has OnetoMany Mapping. I have a form submit in which I'm passing few fields of child class, now what is happening when I bind the child class in the…
prit kalra
  • 319
  • 4
  • 18
1
vote
2 answers

Unique constraint violation on hibernate update to OneToMany collection

I have the following entities: @Entity public class License { // ... @OneToMany(mappedBy = "license", cascade = CascadeType.ALL, fetch = FetchType.EAGER, orphanRemoval = true) private Set services = new HashSet<>(); //…
t777
  • 3,099
  • 8
  • 35
  • 53
1
vote
2 answers

JPA : Select parent and child with oneToMany relatinships

Implemented one to many relationship and select parent and child I have a onetomany relationship and I want to do a query (select *) Folders.java @Entity @Table(name = "FOLDERS") public class Folders implements Serializable { @Id …
user1814879
  • 984
  • 6
  • 23
  • 49
1
vote
2 answers

Create instance of the Entity in the Many side of ManyToOne Relationship

I'm using Spring Data JPA. I have the following Entities Person Entity class Person{ private String id; @OneToMany(mappedBy="owner") private List contacts; ... } And Contact Entity class Contact{ private String…
1
vote
0 answers

"invalid column index" error while inserting data to DB using hibernate

I am new to hibernate. I am using hibernate to insert the data to the DB. While inserting the data to the DB getting "invalid column index" error. I am using OnetoMany mapping in hibernate. Please let me know if I have implemented something wrong…
Rishi Arora
  • 1,713
  • 3
  • 16
  • 31
1
vote
3 answers

@OneToMany cause collection is not associated with any session

I'm trying to get a lot of data in one query with Hibernate. I have this named query : SELECT r FROM Reservationlight_SS r LEFT JOIN r.personne p WHERE r.iDSport =:IDSport AND r.iDSaison =:IDSaison AND r.dateReservation =:date GROUP BY…
Chatis
  • 47
  • 2
  • 11
1
vote
0 answers

OneToMany not working in Hibernate (org.hibernate.AnnotationException)

I know there are alot of topics about this problem, but none of them are like this (As most people actually forget to use mappedBy propertly). But I'm entirely sure this code is right and thus i'm completely stuck on this…
iLuvCode
  • 329
  • 1
  • 4
  • 15
1
vote
1 answer

How to retrieve data from Hibernate bidirectional OneToMany ManyToOne in Java Spring

It really sounds like a easy question but I really cannot find anything useful. My question is how can I get DB entries using criteria(or something else) from a bidirectional ManytoOne association? So let's say that we have 2…
1
vote
1 answer

Hibernate - using composite key that contains a parent id - OneToMany

(The original question has changed, see updates below.) I have trouble letting hibernate set the primary key of a child object. The primary key is identical with the parent's primary key. This is what the parent looks like: @Entity @Table(name =…
Nina
  • 681
  • 1
  • 10
  • 27
1
vote
0 answers

JPA self mapped entity with ManyToOne issue

I have MySQL table with readonly access oc_category (table from Opencart). With the next records: id | parent_id | Category ------------------------------ 1 | 0 | TOPCategory1 2 | 0 | TOPCategory2 3 | 1 | Category1 4 …
Oleg Kovalyk
  • 508
  • 5
  • 12
1
vote
0 answers

More than one "one to many" association using Detached Criteria (XML Based Hibernate Configuration)

I am trying to join three tables by using Detached Criteria Class of Hibernate. I have three tables those are STUDENT,STUDENT_CORRESPOND,STUDENT_COURSES Primary Keys of tables are **Table Names** **Primary Keys** STUDENT …
1
vote
1 answer

Object relational mapping

I am very new to ORM and can any one suggest an Idea to over come the following scenario. I have a Chat Class as bellow @Entity public class Chat { @Id @GeneratedValue @Column(name="Id") private int id; @ManyToOne …
Faseem
  • 25
  • 1
  • 8
1
vote
2 answers

Hibernate - OneToMany - Several Columns

I have those 2 tables Teacher and Contact, a teacher can have x Contacts. So here we are looking at a @OneToMany association. Tables Structure: User [userid, username, email,...] Contact [contactid, contactname, ref, reftype,...] I want to load…
deluxouss
  • 21
  • 1
  • 3
1
vote
0 answers

Hibernate One to many

As per hibernate documentation: To map a bidirectional one to many, with the one-to-many side as the owning side, you have to remove the mappedBy element and set the many to one @JoinColumn as insertable and updatable to false. This solution is not…
sab
  • 9,767
  • 13
  • 44
  • 51