我正在尝试从eclipse到postgresql的连接(pg Admin III)。我遇到了以下错误。
我也试过了每个stackoverflow链接和其他链接。他们中的很多人都表示"因为你使用的是@GeneratedValue()"。
我有两个表名"用户"和" Userrole"在postgresql和myhibernate.cfg.xml中是: -
<property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property> <property name="connection.driver_class">org.postgresql.Driver</property> <property name="connection.url">jdbc:postgresql://localhost:5432/shiroexample</property> <property name="connection.username">postgres</property> <property name="connection.password">root</property> <property name="connection.autoReconnect">true</property> <property name="cache.provider_class">org.hibernate.cache.HashtableCacheProvider</property> <property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property> <property name="current_session_context_class">thread</property> <property name="hibernate.show_sql">false</property> <mapping class="com.jjoe64.shiroexample.models.User"></mapping> <mapping class="com.jjoe64.shiroexample.models.UserRole"></mapping> <mapping class="com.jjoe64.shiroexample.models.RolesPermission"></mapping> </session-factory>
运行时出错。我正在使用Tomcat服务器
> HTTP Status 500 - Filtered request failed.
>
> --------------------------------------------------------------------------------
>
> type Exception report
>
> message Filtered request failed.
>
> description The server encountered an internal error that prevented it from fulfilling this request.
>
> exception
>
> javax.servlet.ServletException: Filtered request failed.
> org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:384)
> org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
>
>
> root cause
>
> org.hibernate.exception.SQLGrammarException: could not extract ResultSet
> org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:123)
> org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)
> org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
> org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)
> org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:88)
> org.hibernate.id.SequenceGenerator.generateHolder(SequenceGenerator.java:122)
> org.hibernate.id.SequenceGenerator.generate(SequenceGenerator.java:115)
> org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:117)
> org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:206)
> org.hibernate.event.internal.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:55)
> org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:191)
> org.hibernate.event.internal.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:49)
> org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:90)
> org.hibernate.internal.SessionImpl.fireSave(SessionImpl.java:683)
> org.hibernate.internal.SessionImpl.save(SessionImpl.java:675)
> org.hibernate.internal.SessionImpl.save(SessionImpl.java:671)
> com.jjoe64.shiroexample.RegisterServlet.registrate(RegisterServlet.java:102)
> com.jjoe64.shiroexample.RegisterServlet.doPost(RegisterServlet.java:65)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
> org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
> org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
> org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
> org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
> org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
> org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
> org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
> org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
>
>
> root cause
>
> org.postgresql.util.PSQLException: ERROR: relation "hibernate_sequence" does not exist
> Position: 17
> org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2453)
> org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2153)
> org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:286)
> org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:432)
> org.postgresql.jdbc.PgStatement.execute(PgStatement.java:358)
> org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:171)
> org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:119)
> org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:79)
> org.hibernate.id.SequenceGenerator.generateHolder(SequenceGenerator.java:122)
> org.hibernate.id.SequenceGenerator.generate(SequenceGenerator.java:115)
> org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:117)
> org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:206)
> org.hibernate.event.internal.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:55)
> org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:191)
> org.hibernate.event.internal.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:49)
> org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:90)
> org.hibernate.internal.SessionImpl.fireSave(SessionImpl.java:683)
> org.hibernate.internal.SessionImpl.save(SessionImpl.java:675)
> org.hibernate.internal.SessionImpl.save(SessionImpl.java:671)
> com.jjoe64.shiroexample.RegisterServlet.registrate(RegisterServlet.java:102)
> com.jjoe64.shiroexample.RegisterServlet.doPost(RegisterServlet.java:65)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
> javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
> org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
> org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
> org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
> org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
> org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
> org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
> org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
> org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
>
>
> note The full stack trace of the root cause is available in the Apache Tomcat/7.0.69 logs.
>
>
> --------------------------------------------------------------------------------
>
> Apache Tomcat/7.0.69
最初,我认为User是保留关键字,但后来我使用User with&#34; User \&#34;但对我来说没什么用。
如果有人可以帮助我...... !!
答案 0 :(得分:0)
设置您可以看到here
的序列名称我希望这对你有所帮助。