I keep getting SQLGrammarException error, I could not find any syntax error from my code. Here is my controller, entity, DAO and JSP file code. Maybe my form tag in addProduct.jsp is wrong, but I could not find the solution. HomeController.java ProductDAOImpl.java Top.java addProduct.jsp Answer Analysis It looks like some names used in the database context (a table name, a
Tag: hibernate
A bean named ‘entityManagerFactory’ that could not be found
I’m pretty new to Hibernate/JPA. Running the application, I’m getting this error: The main class (I use @EnableJpaRepositories to let Spring find the repository in other package): My main entity class: A repository: A properties file: Maven dependencies: What should I do here? Answer I solved this adding the following dependency instead of spring-data-jpa: After that, I got this exception:
Best way to save and update entity Parent and child using spring data jpa
I’m facing some behaviour about spring data jpa and I need to understand. consider this : Document Template Service First => I created the template And When I created a new document for instance with this data configuration I’m getting this error detached entity passed to persist. So to resolve this error I put CASCADE Merge instead ALL on Parent
Exclude fields from Java object using Spring
I have two endpoint who use the same model class (Cars). For the searchBigList endpoint I would like to retrieve all car fields and for searchCarSmallList endpoint I would like to retrieve just 3 fields. I tried to do it with @JsonView annotation but it was not working for me. Anyone have better idea how to do it? Answer I
Hibernate: How to distinguish two uni-directional relationship and one bi-directional relationship?
in this answer, the author said: Take an example of two entities mapped without declaring a owning side: From a OO point of view this mapping defines not one bi-directional relation, but two separate uni-directional relations. 1.My first question is: Why it is not a bi-directional relation? Docs Oracle: In a bidirectional relationship, each entity has a relationship field or
What is difference between transient state and removed state in JPA?
I have a question about entity states in JPA. I’ve read some article about entity states in jpa and my understanding about them is that: a transient object is a newly created object that hasn’t been associated with Persistence Context and does not represent a record in database. and when we remove an object, it doesn’t have any association with
DuplicateMappingException contains physical column name referred to by multiple logical column names on adding passportId to the Student entity
This code is causing the following exception on the startup I’m using H2 in-memory database. Student entity: Passport entity: Question 1: What is the reason for org.hibernate.DuplicateMappingException? Question 2: Why does adding the following annotation to passportId in the Student entity resolve the issue? PS: I know similar questions has been asked earlier but I couldn’t understand the answer for
JPA Using Composite Fields To Store Multiple @Column On An @Entity
I have a user table and I am using Hibernate to read it into User instances. I want to collect a number of related columns under a composite object to pass it around. So, I want to do something like this: Now I want to read some of the columns in the same user table into the fields in my
Convert String to Money Thymeleaf
I am having a problem converting input String to money. I am creating a spring boot application with thymeleaf. I have a web page where user inputs the data and there is a particular field where he inputs the String and it needs to be converted to type joda.money as in my pojo class that field has money data type.
Spring JPA/Hibernate – OneToMany bi-directional problem
I’ve encountered this problem that won’t let me sleep I have 2 entities Property and Tenant each property can have 0..1 tenant, each tenant can have 1..N properties what am I trying to accomplish is when I create a new tenant, using cascading I want to attach it to an existing property saving is done via JpaRepository.save(Tenant) for example first