Skip to content

Tag: hibernate

JPA createQuery where condition does not work

I am trying to use JPA to fetch records from database. However I am able to insert records indatabse and even get all the records using createQuery method of class EntityManager. But in below case I am not getting why the condition in where clause is not working. Please help me figure it out. POJO class : DAO…

How to show the query made by Hibernate 5.5.6

It’s my day 3 with Hibernate. I’m using Hibernate 5.5.6 pom.xml I think my hibernate.cfg.xml is also correct: App.java Yes, the data is inserted properly but I’m not able to see the query: console Please point out my mistake. Answer You should change the property to

Using Java records as JPA embeddables

I want to use Java records as embeddable objects with JPA. For example I want to wrap the ID in a record to make it typesafe: But If I try to persist it with Hibernate 5.4.32 I get the following error: So it looks like Hibernate would treat the record Id like an entity, although it is an @Embeddable. The

Seeding Initial Data – Spring Boot with data.sql

data.sql is executed before JPA entities are created and it creates the error that the table is not found. can anyone help me with it? I have seen the same question in this link Spring Boot – Loading Initial Data but the question is not answered. Answer This is a normal and wanted behaviour from Springb…