写程序,做产品,过日子

成功其实很简单,就是强迫自己坚持下去

BlogJava 首页 新随笔 联系 聚合 管理
  69 Posts :: 1 Stories :: 92 Comments :: 0 Trackbacks

1. Hibernate can not set null value to primitive types.
If data is null in DB, and Hibernate maps it as primitive type, An PropertyAccessException will be th rowed when.
Our solution (Discussed with Andy):
1) Ensure all Database fileds have default value.
2) Wrap all primitive value in DTO. (Andy says this is not essential.)

2. Debug Hibernate in my product

In single way one-to-many association, when update, Hibernate always update children's id to null!
Only when Bi-one-to-many association, Hibernate can update children correctly.
Do not use Hibernate List. It need a index/list-index property, which bind to a DB column, but means the real index of Java List. The List often get many null items.
Hibernate set is good. But our DTO already use ArrayList as Collection.
Children Id is missing after updated it.
Hibernate session.save normally call insert, session.update normally call update.
When update Bi-one-to-many association, parent always correct. But always insert children, can not delete and update children. CAUSE: I use a modifiable field as PK, because all children's ID is missing from JSP. In this case, I should manual delete and insert children table.

BTW, Set can not include duplicated items. However. Our DTO have no PK when it created until saved it to DB. This cause add new item fail.


Technorati : ,

posted on 2006-11-06 16:59 Welkin Hu 阅读(205) 评论(0)  编辑  收藏 所属分类: Java

只有注册用户登录后才能发表评论。


网站导航: