I have web application based on Spring-MVC. I've integrated it with Hibernate 3.6.0. When I'm trying to save entity named User I get :
我有基于Spring-MVC的Web应用程序。我已经将它与Hibernate 3.6.0集成在一起。当我试图保存名为User的实体时,我得到:
org.hsqldb.HsqlException: user lacks privilege or object not found: USER
org.hsqldb.HsqlException:user缺少未找到的权限或对象:USER
I figured out that there is no table USER in the database but why? My configuration file's fragment for springs ServletDispatcher:
我发现数据库中没有表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>
Root exception stack trace:
根异常堆栈跟踪:
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)
EDIT
编辑
I'm deploying my application to JBoss AS 7. It's located on /usr/share/JBoss..7/ on Ubuntu. Maybe it's important.
我正在将我的应用程序部署到JBoss AS 7.它位于Ubuntu上的/usr/share/JBoss..7/。也许这很重要。
2 个解决方案
#1
0
USER is a special function name and should not be used for your entities.
USER是一个特殊的函数名称,不应该用于您的实体。
#2
0
I solved the problem. Hibernate properties in should be precided by "hibernate.". Following change did the trick:
我解决了这个问题。 Hibernate属性应该由“hibernate”预先确定。改变后做了诀窍:
<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>
#1
0
USER is a special function name and should not be used for your entities.
USER是一个特殊的函数名称,不应该用于您的实体。
#2
0
I solved the problem. Hibernate properties in should be precided by "hibernate.". Following change did the trick:
我解决了这个问题。 Hibernate属性应该由“hibernate”预先确定。改变后做了诀窍:
<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>