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 : Hibernate, java