spring自动建表 很蛋疼的问题(exception)create update
来源:互联网 发布:linux命令行创建文件 编辑:程序博客网 时间:2024/06/15 07:35
<?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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="org.itec.elwg" />
<bean id="propertyConfiger" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:configuration.properties</value>
</property>
</bean>
<!-- 配置数据源 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
<!-- 配置数据源事务管理器 -->
<bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<!-- 配置sessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.hbm2ddl.auto">create</prop> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
<!-- 实体类 -->
<property name="packagesToScan">
<list>
<value>org.my.entity</value>
</list>
</property>
</bean>
<!-- 配置HibernateTemplate -->
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<!-- 事务通知 -->
<tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED" />
</tx:attributes>
</tx:advice>
<!-- Spring AOP config -->
<aop:config>
<!-- 切入点 -->
<aop:pointcut id="servicePointcut" expression="execution(* org.my.service.impl.*.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="servicePointcut" />
</aop:config>
</beans>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="org.itec.elwg" />
<bean id="propertyConfiger" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:configuration.properties</value>
</property>
</bean>
<!-- 配置数据源 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean>
<!-- 配置数据源事务管理器 -->
<bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<!-- 配置sessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.hbm2ddl.auto">create</prop> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
<!-- 实体类 -->
<property name="packagesToScan">
<list>
<value>org.my.entity</value>
</list>
</property>
</bean>
<!-- 配置HibernateTemplate -->
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<!-- 事务通知 -->
<tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED" />
</tx:attributes>
</tx:advice>
<!-- Spring AOP config -->
<aop:config>
<!-- 切入点 -->
<aop:pointcut id="servicePointcut" expression="execution(* org.my.service.impl.*.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="servicePointcut" />
</aop:config>
</beans>
- spring自动建表 很蛋疼的问题(exception)create update
- Spring整合Hibernate3后,hbm2ddl设置update无法自动建表的解决方法
- Hibernate 的update不能自动建表
- 数据库SQL 表的基本操作(create,drop,alter,insert,update,delete,select)
- django update和create外键时出现问题
- 关于Thinkphp的自动验证create()函数的问题
- Could not create the view An unexpected exception……的问题
- Myeclipse出现Could not create the view: An unexpected exception was thrown.的问题
- spring自动扫描的问题
- hibernate 设置hbm2ddl.auto=create不能自动建表问题
- org.hibernate.exception.SQLGrammarException:Could not execute JDBC batch update问题的解决
- org.hibernate.exception.SQLGrammarExceptionCould not execute JDBC batch update的问题
- org.hibernate.exception.SQLGrammarException:Could not execute JDBC batch update问题的解决
- org.hibernate.exception.SQLGrammarException:Could not execute JDBC batch update问题的解决
- org.hibernate.exception.SQLGrammarException:Could not execute JDBC batch update问题的解决
- spring进阶(三)--bean自动注入混乱的问题
- 数据库创建(CREATE),数据库的修改(Update),数据库的删除(ALERT)
- create index的问题
- PHP购物车怎么生成订单号
- 利用XSS Shell进行XSS测试
- JavaScript修改css样式style
- 转:profibus dp和pa有什么差别
- struts2中获取request、response
- spring自动建表 很蛋疼的问题(exception)create update
- JS 定时器 (setInterval 和 setTimeout 函数)
- Linux下使用SFTP命令
- TKPROF工具
- 智能指针scoped_ptr组件的使用
- C++ STL遍历map的时候如何删除其中的element
- Spring 开发笔记之 java.sql.SQLException: Lock wait timeout exceeded | CannotAcquireLockException 的解决
- 运行时获取方法调用堆栈信息(java)
- c++ vector遍历删除元素 出错的问题