Reputation: 747
I have 2 classes: Msg
and Task
that are 1-to-1.
If i try to save Msg instance without setting Task instance for it i get.
org.hibernate.PropertyValueException: not-null property references a null or transient value: entity3.Msg.task
How do i enable saving Msg without Task? i have this in mapping file for Msg but its not helping
<many-to-one class="entity3.Task" fetch="select" name="task" not-null="false">
<column name="TaskID" not-null="true" unique="true"/>
</many-to-one>
Thanks in advance!
Upvotes: 4
Views: 22453
Reputation: 11829
Try modifying your mapping as below,
<many-to-one class="entity3.Task" fetch="select" name="task"
column="TaskID" not-null="false"> </many-to-one>
The problem could be because you are having a not-null="true"
at the column
definition tag. Read here more about hibernate mappings.
Upvotes: 5