Spring Boot: Exception Stack
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception
[Request processing failed: org.springframework.orm.jpa.JpaSystemException:
No default constructor for entity: : com.example.redisdemo.DbUser] with root cause
org.hibernate.InstantiationException: No default constructor for entity: : com.example.springboot.User
at org.hibernate.metamodel.internal.EntityInstantiatorPojoStandard.instantiate(EntityInstantiatorPojoStandard.java:101)
~[hibernate-core-6.1.7.Final.jar:6.1.7.Final]
at org.hibernate.persister.entity.AbstractEntityPersister.instantiate(AbstractEntityPersister.java:5288)
~[hibernate-core-6.1.7.Final.jar:6.1.7.Final]
The above exception is what you get when you do not have a default constructor not been defined in your Entity/POJO class when working with Spring Data JPA.
Fix:
To fix this issue, you need to simply define a default constructor in your class that gave the exception.
@Entity
public class User implements Serializable {
private static final long serialVersionUID = 1L;
public DbUser(int userId, String userName) {
this.userId = userId;
this.userName = userName;
}
//Default Constructor Added
public DbUser() {
}
@Id
private int userId;
@Column
private String userName;
...
...

Have Questions? Post them here!
- Create a Zip file using Java Code programmatically
- Eclipse : A java Runtime Environment (JRE) or Java Development kit (JDK) must be available
- How to Sort a LinkedList in Java
- Loading class com.mysql.jdbc.Driver. This is deprecated. The new driver class is com.mysql.cj.jdbc.Driver
- How to declare and initialize Array in Java Programming
- [Fix] java: integer number too large compilation error
- Java JDBC Connection with MySQL Driver in VS Code + Troubleshooting
- Reading .xls and .xlsx Excel file using Apache POI Java Library
- IntelliJ: Error: Could not find or load main class, java.lang.ClassNotFoundException
- How to get Client IP address using Java Code Example
- Truncate table using Java JDBC Example
- Struts 2 : There is no Action mapped for namespace [/] and action name [form] associated with context path [/proj]
- How to get file path in Idea IntelliJ IDE
- Java Generics explained with simple definition and examples
- Java SE 8 Update 301 available with various bug fixes and security improvements
- Java: Collect Stream as ArrayList or LinkedList
- Java JDBC Connection with PostgreSQL Driver Example
- How to check if Java main thread is alive
- How to fix Java nio NoSuchFileException wile reading a file
- Java 8+ get Day of the Week Examples with LocalDateTime, DateTime, ZonalDateTime and Instant classes
- Ways to Convert Integer or int to Long in Java
- [Java] How to throws Exception using Functional Interface and Lambda code
- [Fix] Spring Boot: mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
- Java: The value of the local variable string is not used
- Java JDBC: Insert Java 8 LocalDate and Time using PreparedStatement
- How to Upload a File to Google Colab (txt, csv, json, xml, xlsx) - Google
- Send Email using SharePoint PowerShell command, SMTP server - SharePoint
- How to check if a String contains substring or a word using javaScript - JavaScript
- Open Current Directory in Finder using Mac Terminal - MacOS
- How to remove blank lines from a file using Notepad++ - NotepadPlusPlus
- Find and Replace Multiple different words with the same word in a text file - NotepadPlusPlus
- ADT Installation Error: requires plug-in org.eclipse.wst.sse.ui - Android
- How to open a file via Mac Terminal - MacOS