Questions regarding the implementation of one to many relations using Hibernate ORM framework
Questions tagged [hibernate-onetomany]
281 questions
2
votes
2 answers
I am facing **JSON parse error: Cannot deserialize instance of `java.util.HashSet` out of START_OBJECT token** in Spring Boot project
I am getting JSON parse error: Cannot deserialize instance of java.util.HashSet out of START_OBJECT token, with my Spring Boot project, when I am trying to save Pojo class object which is mapped with One-To-Many relationship with my another Pojo. I…

Amit
- 231
- 1
- 8
- 19
2
votes
2 answers
Spring Boot JPA OneToMany return Null
I'm working on spring boot with jpa, I try to use onetomany and for some reason when I try to post the request on postman it creates my parent object but does not use the child foreign key, and for that I'm getting null.
1 more thing: once I played…

boxser
- 25
- 1
- 5
2
votes
0 answers
Why to use Set in OneToMany Mapping in hibernate
I have two tables with a one-to-many relationship. I want to fetch those records and insert into another database which having same table by changing the primary key.
My application entity class
@Entity
@Table(name = "EM_APPLICATION")
public class…

paardhu
- 101
- 8
2
votes
1 answer
How to include join column in json result with JPA+Hibernate
I have a Province class like below:
public class Province {
@Id
Long id;
@Column(nullable = false)
String name;
@JsonManagedReference
@OneToMany(mappedBy = "province")
List cities;
}
and a City class like…

SadeghAlavizadeh
- 609
- 3
- 17
- 33
2
votes
1 answer
When hibernate will update related entities?
I'm using spring data JPA and have Player, Score entities. Player has @OneToMany relation to Score (and @ManyToOne from Score to Player). I save Player to the database without specifying related scores. After that, I save Score to the database,…

Dima Stoyanov
- 121
- 1
- 11
2
votes
2 answers
Hibernate OneToMany wrong binding from parent
I have a simple REST spring boot app written on Kotlin.
It has next schema: Map hasOne Channel and Channel hasMany Headers
I have only one action of controller, and want to save all my models in a single request like this:
{
"channel": {
…

qwert_ukg
- 490
- 5
- 15
2
votes
1 answer
hibernate one to many annotation foreign key null
I have two entities LR.java and LI.java. One request may have more than one items on it.
After the execution of this method the lR is always null inside the item table. What I am doing wrong here? Any suggestions

Rajeshkumar
- 815
- 12
- 35
2
votes
0 answers
Hibernate doesn't use batch-processing at bidirectional OneToMany-relation with JoinTable
I have several entities with a bidirectional @OneToMany-relation with @JoinTable. Functionality is working fine, besides the performance of inserting large amounts of datasets to the database.
I found out that in this case Hibernate isn't using…

flobuc
- 31
- 5
2
votes
0 answers
How to create a dynamic subquery in QueryDsl without using Q-Classes?
I'm kinda new to querydsl and currently working on a task where we
want to access a OneToMany related table without using the generated Q-classes and perform a subquery on that. We're using QueryDsl 3.7.4. In this example case we've got a simple…

Tobi
- 31
- 4
2
votes
1 answer
StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
I found too many answers in this site, but i am unable to resolve the error. Please help me to come out of this problem.
The exception is thrown when (Transaction) tx.commit is executed but I don't know why.If I comment tx.commit, the Employee…

Siddu
- 77
- 1
- 8
2
votes
1 answer
Hibernate one to many input using json with POSTMAN
The problem is one to many hibernate mapping is not working in this json format. I think it's a logical error, syntax error is not shown.
My Controller is:
@RequestMapping(value = "/save", method = RequestMethod.POST, produces…

Amritha Ashok
- 55
- 1
- 10
2
votes
1 answer
How to avoid insert and update queries in one-to-many uni-directional association
I have a simple one-to-many relationship between Employee & Phone entities.
I have 2 issues here.
Scenario 1 :
@Entity
public class Employee {
@Id
@GeneratedValue
private long id;
private String firstName;
private String…

learner
- 6,062
- 14
- 79
- 139
2
votes
1 answer
Hibernate : OneToMany mapping not based on PK?
I have 2 entities/tables.
One is a proper entity, let's call it data. It has a number of fields containing so-called "multilingual codes".
The second table, code, contains the multilingual values themselves.
Here is some example data :
Data…

Pierre Henry
- 16,658
- 22
- 85
- 105
2
votes
1 answer
Hibernate Unidirectional OneToMany with composite key
I wanted to frame Hibernate OneToMany relationship where
Parent has a composite primary key and Child has a primary key (hibernate-auto generated). Below is my working sample code :
class Parent{
@EmbeddedId
private ParentPk parentPk;
…

Rams
- 47
- 1
- 5
2
votes
1 answer
Mapping one-to-many to subclass in Hibernate
I have the following classes:
public class Step {
private int id;
private String name;
private List createdVariables;
private List captureVariables;
}
public abstract class Variable implements…

Eduardo Almeida
- 171
- 8