我将自己的3张表分别为sys_operator(对应为user),sys_role(对应为role),sys_operator_role 为二者的多对多关系 ,还有同样的 sys_resource(对应的resource) 及sys_role_resource(角色和资源的多对多关系表)。 以角色和用户为例来说明:
koala-security中的user对象现在变为:
@Entity
@Table(name = "SYS_OPERATOR")
public class User extends CopyOfIdentity {...//做了列和属性的对应}
@MappedSuperclass
public abstract class CopyOfIdentity extends Party {}
@MappedSuperclass
public abstract class Party extends TimeIntervalEntity {}
@MappedSuperclass
public abstract class TimeIntervalEntity extends KoalaSecurityEntity {
private static final long serialVersionUID = 858481853210607590L;
@Column(name = "CREATE_TIME", nullable = false)
@Temporal(TemporalType.TIMESTAMP)
@NotNull(message = "createDate.is.null")
private Date createDate;
@Column(name = "ABOLISH_DATE", nullable = false)
@Temporal(TemporalType.TIMESTAMP)
@NotNull(message = "abolishDate.is.null")
private Date abolishDate;
......}
现在maven build之后,jetty启动koala-security-web-mvc 可以看到登录界面
输入sys_operator 中的不存在的用户名 aaaa 登录 提示用户名错误
输入sys_operator 中已存在的账户和正确的密码 跳转到404
输出错误:
8:06:07,964 DEBUG [Loader] Result row: EntityKey[org.openkoala.koala.auth.core.domain.User#1]
18:06:07,964 DEBUG [SqlExceptionHelper] Value '100000-00-00 00:00:002013-04-12 16:55:38���1Y�00000-00-00 00:00:00�aaa测试帐号(aaa),1yidogQaod+v5ZwOqH3RBjoeGqpDvaXH1woy1SJaELE=
java.sql.SQLException: Value '100000-00-00 00:00:002013-04-12 16:55:38���1Y�00000-00-00 00:00:00�aaa测试帐号(aaa),1yidogQaod+v5ZwOqH3RBjoeGqpDvaXH1woy1SJaELE=
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1074)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:988)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:974)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:919)
at com.mysql.jdbc.ResultSetRow.getTimestampFast(ResultSetRow.java:1061)
at com.mysql.jdbc.BufferRow.getTimestampFast(BufferRow.java:576)
at com.mysql.jdbc.ResultSetImpl.getTimestampInternal(ResultSetImpl.java:6591)
at com.mysql.jdbc.ResultSetImpl.getTimestamp(ResultSetImpl.java:6191)
at com.mysql.jdbc.ResultSetImpl.getTimestamp(ResultSetImpl.java:6229)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.hibernate.engine.jdbc.internal.proxy.AbstractResultSetProxyHandler.continueInvocation(AbstractResultSetProxyHandler.java:104)
at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
at $Proxy56.getTimestamp(Unknown Source)
at org.hibernate.type.descriptor.sql.TimestampTypeDescriptor$2.doExtract(TimestampTypeDescriptor.java:67)
at org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:65)
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:269)
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:265)
at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:238)
at org.hibernate.type.AbstractStandardBasicType.hydrate(AbstractStandardBasicType.java:357)
at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2807)
at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1545)
at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1477)
at org.hibernate.loader.Loader.getRow(Loader.java:1377)
at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:644)
at org.hibernate.loader.Loader.doQuery(Loader.java:854)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:293)
at org.hibernate.loader.Loader.doList(Loader.java:2382)
at org.hibernate.loader.Loader.doList(Loader.java:2368)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2198)
at org.hibernate.loader.Loader.list(Loader.java:2193)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:470)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:355)
at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:195)
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1244)
at org.hibernate.internal.QueryImpl.list(QueryImpl.java:101)
at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:285)
at org.openkoala.koala.util.KoalaEntityRepositoryJpa.getSingleResult(KoalaEntityRepositoryJpa.java:195)
at org.openkoala.koala.auth.core.domain.User.findByUserAccount(User.java:159)
at org.openkoala.application.impl.UserApplicationImpl.findByUserAccount(UserApplicationImpl.java:135)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy49.findByUserAccount(Unknown Source)
at org.openkoala.koala.auth.ss3adapter.auth.handler.SS3AuthHandler.authenticate(SS3AuthHandler.java:37)
at org.openkoala.koala.auth.ss3adapter.provider.LoginAuthenticationProvider.authenticate(LoginAuthenticationProvider.java:58)
at org.springframework.security.authentication.ProviderManager.authenticate(ProviderManager.java:156)
at org.openkoala.koala.auth.ss3adapter.filter.AuthenticationFilter.attemptAuthentication(AuthenticationFilter.java:88)
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:211)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:343)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:260)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1474)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:499)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:137)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:557)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:231)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:428)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:193)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:255)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)
at org.eclipse.jetty.server.Server.handle(Server.java:370)
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:489)
at org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:960)
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:1021)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:865)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:82)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:668)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:52)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)
at java.lang.Thread.run(Thread.java:722)
18:06:07,965 WARN [SqlExceptionHelper] SQL Error: 0, SQLState: S1009
18:06:07,965 ERROR [SqlExceptionHelper] Value '100000-00-00 00:00:002013-04-12 16:55:38���1Y�00000-00-00 00:00:00�aaa测试帐号(王二),1yidogQaod+v5ZwOqH3RBjoeGqpDvaXH1woy1SJaELE=
将自己的sys_operator表映射为koala 中的user 报错
查看全异常,发现最终的错误是cannotberepresentedasjava.sql.Timestamp,这个错可能是数据中的数据不是日期,但实体中又使用了@Timestamp导致的
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。