gpt4 book ai didi

java - 在 Spring Hibernate 中映射子类

转载 作者:行者123 更新时间:2023-12-01 11:10:31 25 4
gpt4 key购买 nike

我一直在尝试在我的新网络应用程序中执行登录过程,它曾经有效,但自从我创建了由 UserData 和 Profile 子类组成的 User 模型后,Tomcat 向我显示了一个未映射的 UserData :

Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: UserData is not mapped [from UserData u where u.username = :Username]

用户登录 DAO:

public UserData getUsername(String username) {
List<UserData> userList = new ArrayList<UserData>();
Query query = openSession().createQuery("from UserData u where u.username = :Username");
query.setParameter("Username", username);
userList = query.list();
if (userList.size() > 0)
return userList.get(0);
else
return null;
}

型号:

public class Usermanager {


@Entity
@Table(name="USER")
public class UserData implements Serializable {

@Id
@GeneratedValue(strategy=GenerationType.AUTO)
int iduser;
String username;
String password;
int idprofile;
int accountstatus;

public int getIduser() {
return iduser;
}
public void setIduser(int iduser) {
this.iduser = iduser;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public int getIdprofile() {
return idprofile;
}
public void setIdprofile(int idprofile) {
this.idprofile = idprofile;
}
public int getAccountstatus() {
return accountstatus;
}
public void setAccountstatus(int accountstatus) {
this.accountstatus = accountstatus;
}

}

@Entity
@Table(name="PROFILE")
public class Profile implements Serializable { ... }
}

完整的堆栈跟踪:

    sept. 07, 2015 6:53:07 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
AVERTISSEMENT: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:empsuite' did not find a matching property.
sept. 07, 2015 6:53:07 PM org.apache.catalina.startup.VersionLoggerListener log
INFOS: Server version: Apache Tomcat/8.0.20
sept. 07, 2015 6:53:07 PM org.apache.catalina.startup.VersionLoggerListener log
INFOS: Server built: Feb 15 2015 18:10:42 UTC
sept. 07, 2015 6:53:07 PM org.apache.catalina.startup.VersionLoggerListener log
INFOS: Server number: 8.0.20.0
sept. 07, 2015 6:53:07 PM org.apache.catalina.startup.VersionLoggerListener log
INFOS: OS Name: Windows 10
sept. 07, 2015 6:53:07 PM org.apache.catalina.startup.VersionLoggerListener log
INFOS: OS Version: 10.0
sept. 07, 2015 6:53:07 PM org.apache.catalina.startup.VersionLoggerListener log
INFOS: Architecture: amd64
sept. 07, 2015 6:53:07 PM org.apache.catalina.startup.VersionLoggerListener log
INFOS: Java Home: C:\Program Files\Java\jdk1.8.0_60\jre
sept. 07, 2015 6:53:07 PM org.apache.catalina.startup.VersionLoggerListener log
INFOS: JVM Version: 1.8.0_60-b27
sept. 07, 2015 6:53:07 PM org.apache.catalina.startup.VersionLoggerListener log
INFOS: JVM Vendor: Oracle Corporation
sept. 07, 2015 6:53:07 PM org.apache.catalina.startup.VersionLoggerListener log
INFOS: CATALINA_BASE: C:\Users\ceo\Desktop\BluePen Labs\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
sept. 07, 2015 6:53:07 PM org.apache.catalina.startup.VersionLoggerListener log
INFOS: CATALINA_HOME: C:\Program Files\Apache Software Foundation\Apache Tomcat 8.0.20
sept. 07, 2015 6:53:07 PM org.apache.catalina.startup.VersionLoggerListener log
INFOS: Command line argument: -Dcatalina.base=C:\Users\ceo\Desktop\BluePen Labs\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
sept. 07, 2015 6:53:07 PM org.apache.catalina.startup.VersionLoggerListener log
INFOS: Command line argument: -Dcatalina.home=C:\Program Files\Apache Software Foundation\Apache Tomcat 8.0.20
sept. 07, 2015 6:53:07 PM org.apache.catalina.startup.VersionLoggerListener log
INFOS: Command line argument: -Dwtp.deploy=C:\Users\ceo\Desktop\BluePen Labs\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
sept. 07, 2015 6:53:07 PM org.apache.catalina.startup.VersionLoggerListener log
INFOS: Command line argument: -Djava.endorsed.dirs=C:\Program Files\Apache Software Foundation\Apache Tomcat 8.0.20\endorsed
sept. 07, 2015 6:53:07 PM org.apache.catalina.startup.VersionLoggerListener log
INFOS: Command line argument: -Dfile.encoding=Cp1252
sept. 07, 2015 6:53:07 PM org.apache.catalina.core.AprLifecycleListener lifecycleEvent
INFOS: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.8.0_60\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre1.8.0_60/bin/server;C:/Program Files/Java/jre1.8.0_60/bin;C:/Program Files/Java/jre1.8.0_60/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files (x86)\Common Files\Acronis\SnapAPI\;C:\Program Files\Java\jdk1.8.0_60\bin;C:\Maven\bin;C:\eclipse;;.
sept. 07, 2015 6:53:09 PM org.apache.coyote.AbstractProtocol init
INFOS: Initializing ProtocolHandler ["http-nio-8080"]
sept. 07, 2015 6:53:09 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFOS: Using a shared selector for servlet write/read
sept. 07, 2015 6:53:09 PM org.apache.coyote.AbstractProtocol init
INFOS: Initializing ProtocolHandler ["ajp-nio-8009"]
sept. 07, 2015 6:53:09 PM org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
INFOS: Using a shared selector for servlet write/read
sept. 07, 2015 6:53:09 PM org.apache.catalina.startup.Catalina load
INFOS: Initialization processed in 4009 ms
sept. 07, 2015 6:53:09 PM org.apache.catalina.core.StandardService startInternal
INFOS: Démarrage du service Catalina
sept. 07, 2015 6:53:09 PM org.apache.catalina.core.StandardEngine startInternal
INFOS: Starting Servlet Engine: Apache Tomcat/8.0.20
sept. 07, 2015 6:53:11 PM org.apache.jasper.servlet.TldScanner scanJars
INFOS: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
sept. 07, 2015 6:53:12 PM org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom
INFOS: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [179] milliseconds.
sept. 07, 2015 6:53:25 PM org.apache.catalina.core.ApplicationContext log
INFOS: No Spring WebApplicationInitializer types detected on classpath
sept. 07, 2015 6:53:25 PM org.apache.catalina.core.ApplicationContext log
INFOS: Initializing Spring root WebApplicationContext
sept. 07, 2015 6:53:25 PM org.springframework.web.context.ContextLoader initWebApplicationContext
INFOS: Root WebApplicationContext: initialization started
sept. 07, 2015 6:53:26 PM org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh
INFOS: Refreshing Root WebApplicationContext: startup date [Mon Sep 07 18:53:26 WAT 2015]; root of context hierarchy
sept. 07, 2015 6:53:26 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFOS: Loading XML bean definitions from ServletContext resource [/WEB-INF/application-context.xml]
sept. 07, 2015 6:53:27 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFOS: Loading XML bean definitions from ServletContext resource [/WEB-INF/security-context.xml]
sept. 07, 2015 6:53:28 PM org.springframework.security.core.SpringSecurityCoreVersion performVersionChecks
INFOS: You are running with Spring Security Core 3.2.0.RELEASE
sept. 07, 2015 6:53:28 PM org.springframework.security.config.SecurityNamespaceHandler <init>
INFOS: Spring Security 'config' module version is 3.2.0.RELEASE
sept. 07, 2015 6:53:29 PM com.mchange.v2.log.MLog <clinit>
INFOS: MLog clients using java 1.4+ standard logging.
sept. 07, 2015 6:53:29 PM com.mchange.v2.c3p0.C3P0Registry banner
INFOS: Initializing c3p0-0.9.1.2 [built 21-May-2007 15:04:56; debug? true; trace: 10]
sept. 07, 2015 6:53:31 PM org.hibernate.annotations.common.Version <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
sept. 07, 2015 6:53:31 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.0.1.Final}
sept. 07, 2015 6:53:31 PM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
sept. 07, 2015 6:53:31 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
sept. 07, 2015 6:53:32 PM com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource getPoolManager
INFOS: Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 1hge1369b1aviaj8nw80g0|405f41fb, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> com.mysql.jdbc.Driver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge1369b1aviaj8nw80g0|405f41fb, idleConnectionTestPeriod -> 0, initialPoolSize -> 3, jdbcUrl -> jdbc:mysql://localhost/empsdb, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 0, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 2, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 1, numHelperThreads -> 3, numThreadsAwaitingCheckoutDefaultUser -> 0, preferredTestQuery -> null, properties -> {user=******, password=******}, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false ]
sept. 07, 2015 6:53:33 PM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
sept. 07, 2015 6:53:33 PM org.hibernate.engine.jdbc.internal.LobCreatorBuilder useContextualLobCreation
INFO: HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
sept. 07, 2015 6:53:33 PM org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService
INFO: HHH000399: Using default transaction strategy (direct JDBC transactions)
sept. 07, 2015 6:53:33 PM org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init>
INFO: HHH000397: Using ASTQueryTranslatorFactory
sept. 07, 2015 6:53:34 PM org.hibernate.tuple.PojoInstantiator <init>
INFO: HHH000182: No default (no-argument) constructor for class: empsuite.model.Usermanager$UserData (class must be instantiated by Interceptor)
sept. 07, 2015 6:53:34 PM org.hibernate.tuple.PojoInstantiator <init>
INFO: HHH000182: No default (no-argument) constructor for class: empsuite.model.Usermanager$Profile (class must be instantiated by Interceptor)
sept. 07, 2015 6:53:35 PM org.springframework.orm.hibernate4.HibernateTransactionManager afterPropertiesSet
INFOS: Using DataSource [com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, dataSourceName -> 1hge1369b1aviaj8nw80g0|405f41fb, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> com.mysql.jdbc.Driver, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge1369b1aviaj8nw80g0|405f41fb, idleConnectionTestPeriod -> 0, initialPoolSize -> 3, jdbcUrl -> jdbc:mysql://localhost/empsdb, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 0, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 2, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 1, numHelperThreads -> 3, numThreadsAwaitingCheckoutDefaultUser -> 0, preferredTestQuery -> null, properties -> {user=******, password=******}, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false ]] of Hibernate SessionFactory for HibernateTransactionManager
sept. 07, 2015 6:53:35 PM org.springframework.web.context.ContextLoader initWebApplicationContext
INFOS: Root WebApplicationContext: initialization completed in 10320 ms
sept. 07, 2015 6:53:35 PM com.sun.faces.config.ConfigureListener contextInitialized
INFOS: Initialisation de Mojarra 2.2.12 ( 20150720-0848 https://svn.java.net/svn/mojarra~svn/tags/2.2.12@14885) pour le contexte «/empsuite»
sept. 07, 2015 6:53:36 PM com.sun.faces.spi.InjectionProviderFactory createInstance
INFOS: JSF1048 : Présence d’annotations PostConstruct/PreDestroy Les méthodes de beans gérés marquées avec ces annotations auront des annotations dites traitées.
sept. 07, 2015 6:53:39 PM com.sun.faces.config.ConfigureListener$WebConfigResourceMonitor$Monitor <init>
INFOS: Monitoring file:/C:/Users/ceo/Desktop/BluePen%20Labs/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/empsuite/WEB-INF/faces-config.xml for modifications
sept. 07, 2015 6:53:39 PM org.primefaces.webapp.PostConstructApplicationEventListener processEvent
INFOS: Running on PrimeFaces 4.0
sept. 07, 2015 6:53:39 PM org.apache.coyote.AbstractProtocol start
INFOS: Starting ProtocolHandler ["http-nio-8080"]
sept. 07, 2015 6:53:39 PM org.apache.coyote.AbstractProtocol start
INFOS: Starting ProtocolHandler ["ajp-nio-8009"]
sept. 07, 2015 6:53:39 PM org.apache.catalina.startup.Catalina start
INFOS: Server startup in 29484 ms
sept. 07, 2015 6:53:44 PM com.sun.faces.context.SessionMap put
AVERTISSEMENT: JSF1063 : AVERTISSEMENT ! Définition d’une valeur d’attribut non-sérialisable dans HttpSession (clé : UserloginMB, classe de la valeur : empsuite.managedbean.UserloginManagedBean).
org.springframework.security.authentication.AuthenticationServiceException: UserData is not mapped [from UserData u where u.username = :Username]
at org.springframework.security.authentication.dao.DaoAuthenticationProvider.retrieveUser(DaoAuthenticationProvider.java:109)
at org.springframework.security.authentication.dao.AbstractUserDetailsAuthenticationProvider.authenticate(AbstractUserDetailsAuthenticationProvider.java:132)
at org.springframework.security.authentication.ProviderManager.authenticate(ProviderManager.java:156)
at empsuite.managedbean.UserloginManagedBean.login(UserloginManagedBean.java:25)
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:497)
at org.apache.el.parser.AstValue.invoke(AstValue.java:245)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:267)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
at org.springframework.faces.webflow.FlowActionListener.processAction(FlowActionListener.java:71)
at org.springframework.faces.model.SelectionTrackingActionListener.processAction(SelectionTrackingActionListener.java:64)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:658)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:516)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1086)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:659)
at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:223)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1558)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1515)
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)
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: UserData is not mapped [from UserData u where u.username = :Username]
at org.hibernate.hql.internal.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:180)
at org.hibernate.hql.internal.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:110)
at org.hibernate.hql.internal.ast.tree.FromClause.addFromElement(FromClause.java:93)
at org.hibernate.hql.internal.ast.HqlSqlWalker.createFromElement(HqlSqlWalker.java:326)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElement(HqlSqlBaseWalker.java:3252)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromElementList(HqlSqlBaseWalker.java:3141)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.fromClause(HqlSqlBaseWalker.java:694)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:550)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.selectStatement(HqlSqlBaseWalker.java:287)
at org.hibernate.hql.internal.antlr.HqlSqlBaseWalker.statement(HqlSqlBaseWalker.java:235)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:248)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:183)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:101)
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:119)
at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:214)
at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:192)
at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1537)
at empsuite.dao.UserloginDAOImpl.getUsername(UserloginDAOImpl.java:24)
at empsuite.service.UserloginService.loadUserByUsername(UserloginService.java:20)
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:497)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:302)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:99)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:281)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
at com.sun.proxy.$Proxy24.loadUserByUsername(Unknown Source)
at org.springframework.security.authentication.dao.DaoAuthenticationProvider.retrieveUser(DaoAuthenticationProvider.java:101)
... 43 more

最佳答案

你所做的不是子类,而是内部类。我不完全确定你计划在你自己的类之间建立什么关系,但是 UserManager.java 文件不应包含您的实体的定义。

  • 如果你想扩展 UserManager(看起来不是一个好的解决方案,但仍然如此):你需要一个 UserManager.java 和另外两个用于你的实体的 .java 文件,它们都标记为“extends Usermanager”并且带有@Entity注释。

  • 如果您希望 UserManager 类包含这些元素,只需简单地声明两个具有这些类型的变量并使用 @Entity 注释创建另外两个 java 类即可。

关于java - 在 Spring Hibernate 中映射子类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32443404/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com