每日累计

hib ernate test the  pojo

方法1 使用默认的配置文件:hibernate.cfg.xml
setup{
Session session = null;
Configuration config = new Configuration().configure();
SessionFactory sessionFactory =
config.buildSessionFactory();
session = sessionFactory.openSession();

}
方法2
setup
File file = new File("c:\\sample\\myhibernate.xml");
Session session = null;
Configuration config = new Configuration().configure(file);
SessionFactory sessionFactory =
config.buildSessionFactory();
session = sessionFactory.openSession();
复制po 到vo
BeanUtils.copyProperties(anotherUser,user);

   作测试时:
    addressDAO.getSessionFactory().getCurrentSession().flush();
   否则数据会在缓存区 中停留。不执行add,及delete 相关操作。

日期转换:DateFormat.getInstance().format(new Date())

οnlοad=document.login.username.focus()

学习好网站

 http://www.myeclipseide.com/images/tutorials/demos/terra_server_client/tutorial.html
http://xfire.codehaus.org/
http://myeclipseide.com/enterpriseworkbench/help/index.jsp?topic=/com.genuitec.myeclipse.doc/html/quickstarts/webservices/index.html
 
 
  http://blog.csdn.net/danny_xcz/archive/2007/02/07/1504218.aspx
 http://www.360doc.com.cn/showWeb/0/1/336000.aspx
 http://www.360doc.com/showWeb/0/0/410239.aspx
 http://blog.csdn.net/danny_xcz/archive/2007/02/07/1504218.aspx
 http://www.360doc.com/showWeb/0/0/487975.aspx
 
 
 http://www.360doc.com/showWeb/0/0/487975.aspx

问题提示:
org.hibernate.PropertyNotFoundException: Could not find a getter for attribute

问题分析:
1)getter()方法写错了,没有按照javaBean的规则写.

2)*.hmb.xml中的属性名和pojo中的是否一致.注意:属性名是否多了空格.
启示:.hbm.xml里的排列最好跟数据库表里的排列一样!最好不要乱改变位置!否则会出莫名其妙的错误!

3)字段的取名要注意。比如数据库中的字段为M_R_ID,映射到hbm.xml为mRId,那么产生的POJO也是mRId,自动产生的getter方 法为:getMRId();相应的setter方法一致,这样就会抛出上面所述异常,这个应该是hibernate的模板格式问题。所以尽量要避免这样的 命名。

解决方法:
1)换做getmRId(); 问题可解决,没有抛出异常,能取值。
2)修改数据库字段名。这个最好,不会产生以后的不确定因素。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值