一:public void updateNewsType(FcNewstype fcntype)
{
session=HibernateSessionFactory.getSession();
try {
session.beginTransaction();
session.update(FcNewstype.class, fcntype.getNewsTpeId());
session.beginTransaction().commit();
session.close();
} catch (Exception e) {
System.out.println(e.getMessage());
session.close();
}
}这事我写的一个测试update方法的方法,事务也开启提交了,数据库中就是不更新,提示:Unknown entity: java.lang.Class。二:public void updateNewsType(FcNewstype fcntype)
{
session=HibernateSessionFactory.getSession();
try {
session.beginTransaction();
session.update(FcNewstype.class, fcntype.getNewsTpeId());
session.beginTransaction().commit();
session.close();
} catch (Exception e) {
System.out.println(e.getMessage());
session.close();
}
}
情况和一一样:数据库不更新,Unknown entity: java.lang.Class。
然后我换了三:public void updateNewsType(FcNewstype fcntype)
{
session=HibernateSessionFactory.getSession();
try {
session.beginTransaction();
session.update(fcntype, fcntype.getNewsTpeId());
session.beginTransaction().commit();
session.close();
} catch (Exception e) {
System.out.println(e.getMessage());
session.close();
}
}
数据库还是不更新,什么都不提示了,郁闷。
我用的hibernate和struts框架,没有用spring框架,而且save方法可以插入数据,get方法可以得到数据,唯独update不能更新数据……
{
session=HibernateSessionFactory.getSession();
try {
session.beginTransaction();
session.update(FcNewstype.class, fcntype.getNewsTpeId());
session.beginTransaction().commit();
session.close();
} catch (Exception e) {
System.out.println(e.getMessage());
session.close();
}
}这事我写的一个测试update方法的方法,事务也开启提交了,数据库中就是不更新,提示:Unknown entity: java.lang.Class。二:public void updateNewsType(FcNewstype fcntype)
{
session=HibernateSessionFactory.getSession();
try {
session.beginTransaction();
session.update(FcNewstype.class, fcntype.getNewsTpeId());
session.beginTransaction().commit();
session.close();
} catch (Exception e) {
System.out.println(e.getMessage());
session.close();
}
}
情况和一一样:数据库不更新,Unknown entity: java.lang.Class。
然后我换了三:public void updateNewsType(FcNewstype fcntype)
{
session=HibernateSessionFactory.getSession();
try {
session.beginTransaction();
session.update(fcntype, fcntype.getNewsTpeId());
session.beginTransaction().commit();
session.close();
} catch (Exception e) {
System.out.println(e.getMessage());
session.close();
}
}
数据库还是不更新,什么都不提示了,郁闷。
我用的hibernate和struts框架,没有用spring框架,而且save方法可以插入数据,get方法可以得到数据,唯独update不能更新数据……
解决方案 »
- word文档,带表格,转换成html文件后,样式不一致,求解决
- ireport 3.7.3 table 控件问题
- dorado weblogic 部署出了问题,求救,急!!!!
- 找错:jsp传值小问题
- 在JAVA中如何把日期转化为24进制
- 关于eclipse+jbosside+jsp的简单问题
- jsp编程问题 获取表单提交的数据 附完整代码 需修改
- 可以发给我一份JspSmart类库吗?
- 请教:怎么样验证几个文本框内容有无重复?????
- 看看这个页面 Jsp1.jsp 点击按钮中文不能显示
- struts报at org.apache.struts.util.ModuleUtils.getModuleName错误,怎办?
- FCKeditor中如何用鼠标调整文本框大小?
应该是:session.update(FcNewstype, fcntype.getNewsTpeId());
FcNewsType后面没有.class
刚试过,直接update还是不行……
解决了啦………………按照你说的直接update(fcntype);
但是还得开启事务提交才能更新数据库。