Hibernate Reference Documentation
20.1.1. Customizing the schema says that:
Quote:
The default attribute lets you specify a default value for a column
(you should assign the same value to the mapped property before saving a new instance of the mapped class).
Code:
<property name="credits" type="integer" insert="false">
<column name="credits" default="10"/>
</property>
[/quote]
What "
you should assign the same value to the mapped property before saving a new instance of the mapped class" means? does it means that the default attribute only applied to hbm2ddl tool?
If that's right, how can I initialize property's default value, especially for String field, because of underlying DB's NOT NULL contraint?
Is it possible to this job in POJO default constructor? sometimes I got the following erros:
Code:
public class ScheduleItem {
private Integer mId;
private String consignee;
private String consigneePhone;
...
public ScheduleItem() {
consignee = "";
consigneePhone = "";
oldFurnitureMoveTo = "";
mOtherNote = "";
mOtherNote2 = "";
mOtherNote3 = "";
mConfirmLog = "";
}
...
}
org.hibernate.AssertionFailure: null id in ScheduleItem entry (don't flush the Session after an exception occurs)
Could anybody do me a favor? thank you.