I am trying to create a spring application that allows user to register an account. This involves submitting data to a controller which passes data to a service which calls my DAO. This is my first Spring application ever and I have been following a bunch of different guides to get my application where it is.
So my problem arose when I added the request scope to my beans. I added request scope to the service and models beans since the singleton scope was leaving data in my object across different http requests. So when I run my application and send data to my controllers I don't get any console errors, but my application doesn't do anything. When I debugged I notice that I get this error when the DAO tries to insert the user object "org.hibernate.MappingException: Unknown entity: com.nvc.slink.model.User$$EnhancerBySpringCGLIB$$6c38e058" When I looked into my user object when I got this error I noticed that it had weird member variables:
org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor@5ced77ee
org.springframework.aop.framework.CglibAopProxy$DynamicUnadvisedInterceptor@40464597
org.springframework.aop.framework.CglibAopProxy$SerializableNoOp@21df885d
org.springframework.aop.framework.CglibAopProxy$SerializableNoOp@5c608df2
org.springframework.aop.framework.CglibAopProxy$AdvisedDispatcher@6b85c397
org.springframework.aop.framework.CglibAopProxy$EqualsInterceptor@191d598d
org.springframework.aop.framework.CglibAopProxy$HashCodeInterceptor@445db793
I'm assuming this is directly related to my addition of the request scope to my beans which also leads me to believe I dun messed up. I have been trying to fix this problem for a week now and feel like i've read every stackoverflow question related to my problem, but with no luck in solving issue.
Here are some relevant source files (I did blot out some of the package names deliberately.)
My configurations:
My java run class.
//Application.java
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.boot.SpringApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@Configuration
@ComponentScan
@EnableTransactionManagement
@EnableAutoConfiguration
public class Application extends SpringBootServletInitializer{
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(applicationClass);
}
private static Class<Application> applicationClass = Application.class;
}
Hibernate related Beans
//HibernateConfig.java
import java.util.Properties;
import javax.sql.DataSource;
import org.apache.tomcat.dbcp.dbcp.BasicDataSource;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
import org.springframework.orm.hibernate4.HibernateTransactionManager;
import org.springframework.orm.hibernate4.LocalSessionFactoryBean;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import com.google.common.base.Preconditions;
@Configuration
@EnableTransactionManagement
@PropertySource({ "classpath:hibernate.properties" })
@ComponentScan({ "xx.xxx.xxxx" })
public class HibernateConfig {
@Autowired
private Environment env;
public HibernateConfig() {
super();
}
@Bean
public LocalSessionFactoryBean sessionFactory() {
final LocalSessionFactoryBean sessionFactory = new LocalSessionFactoryBean();
sessionFactory.setDataSource(restDataSource());
sessionFactory.setPackagesToScan(new String[] { "com.nvc.slink.model" });
sessionFactory.setHibernateProperties(hibernateProperties());
return sessionFactory;
}
@Bean
public DataSource restDataSource() {
final BasicDataSource dataSource = new BasicDataSource();
dataSource.setDriverClassName(Preconditions.checkNotNull(env.getProperty("jdbc.driverClassName")));
dataSource.setUrl(Preconditions.checkNotNull(env.getProperty("jdbc.url")));
dataSource.setUsername(Preconditions.checkNotNull(env.getProperty("jdbc.user")));
dataSource.setPassword(Preconditions.checkNotNull(env.getProperty("jdbc.pass")));
return dataSource;
}
@Bean
@Autowired
public HibernateTransactionManager transactionManager(final SessionFactory sessionFactory) {
final HibernateTransactionManager txManager = new HibernateTransactionManager();
txManager.setSessionFactory(sessionFactory);
return txManager;
}
@Bean
public PersistenceExceptionTranslationPostProcessor exceptionTranslation() {
return new PersistenceExceptionTranslationPostProcessor();
}
final Properties hibernateProperties() {
final Properties hibernateProperties = new Properties();
hibernateProperties.setProperty("hibernate.hbm2ddl.auto", env.getProperty("hibernate.hbm2ddl.auto"));
hibernateProperties.setProperty("hibernate.dialect", env.getProperty("hibernate.dialect"));
hibernateProperties.setProperty("hibernate.show_sql", "true");
// hibernateProperties.setProperty("hibernate.format_sql", "true");
// hibernateProperties.setProperty("hibernate.globally_quoted_identifiers", "true");
return hibernateProperties;
}
}
Model beans
import java.util.Date;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import com.nvc.slink.model.User;
import com.nvc.slink.model.Userauthentication;
@Configuration
@ComponentScan({ "XX.XXX.XXXX" })
public class ModelConfig {
@Bean
@Scope(value = "request", proxyMode = ScopedProxyMode.TARGET_CLASS)
public User user(){
Date d = new Date();
User u = new User();
u.setULastactive(d);
return u;
}
@Bean
@Scope(value = "request", proxyMode = ScopedProxyMode.TARGET_CLASS)
public Userauthentication userauthentication(){
Userauthentication ua = new Userauthentication();
return ua;
}
}
Service Beans
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import com.nvc.slink.service.RegisterServiceImpl;
import com.nvc.slink.service.UserServiceImpl;
@Configuration
@ComponentScan({ "XX.XXX.XXXX" })
public class ServiceConfig {
@Bean
@Scope(value = "request", proxyMode = ScopedProxyMode.TARGET_CLASS)
public UserServiceImpl userService(){
return new UserServiceImpl();
}
@Bean
@Scope(value = "request", proxyMode = ScopedProxyMode.TARGET_CLASS)
public RegisterServiceImpl registerService(){
return new RegisterServiceImpl();
}
}
DAO beans
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import com.nvc.slink.dao.RegisterDaoImpl;
import com.nvc.slink.dao.UserDaoImpl;
@Configuration
@ComponentScan({ "XX.XXX.XXXX" })
public class DaoConfig {
@Bean
public UserDaoImpl userDao(){
return new UserDaoImpl();
}
@Bean
public RegisterDaoImpl registerDao(){
return new RegisterDaoImpl();
}
}
User Registration Controller
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.nvc.slink.service.IRegisterService;
import com.nvc.slink.transfermodels.UserTO;
@RestController
public class RegisterController {
@Autowired
private IRegisterService registerService;
/*
@Autowired
private IUserService userService;
@RequestMapping("/name/{name}")
public String greeting(@PathVariable String name) {
return name;
}
@RequestMapping("/all")
public List<User> index() {
return userService.getAllUsers();
}*/
@RequestMapping(value= "/register", method = RequestMethod.POST)
public Object register(@Valid @RequestBody UserTO user,BindingResult result){ //Make into register Object
if (result.hasErrors()) {
return result.getAllErrors();
}
return registerService.register(user);
}
}
Register Service implementation
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.encrypt.Encryptors;
import org.springframework.security.crypto.encrypt.TextEncryptor;
import org.springframework.security.crypto.keygen.KeyGenerators;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.nvc.slink.dao.IRegisterDao;
import com.nvc.slink.model.User;
import com.nvc.slink.model.Userauthentication;
import com.nvc.slink.transfermodels.UserTO;
import com.nvc.slink.transfermodels.UserauthenticationTO;
@Service
@Transactional
public class RegisterServiceImpl implements IRegisterService {
@Autowired
private IRegisterDao registerDao;
@Autowired
private User user;
@Autowired
private Userauthentication userauthentication;
@Override
public void encryptUA(Userauthentication unencrypted) {
String salt = KeyGenerators.string().generateKey();
TextEncryptor encrypter = Encryptors.text("password", salt);
// TODO Create secure encryption password
String encrypted = encrypter.encrypt(unencrypted.getUaPassword());
unencrypted.setUaPassword(encrypted);
unencrypted.setUaSalt(salt);
}
@Override
public User createNewUser(User u) {
try {
registerDao.insertUser(u);
return u;
} catch (Exception e) {
return null;
}
}
@Override
public User register(UserTO uTO) {
UserauthenticationTO uaTO = uTO.getUserauthentication();
userauthentication.setUaPassword(uaTO.getPassword());
user.setUserauthentication(userauthentication);
user.setUEmail(uTO.getEmail());
user.setUUsername(uTO.getUsername());
this.encryptUA(userauthentication);
return this.createNewUser(user);
}
}
User Model
// Generated Dec 29, 2014 7:43:39 PM by Hibernate Tools 4.3.1
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
/**
* User generated by hbm2java
*/
@Entity
@Table(name = "user", catalog = "slinkdb", uniqueConstraints = {
@UniqueConstraint(columnNames = "u_iduserauthentication"),
@UniqueConstraint(columnNames = "u_email"),
@UniqueConstraint(columnNames = "u_username") })
public class User implements java.io.Serializable {
private Integer iduser;
private Userauthentication userauthentication;
private String UEmail;
private String UImgsrc;
private Date ULastactive;
private boolean UPrivate = false;
private String UUsername;
private Set<UserCode> userCodes = new HashSet<UserCode>(0);
private Set<UserDefault> userDefaults = new HashSet<UserDefault>(0);
private Set<Gateway> gateways = new HashSet<Gateway>(0);
public User() {
}
public User(String UEmail, boolean UPrivate) {
this.UEmail = UEmail;
this.UPrivate = UPrivate;
}
public User(Userauthentication userauthentication, String UEmail,
String UImgsrc, Date ULastactive, boolean UPrivate,
String UUsername, Set<UserCode> userCodes,
Set<UserDefault> userDefaults, Set<Gateway> gateways) {
this.userauthentication = userauthentication;
this.UEmail = UEmail;
this.UImgsrc = UImgsrc;
this.ULastactive = ULastactive;
this.UPrivate = UPrivate;
this.UUsername = UUsername;
this.userCodes = userCodes;
this.userDefaults = userDefaults;
this.gateways = gateways;
}
@Id
@GeneratedValue(strategy = IDENTITY)
@Column(name = "iduser", unique = true, nullable = false)
public Integer getIduser() {
return this.iduser;
}
public void setIduser(Integer iduser) {
this.iduser = iduser;
}
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "u_iduserauthentication", unique = true)
@Cascade(CascadeType.ALL)
public Userauthentication getUserauthentication() {
return this.userauthentication;
}
public void setUserauthentication(Userauthentication userauthentication) {
this.userauthentication = userauthentication;
}
@Column(name = "u_email", unique = true, nullable = false, length = 100)
public String getUEmail() {
return this.UEmail;
}
public void setUEmail(String UEmail) {
this.UEmail = UEmail;
}
@Column(name = "u_imgsrc", length = 45)
public String getUImgsrc() {
return this.UImgsrc;
}
public void setUImgsrc(String UImgsrc) {
this.UImgsrc = UImgsrc;
}
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "u_lastactive", length = 19)
public Date getULastactive() {
return this.ULastactive;
}
public void setULastactive(Date ULastactive) {
this.ULastactive = ULastactive;
}
@Column(name = "u_private", nullable = false)
public boolean isUPrivate() {
return this.UPrivate;
}
public void setUPrivate(boolean UPrivate) {
this.UPrivate = UPrivate;
}
@Column(name = "u_username", unique = true, length = 45)
public String getUUsername() {
return this.UUsername;
}
public void setUUsername(String UUsername) {
this.UUsername = UUsername;
}
@OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
public Set<UserCode> getUserCodes() {
return this.userCodes;
}
public void setUserCodes(Set<UserCode> userCodes) {
this.userCodes = userCodes;
}
@OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
public Set<UserDefault> getUserDefaults() {
return this.userDefaults;
}
public void setUserDefaults(Set<UserDefault> userDefaults) {
this.userDefaults = userDefaults;
}
@OneToMany(fetch = FetchType.LAZY, mappedBy = "user")
public Set<Gateway> getGateways() {
return this.gateways;
}
public void setGateways(Set<Gateway> gateways) {
this.gateways = gateways;
}
}
User DAO
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import com.nvc.slink.model.User;
@Repository
public class RegisterDaoImpl implements IRegisterDao {
@Autowired
private SessionFactory sessionFactory;
@Override
public User insertUser(User u) throws Exception {
try{
Session session = sessionFactory.getCurrentSession();
session.save(u);
return u;
}catch(Exception e){ //Could not insert user;
throw new Exception();
}
}
}
Full stack trace added at DAO level where error occurs.
org.hibernate.MappingException: Unknown entity: com.nvc.slink.model.User$$EnhancerBySpringCGLIB$$332d007d
at org.hibernate.internal.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:1096)
at org.hibernate.internal.SessionImpl.getEntityPersister(SessionImpl.java:1443)
at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:116)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:209)
at org.hibernate.event.internal.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:55)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:194)
at org.hibernate.event.internal.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:49)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:90)
at org.hibernate.internal.SessionImpl.fireSave(SessionImpl.java:715)
at org.hibernate.internal.SessionImpl.save(SessionImpl.java:707)
at org.hibernate.internal.SessionImpl.save(SessionImpl.java:702)
at com.nvc.slink.dao.RegisterDaoImpl.insertUser(RegisterDaoImpl.java:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:136)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
at com.sun.proxy.$Proxy61.insertUser(Unknown Source)
at com.nvc.slink.service.RegisterServiceImpl.createNewUser(RegisterServiceImpl.java:43)
at com.nvc.slink.service.RegisterServiceImpl.register(RegisterServiceImpl.java:58)
at com.nvc.slink.service.RegisterServiceImpl$$FastClassBySpringCGLIB$$8757c338.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:708)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:644)
at com.nvc.slink.service.RegisterServiceImpl$$EnhancerBySpringCGLIB$$ce76b984.register(<generated>)
at com.nvc.slink.service.RegisterServiceImpl$$FastClassBySpringCGLIB$$8757c338.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:708)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:133)
at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:121)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:644)
at com.nvc.slink.service.RegisterServiceImpl$$EnhancerBySpringCGLIB$$d399c44.register(<generated>)
at com.nvc.slink.controller.RegisterController.register(RegisterController.java:42)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:749)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:689)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:938)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:863)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1736)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1695)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
You are autowiring User entity ( @Autowired private User user ) which is converted to CGLibProxy. Then you want to save such CGLib enhanced proxy to the database and so it fails since Hibernate knows nothing about class User$$EnhancerBySpringCGLIB$$332d007d.
Why are you using User entity in such a way ?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.