Null values are insering in data base using Struts2 and hibernate

拟墨画扇 提交于 2019-12-04 17:16:24
Roman C

if you want to get something first you need to put something. This rule works everywhere. In your code you need to put the model object to DAO. Then DAO will save it to the db using the values populated in the model via the interceptor. For example

Empmodel queryresult = empdao.add(model); 

For this to work you need to change the method signature to add a parameter for model.

The thing seems trivial but you need to remove the statement that recreate the model in the method implementation, it is not working fine. Also make sure that the model is not empty before you start transaction.

The save method in DAO should check if the new object is created that has null value for id.

if (model.getId() == null)
  session.save(model);
else
  session.update(model);
}

How to implement a ModelDriven with integration hibernate example

Struts2 hibernate integration via s2hibernate plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!