2012-08-22 110 views
1

我有基於Spring-MVC的Web應用程序。我已經將它與Hibernate 3.6.0集成。 當我試圖挽救實體命名的用戶,我得到:Hibernate + HSQLDB架構未導出

org.hsqldb.HsqlException:用戶缺少特權或找不到對象: USER

我想通了,沒有表USER在數據庫中,但爲什麼? 我的配置文件,對彈簧的ServletDispatcher片段:

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> 
     <property name="driverClassName" value="org.hsqldb.jdbcDriver"></property> 
     <property name="url" value="jdbc:hsqldb:file: db/autostop; shutdown=true"></property> 
     <property name="username" value="SA"></property> 
     <property name="password" value=""></property> 
    </bean> 
    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> 
     <property name="dataSource" ref="dataSource"/> 
     <property name="packagesToScan" value="prv.bladositto.autostop.persistance.hibernate.model"/> 
     <property name="hibernateProperties"> 
      <props> 
       <prop key="dialect">org.hibernate.dialect.HSQLDialect</prop> 
       <prop key="show_sql">true</prop> 
       <prop key="hbm2ddl.auto">create-drop</prop> 
      </props> 
     </property> 
    </bean> 

根異常堆棧跟蹤:

org.hsqldb.HsqlException: user lacks privilege or object not found: USER 
    org.hsqldb.error.Error.error(Unknown Source) 
    org.hsqldb.error.Error.error(Unknown Source) 
    org.hsqldb.SchemaManager.getTable(Unknown Source) 
    org.hsqldb.ParserDQL.readTableName(Unknown Source) 
    org.hsqldb.ParserDQL.readSimpleRangeVariable(Unknown Source) 
    org.hsqldb.ParserDML.compileInsertStatement(Unknown Source) 
    org.hsqldb.ParserCommand.compilePart(Unknown Source) 
    org.hsqldb.ParserCommand.compileStatement(Unknown Source) 
    org.hsqldb.Session.compileStatement(Unknown Source) 
    org.hsqldb.StatementManager.compile(Unknown Source) 
    org.hsqldb.Session.execute(Unknown Source) 
    org.hsqldb.jdbc.JDBCPreparedStatement.<init>(Unknown Source) 
    org.hsqldb.jdbc.JDBCConnection.prepareStatement(Unknown Source) 
    org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:524) 
    org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:116) 
    org.hibernate.id.IdentityGenerator$GetGeneratedKeysDelegate.prepare(IdentityGenerator.java:90) 
    org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:54) 
    org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2327) 
    org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2834) 
    org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:71) 
    org.hibernate.engine.ActionQueue.execute(ActionQueue.java:273) 
    org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:320) 
    org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:203) 
    org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:129) 
    org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:210) 
    org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:56) 
    org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:195) 
    org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:50) 
    org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:93) 
    org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:713) 
    org.hibernate.impl.SessionImpl.save(SessionImpl.java:701) 
    org.hibernate.impl.SessionImpl.save(SessionImpl.java:697) 
    org.springframework.orm.hibernate3.HibernateTemplate$12.doInHibernate(HibernateTemplate.java:686) 
    org.springframework.orm.hibernate3.HibernateTemplate$12.doInHibernate(HibernateTemplate.java:1) 
    org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:406) 
    org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374) 
    org.springframework.orm.hibernate3.HibernateTemplate.save(HibernateTemplate.java:683) 
    prv.bladositto.autostop.persistance.hibernate.UserServiceImpl.save(UserServiceImpl.java:23) 
    prv.bladositto.autostop.controllers.UsersController.createUser(UsersController.java:40) 
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    java.lang.reflect.Method.invoke(Method.java:601) 
    org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213) 
    org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126) 
    org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96) 
    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617) 
    org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578) 
    org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80) 
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923) 
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852) 
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882) 
    org.springframework.web.servlet.FrameworkServlet.doPut(FrameworkServlet.java:800) 
    javax.servlet.http.HttpServlet.service(HttpServlet.java:757) 
    javax.servlet.http.HttpServlet.service(HttpServlet.java:847) 
    org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:74) 
    org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76) 

編輯

我部署我的應用程序到JBoss AS 7.它位於/ usr/share/JBoss..7 /在Ubuntu上。也許這很重要。

回答

0

我解決了這個問題。休眠屬性應該通過「休眠」來預先確定。下面的變化訣竅:

<property name="hibernateProperties"> 
    <props> 
    <prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop> 
    <prop key="hibernate.show_sql">true</prop> 
    <prop key="hibernate.hbm2ddl.auto">create-drop</prop> 
    </props> 
</property> 
0

USER是一個特殊的函數名稱,不應該用於您的實體。

+0

不幸的是,這並沒有幫助我。我已經爲我的實體添加了@Table(name =「TBL_USER」),現在我得到:org.hsqldb.HsqlException:用戶缺少權限或找不到對象:TBL_USER – Bladositto