org.springframework.dao.DataIntegrityViolationException: Could not read entity state from ResultSet : EntityKey[com.ledar.mono.domain.User#2]; SQL [n/a]; nested exception is org.hibernate.exception.DataException: Could not read entity state from ResultSet : EntityKey[com.ledar.mono.domain.User#2]
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:280)
at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:233)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:551)
at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:61)
at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:242)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:152)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor$CrudMethodMetadataPopulatingMethodInterceptor.invoke(CrudMethodMetadataPostProcessor.java:174)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
Caused by: java.sql.SQLDataException: Cannot determine value type from string 'NORMAL'
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:114)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:73)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:96)
at com.mysql.cj.jdbc.result.ResultSetImpl.getObject(ResultSetImpl.java:1431)
at com.mysql.cj.jdbc.result.ResultSetImpl.getInt(ResultSetImpl.java:830)
at com.mysql.cj.jdbc.result.ResultSetImpl.getInt(ResultSetImpl.java:851)
Solution: In fact, Could not read entity state from ResultSet : EntityKey[com.ledar.mono.domain.User#2];
, the meaning of this passage is that a certain field attribute of your entity class is inconsistent with the field attribute in the database table.
You need to check this class and the corresponding database.
After inspection, it is found that:
Pay attention to see that user_status
the field type is varchar
the corresponding attribute of the corresponding entity class is Status userStatus
the Status type, which is a custom Enumeration type. After running the project, the entity class will be automatically injected into the database, and the automatically generated type is also varchar. Why an error will be reported is puzzling. until you see it. Solution to the error
It turns out that I forgot to add @Enumerated(EnumType.STRING)
this statement. Make the entity class and the database table type userStatus inconsistent.
Add the following class attributes: