日期:2014-05-18 浏览次数:21245 次
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="username" value="scott"></property>
<property name="password" value="tiger"></property>
<property name="url" value="jdbc:oracle:thin:@localhost:1521:orcl"></property>
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="mappingResources">
<list>
<value>com/data/UserInfo.hbm.xml</value>
</list>
</property>
<!-- 方言 -->
<property name="hibernateProperties">
<value>
hibernate.dialect=org.hibernate.dialect.Oracle10gDialect
</value>
</property>
</bean>
<!-- 事务管理器 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<tx:annotation-driven transaction-manager="transactionManager"/>
@Repository("workoutBusiness")
@Transactional
public class WorkoutBusiness implements IWorkoutBusiness {
@Resource(name="sessionFactory")
SessionFactory sessionFactory;
@Transactional(propagation=Propagation.REQUIRED)
public void saveNewUser(UserInfo user) {
// Session session = sessionFactory.openSession();
Session session = sessionFactory.getCurrentSession();
// Transaction tran = session.beginTransaction();
// tran.begin();
session.save(user);
//tran.commit();
//session.close();
}
}