I have this Hibernate model I can insert a new Warning into the database with session.save(warning); session.getTransaction().commit();, warning being an instance of Warning and session being a hibernate session. However, trying to get an instance of Warning from the database like this results in the following error: java.lang.ClassCastException: class java.util.Date cannot be cast to class java.time.LocalDateTime (java.util.Date and java.time.LocalDateTime are
Tag: hibernate
java.lang.StackOverflowError: null [Spring Boot, Hibernate]
I have two classes User.java and Address.java and there is a one-to-one bi-directional mapping between them. But when I try to get the address using the User class I get an “java.lang.StackOverflowError: null” exception. The same thing happens when I try to get the User from the Address class. User.java Address.java MainController.java I am using the test() function to put
Keycloak giving Lock wait timeout exceeded error in case Save Events enable
I am using keycloak as an Identity broker in my project. Environment setup: Keycloak version 16.1.1 deployed in k8s cluster with replica 2. Cluster configuration: In keycloak setup we want to log Login and Logout events so I enabled the Save Events and added Save Types as below Event config: Now when users login/logout from the application, I am getting
Alternative to using deprecated save method in hibernate
I am using the following code to save a person object into the database: I see that the save method is deprecated. What’s the alternative approach that we are supposed to use? Answer save() is deprecated since Hibernate 6.0. The javadoc suggests to use persist() instead. Deprecated. use persist(Object) Small print: save() and persist() are similar, but still different. save()
Spring Data JPA: What is wrong or how to correct this jpql query
The entity relationships are – A student belongs to one college And a college can have multiple students. So there is ManyToOne relationship between Student –> College And a OneToMany relationship between College –> Student. The entities are as below. and 1) I am using the below jpql query in spring data jpa repository. I am expecting that a list
How does JPA EntityGraph allow chosing the entity graph at runtime?
I have seen various post describing that JPA EntityGraph allows to choose the graph at run time. And I am not entirely clear what this refers to. Out of good faith and respect I would like to take this helpful article for reference: https://www.baeldung.com/jpa-entity-graph. (Most of JPA users might have gone through it already.) The article quotes – EntityGraph allows
JpaRepository with custom Query and Composite Primary Key: error unknown column
I have a SQL Server entity with a Composite Primary Key. That is the Entity: and this is ID Class: That is the JpaRepository But when this Query is executed I get an error: Invalid Column name: plz Answer Finally I got the solution 🙂 The select wasn’t returing the full key / object. Validation on the object failed and
Should EntityManagerFactory be closed at application shutdown?
I have a Java application that has a GUI made with Swing and that uses two databases interchangeably. One of the two databases is mongoDB and the other one is MySQL. Which database to use is chosen with a command line option. For the MySQL database I am also using Hibernate and JPA. The code I have looks like this:
Mysql problem ,cant resolve it, cant somebody help, i using java
Yoo coderrs, have problem connect and write table to my online free database. Problem is hereUnable to create requested service and Unable to make JDBC Connection 1class package sk.hibernate; 2.class persistence.xml POM Answer I just accessed your database with the following URL: (I masked the credentials). So you missed the prefix “jdbc:” You should quickly change your username and password
How to reuse validator class in spring boot app?
I am currently writing custom validator for Spring Boot app and its idea is mainly to do some validations depending on other validations. For example, I want one field to be @NotNull if some other field is null, but the idea is to make it more generic, so that this conditional validations can be changed. For this purpose I tried