this.getHibernateTemplate().save() 死循环 10

Action:publicActionForwardadd(ActionMappingmapping,ActionFormform,HttpServletRequestr... Action:
public ActionForward add(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
EmployeeForm employeeForm = (EmployeeForm) form;
Employee employee = new Employee();
BeanUtils.copyProperties(employee, employeeForm);
employee.setPassword(employee.getEmpNo());
employeeManager.addEmployee(employee);
Msg = "添加员工成功!";
request.setAttribute("Msg", Msg);
return mapping.findForward("add_success");
}
------------------------------------------------------------------------------
public void addEmployee(Employee employee) {
try {
this.getHibernateTemplate().save(employee);
}catch(Exception e) {
e.printStackTrace();
throw new AppException("jxc.employee.error.addEmployee");
}
}
-----------------------------------------------------------------------
<!-- 配置sessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
</bean>

<!-- 配置事务管理器 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>

<!-- 配置事务的传播特性 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="del*" propagation="REQUIRED"/>
<tx:method name="modify*" propagation="REQUIRED"/>
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice>

<!-- 哪些类的哪些方法参与事务 -->
<aop:config>
<aop:pointcut id="allManagerMethod" expression="execution(* com.cczu.jxc.business.manager.*.*(..))"/>
<aop:advisor pointcut-ref="allManagerMethod" advice-ref="txAdvice"/>
</aop:config>

<bean name="/emp" class="com.cczu.jxc.web.actions.EmployeeAction">
<property name="employeeManager" ref="employeeManager"/>
</bean>

<bean id="employeeManager" class="com.cczu.jxc.business.manager.EmployeeManagerImpl">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
-----------------------------------------------
this.getHibernateTemplate().save() 死循环,无限主键自增插入数据
展开
 我来答
百度网友b9f3058
2011-05-06 · TA获得超过319个赞
知道答主
回答量:71
采纳率:0%
帮助的人:31.1万
展开全部
public void addEmployee(Employee employee) {
try {
this.getHibernateTemplate().save(employee);
}catch(Exception e) {
e.printStackTrace();
throw new AppException("jxc.employee.error.addEmployee");
}
}
将 this.getHibernateTemplate().save(employee);
改成super.getHibernateTemplate().save(employee);
liu_shui8
2011-04-27 · TA获得超过102个赞
知道小有建树答主
回答量:140
采纳率:0%
帮助的人:128万
展开全部
employee有没有其它的实体关联?
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式