Hibernate Many-To-One Foreign Key Default 0
Posted
by
user573648
on Stack Overflow
See other posts from Stack Overflow
or by user573648
Published on 2011-01-13T03:48:54Z
Indexed on
2011/01/13
3:53 UTC
Read the original article
Hit count: 195
I have a table where the the parent object has an optional many-to-one relationship. The problem is that the table is setup to default the fkey column to 0.
When selecting, using fetch="join", etc-- the default of 0 on the fkey is being used to try over and over to select from another table for the ID 0. Of course this doesn't exist, but how can I tell Hibernate to treat a value of 0 to be the same as NULL-- to not cycle through 20+ times in fetching a relationship which doesn't exist?
<many-to-one name="device" lazy="false" class="Device" not-null="true" access="field" cascade="none" not-found="ignore">
<column name="DEVICEID" default="0" not-null="false"/>
© Stack Overflow or respective owner