ssh框架对数据库进行修改和删除时的applicationContext.xml如何配置

ssh框架对数据库进行修改和删除时的applicationContext.xml如何配置,第1张

数据库的 *** 作与applicationContext.xml的配置无关。这个文件主要是用来配置sessionfactory的,你看下你的bean有没有配置正确。

大概是这样配:

<bean id="UserDao" class="onlinestock.dao.impl.UserDaoImpl">

</bean>

<bean id="UserService" class="onlinestock.service.impl.UserServiceImpl">

<property name="UserDao">

<ref bean="UserDao" />

</property>

</bean>

<bean id="UserAction" class="onlinestock.action.UserAction">

<property name="UserService">

<ref bean="UserService" />

</property>

</bean>

Session session = this.getSessionFactory.OpenSession()

session.delete(news) //delete

session.beginTranstrions().commit()

session.save(news) //add

//commit 事务

session.update(news)//修改。

注意每个执行完后就要关闭Session。


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/sjk/9424681.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-28
下一篇2023-04-28

发表评论

登录后才能评论

评论列表(0条)

    保存