Questions tagged [hibernate-onetomany]

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

281 questions
0
votes
1 answer

hibernate on to many reverse query

I have many2one relation between 2 entities Question and Answer with many2one defined in Answer' and no one2many defined inQuestion`. How can i query with hibernate the questions that do not have any answers without adding one2many relation in…
alizelzele
  • 892
  • 2
  • 19
  • 34
0
votes
0 answers

Grails AddTo in for loop

I am facing a problem due to that i'm newbie to grails i'm doing a website for reading stories and my goal now is to do save the content of the story into several pages to get a list and then paginate it easily .. so i did the following. in the…
Mohamed Emad Hegab
  • 2,665
  • 6
  • 39
  • 64
0
votes
1 answer

how to set Multiple one to many relation with same column hibernate

There are two entities. Route (Arrival, ArrivalID and Departure , DepartureID) as Location Location (Arrivals , Departures ) as Route Location will have 2 one to many relationship with route table. I am trying to set. Route.xml
Shan Khan
  • 9,667
  • 17
  • 61
  • 111
0
votes
1 answer

Spring Hibernate Relation Mapping

I'm looking for help in one of my project. I'm having Company Class and Bank Class. Company Class and Bank Class are to be mapped using Many to Many Relation using Hibernate. How Do I start? I'm done creating Company Module which is inserting data…
0
votes
2 answers

JPA - Changing the Name of the mappedBy column

Okay I have an application that maps Semesters to their courses; public class Course { private String courseId; private String courseName; private Collection semesters = new ArrayList<>(); @OneToMany(targetEntity =…
Kramer786
  • 1,238
  • 1
  • 12
  • 26
0
votes
2 answers

Persist Object with Hibernate in OneToMany

I have a problem with my hibernate casscade. I'm trying to persist a set of document. The data model is the following: Corpus 1 --- n Document 1 --- n TextBlock n --- 1 Speaker n --- 1 Party My scenario is the following: SpeakerFacade sf = new…
0
votes
1 answer

Hibernate domain versioning when oneToMany relation is updated

I am wondering if domain version will be changed if oneToMany relation is updated. e.g There is User entity which has OneToMany relation to Addresses . So if I am updating Addresses list will it have impact on user version ? @Entity public class…
0
votes
0 answers

Hibernate: Foreign key must have same number of columns as primary key

I have the following two classes (this is simplified a bit): @Entity @Table(name = 'DETAILS') class Details { // Properties @Id @Column(name = 'ID') Integer id @Id @Column(name = 'ID2') String secondaryId @Id @Column(name = 'FIRST_NAME')…
Harry Muscle
  • 2,247
  • 4
  • 38
  • 62
0
votes
1 answer

how verify the OneToMany relationship between two entities

I have two entites Parent and Child with OneToMany relationship in Hibernate, Parent has many Childs, I want to check if the Parent has Childs or not I used these conditions and they not working if (parent.getChilds().size() == 0) and if…
Spartan
  • 1,167
  • 4
  • 20
  • 40
0
votes
1 answer

Grails domain class relationship many to one

I design domains classes as follow: class Invoice { static hasMany = [invoiceOneLines: InvoiceLine, invoiceTwoLines: InvoiceLine] } class InvoiceLine { static belongsTo = [invoice: Invoice] } The invoice line has 2 types: invoiceOneLines and…
kucku13
  • 7
  • 2
0
votes
2 answers

Lost with hibernate - OneToMany resulting in the one being pulled back many times

I have this DB design: CREATE TABLE report ( ID MEDIUMINT PRIMARY KEY NOT NULL AUTO_INCREMENT, user MEDIUMINT NOT NULL, created TIMESTAMP NOT NULL, state INT NOT NULL, FOREIGN KEY (user) REFERENCES…
Andy
  • 1,421
  • 1
  • 16
  • 22
0
votes
1 answer

Unexpected behavior with Hibernate @OneToMany

I'm a new user of JPA with spring-boot so this question may appears very naive. I've a two very simple entities : @Entity @Table(name="RATEPLAN") public class RatePlan implements Serializable { @Id @GeneratedValue @Column(name="RPCODE") private…
0
votes
1 answer

Hibernate Mapping : delete children in one to many bidirectional mapping in hibernate

I have a parent object and its detail object. The mappings are mentioned in the below code - Parent Object Mapping
0
votes
1 answer

why when I delete a parent on a one to many relationship on grails the beforeInsert event is called on the child?

I have a one to many relationship and when I try to delete a parent that haves more than one child the berforeInsert event gets called on the frst child. I have some code in this event that I mean to call before inserting a child, not when i'm…
nico
  • 9,668
  • 8
  • 26
  • 28
0
votes
1 answer

ASK HIBERNATE: ERROR: mappedBy reference an unknown target entity property

this is my sql CREATE TABLE room ( room_id INT, primary key (room_id) ) ENGINE=InnoDB; CREATE TABLE people ( people_id INT, live_in INT, primary key (people_id), foreign key (live_in) references room(room_id) )…