Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
Hibernate-Version: 3.1.2
Mapping file contains:
Code:
<property name="amount" type="SomeType">
<column name="amount" not-null="true" default="0.0"/>
</property>
Hibernate creates table having amount row:
Code:
Field: amount
Type: decimal(16,6)
Null: NO
Default: 0.000000
So, when I try to store entity with amount == null, Hibernate throws an exception:
Code:
Caused by: org.hibernate.PropertyValueException:
not-null property references a null or transient value: SomeBean.amount
at org.hibernate.engine.Nullability.checkNullability(Nullability.java:72)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:265)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:167)
.......
How to say hibernate dont throw exception and lets database set default column value ?