Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
0 votes
0 answers
13 views

Hibernate duplicates query for non-existing entities with OneToOne relationships

I want to prevent the duplicate SQL queries executed by hibernate, as my underlying relation is a complex view, (although maybe postgresql might cache the result, but still I would vastly prefer if ...
necromancer's user avatar
  • 24.4k
0 votes
1 answer
35 views

How to establish a one-way OneToOne relationship?

public class User { @Id private String user_id; private String email; private String password; @Getter @ManyToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL)...
jack_sparrow's user avatar
1 vote
2 answers
60 views

Getting java.lang.StackOverflowError when two users follow each other

I am working on a Java application using Spring Boot, and I have a UserEntity class where users can follow each other. However, when two users follow each other, I encounter a java.lang....
ssvt's user avatar
  • 21
1 vote
2 answers
115 views

Hibernate StatelessSession.upsert() based on @NaturalId

I have such entity with surrogate PK and unique key based on 3 varchar columns. public class InvoiceEntity { @Id @GeneratedValue private UUID id; @NaturalId private ...
Roman Oborin's user avatar
0 votes
0 answers
30 views

When using an ORM, when would it be better to add fields to a user object and lazy load them vs making a separate repository query?

I am building out a Spring Boot backend using Hibernate and JPA. I have a user object that I plan to fetch given a JWT per request. But past that I am unsure what would be the best way to fetch ...
liamocuz's user avatar
0 votes
1 answer
61 views

Hibernate/JPA: How to properly model unidirectional @ManyToMany relationship for CRUD operations?

I have implemented the following entities: Teacher: @Getter @Setter @ToString @Entity @Builder @AllArgsConstructor @NoArgsConstructor public class Teacher { @Id @GeneratedValue(strategy = ...
Diallo Francis Patrick's user avatar
0 votes
0 answers
37 views

Inaccessible Object Exception when trying to persist data to database

I am building an insurance management program with hibernate and javaFX. I was trying to persist an object to my database when I encountered the following error. Apr 26, 2024 11:33:44 AM org.hibernate....
user24694032's user avatar
0 votes
0 answers
28 views

Exception in thread "main" java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration at hibernatTest.Main.main(Main.java:10)

`i am trying to implement Non-maven project using Hibernate but i keep facing this error Exception in thread "main" java.lang.NoClassDefFoundError: org/hibernate/cfg/Configuration at ...
xxfatmahh's user avatar
0 votes
1 answer
35 views

Java JPA find entity with sub array

I will simplify the task a bit, but the problem is the following, I have an Entity that contains id, name and tags. @Entity public class MyEntity { @Id @GeneratedValue(strategy = GenerationType....
Jupit90's user avatar
  • 74
0 votes
2 answers
45 views

Why does Hibernate create multiple objects for the same entity?

If you get a child entity through a repo and through a parent entity, these will be two different objects We will also get a different object if we want to save the child entity through the parent In ...
NaN's user avatar
  • 41
0 votes
0 answers
11 views

Title: Issue with Insert Statement Generation for @ElementCollection Mapping in JPA

I'm encountering difficulties with generating insert statements for an @ElementCollection mapping in my JPA entity. Here's a summary of my setup: I have an entity class CustomMeal that extends another ...
Domanjie's user avatar
0 votes
0 answers
26 views

Spring JPA Data bidirectionality doesn't work

Working on some sort of social media where u can post events in your city. Want to add opportunity to like Events. Event entity: @Data @Builder @NoArgsConstructor @AllArgsConstructor @Entity @Table(...
Yarik's user avatar
  • 1
-1 votes
2 answers
132 views

Hibernate: JOIN inheritance question - why the need for two left joins

I've been reading an article about inheritance strategies in Hibernate. An Author has publications, and a Publication can be a Book or a BlogPost. In the join inheritance strategy the following table ...
parsecer's user avatar
  • 5,020
3 votes
0 answers
61 views

@ElementCollection with @OnDelete(action = OnDeleteAction.CASCADE)

I used to have an @ElementCollection with ON DELETE CASCADE on the database level generated by hibernate as follows: @ElementCollection @CollectionTable(name = "project2user", joinColumns = @...
dpelisek's user avatar
  • 1,002
1 vote
2 answers
61 views

Why does Hibernate generate a complex subquery for a bidirectional @OneToMany relationship with @JoinTable?

I am working with Spring Boot and Hibernate, managing entities with a bidirectional @OneToMany relationship joined through an intermediary table. Here are my entity definitions: @Entity @Table(name = &...
kairoslav's user avatar

15 30 50 per page
1
2 3 4 5
132