Consider the following: @Entity @Table(name = “cars”) public class Car { @Id private int id; private String name; @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType….
Tag: hibernate
Execute query with MySQL GET_LOCK function in Hibernate
My application uses Hibernate as ORM. I am trying to execute few mysql locking function within my application like GET_LOCK, IS_FREE_LOCK, RELEASE_LOCK (https://dev.mysql.com/doc/refman/5.6/en/locking-functions.html). However I am running into following issue: Here is my Dao code: I am not sure how to execute locking functions using Hibernate. Any help/pointer is appreciated. Thanks in advance. Answer I found the problem. It was
JPA cascade actions on one-to-one relationship
I have the following question regarding one to one relationships (and I guess one to many also): Let’s suppose I have the following tables: As you can see the two tables share the same primary key. Now the entities I created are the following: When I try to persist a new user I have a user object with all the
Stack overflow error for hibernate one-to-one mapping with Spring Data JPA
My problem is similar to this one https://discourse.hibernate.org/t/hibernate-throws-org-hibernate-id-identifiergenerationexception-attempted-to-assign-id-from-null-one-to-one-property/1777 but I am getting a different exception after applying the answer from this thread. My entities: Controller with corresponding Spring Data Repository: With this payload: I am getting an endless nested response with proper fields(distributor -> location -> distributor -> location ..), which ends with SO Error: I can’t fathom why does
Error starting ApplicationContext in Spring when add @OneToOne Annotation
: I am a beginner in Java Spring MVC and I want to create a simple program using spring boots. But I have a problem: When I add @OneToOne and @JoinColumn to my model class, the project doesn’t start! Error: Error starting ApplicationContext. To display the conditions report re-run your application with ‘debug’ enabled. 2020-05-24 15:24:45.140 ERROR 5368 — [
SpringBoot DTO Validation
I am new to spring-boot I’m trying to add validation to my DTO class like below. Below is my REST endpoint to save employee. I create a Validation class like below to validate the DTO fields. expected output is { “firstName”:”Employee first name is required”, “employeeNum”:”EmployeeNUM is required” } But I’m getting only the 400 bad request when hit the
Why are there so many SessionFactoryImpl objects in the dump?
I have ~15,000 identical SessionFactoryImpl objects in my dump: One of the objects with incoming references: One of the objects with outbound references: I don’t have the following parameters …
how do i fetch derived/calculated column from database view or Procedure in Spring Boot using JPA/Hibernate and use it along with predefined columns?
I am working on a project as am learning Spring Boot with JPA,Hibernate with Mustache as for templates. i managed to create a view with one calculated column which calculates an remaining days from issueDate and expiryDate. the view works fine and i am able to display all columns except the calculated column. I need help figuring out how to
Spring Data @Query use VARCHAR instead of NVARCHAR
The code that I posted is not the code that our companies uses, it is just example code to correctly illustrate the problem. I have the following Spring Data Query: For entity Customer: and Name: This works okay, but Spring data passes these parameters as NVARCHAR instead of VARCHAR. Therefore, the DB has to perform expensive conversion that is very
JPA @OnetoOne self reference relationship with both columns non null
I have an existing database table For e.g. T_STUDENTS on top of which I have to create a JPA entity. All three columns in the table are NON NULL and the table has a self-reference as mentor_id Each student has a mentor who is also a student. There is a strict OneToOne relationship between the student and the mentor. For