<property name="generateDdl" value="true" />时,报表或视图不存在

基于jpa作为持久层,开发项目的时候,在bean.xml的文件中的数据源配置中设置了

<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
		<property name="dataSource" ref="dataSource" />
		<property name="jpaVendorAdapter">
			<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
				<property name="database" value="ORACLE" />
				<property name="showSql" value="true" />
				<property name="generateDdl" value="true" />
			</bean>
		</property>
	</bean>

 一般情况下,会在项目启动的过程中,自动检查注解的实体和数据表,如果数据库不存在的标,会根据实体自动生成,但是,今天,遇到了一个奇怪的一个问题,表始终 没有生成,因此,在其他表应用本来须要生成的表的时候,总是报表或视图找不到的错如:

 

2011-05-06 09:45:56 [org.hibernate.tool.hbm2ddl.SchemaUpdate]-[ERROR] Unsuccessful: alter table r_role_x_menu add constraint FK474DC862E1A553E2 foreign key (menu_id) references p_menu 
2011-05-06 09:45:56 [org.hibernate.tool.hbm2ddl.SchemaUpdate]-[ERROR] ORA-00942: 表或视图不存在 

 

 

解决方案:

 

查看其他的同一表空间的其他用户下是否有相同的的表,如果存在,有的话删除即可,其实避免这种情况的根本方法是,给Oracle用户都指定一个自定义的表空间,不要使用Users表空间。

为以下代码注释:<?xml version="1.0" encoding="UTF-8"?> <project version="4"> <component name="ChangeListManager"> <list default="true" id="0fdc712c-b442-48b5-b5ec-72c0e9b163ca" name="Default Changelist" comment="" /> <option name="SHOW_DIALOG" value="false" /> <option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> <option name="LAST_RESOLUTION" value="IGNORE" /> </component> <component name="ProjectId" id="2QVuimGepuP2YY8QMsZ0qPrP6Yt" /> <component name="ProjectViewState"> <option name="hideEmptyMiddlePackages" value="true" /> <option name="showLibraryContents" value="true" /> </component> <component name="PropertiesComponent"> <property name="RunOnceActivity.OpenProjectViewOnStart" value="true" /> <property name="RunOnceActivity.ShowReadmeOnStart" value="true" /> <property name="WebServerToolWindowFactoryState" value="false" /> <property name="aspect.path.notification.shown" value="true" /> <property name="last_opened_file_path" value="$PROJECT_DIR$" /> <property name="settings.editor.selected.configurable" value="preferences.lookFeel" /> </component> <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" /> <component name="TaskManager"> <task active="true" id="Default" summary="Default task"> <changelist id="0fdc712c-b442-48b5-b5ec-72c0e9b163ca" name="Default Changelist" comment="" /> <created>1685451198775</created> <option name="number" value="Default" /> <option name="presentableId" value="Default" /> <updated>1685451198775</updated> <workItem from="1685451199972" duration="592000" /> <workItem from="1685453362061" duration="917000" /> </task> <servers /> </component> <component name="TypeScriptGeneratedFilesManager"> <option name="version" value="3" /> </component> </project>
05-31
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"> <!-- 1. 组件扫描(根据实际包名修改) --> <context:component-scan base-package="cn.edu.uibe.controller"/> <!-- 2. 注解驱动(必须启用) --> <mvc:annotation-driven/> <!-- 3. 静态资源处理(关键修改) --> <mvc:resources mapping="/statics/**" location="/statics/" cache-period="31536000"/> <mvc:resources mapping="/images/**" location="/images/" cache-period="31536000"/> <!-- 4. 兜底静态资源处理(必须添加) --> <mvc:default-servlet-handler/> <!-- 5. 视图解析器(优化配置) --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/views/"/> <property name="suffix" value=".jsp"/> <!-- 开发阶段建议禁用缓存 --> <property name="cache" value="false"/> </bean> <!-- 6. 文件上传(优化配置) --> <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> <property name="maxUploadSize" value="10485760"/> <!-- 10MB --> <property name="defaultEncoding" value="UTF-8"/> <property name="resolveLazily" value="true"/> </bean> <!-- 7. 拦截器配置(示例,可选) --> <mvc:interceptors> <bean class="cn.edu.uibe.interceptor.AccessInterceptor"/> </mvc:interceptors> <!-- 8. 消息转换器(可选) --> <mvc:message-converters> <bean class="org.springframework.http.converter.StringHttpMessageConverter"> <property name="defaultCharset" value="UTF-8"/> </bean> <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"/> </mvc:message-converters> </beans>/这是spring-mvc.xml文件,给出完整的修改后的文件
07-11
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值