I am using Hibernate 3.2.6, with annotations 3.3.0
Mysql 5.0
I am working with a legacy database, and am trying to convert the jdbc code to hibernate.
The data is somewhat dirty, specifically
I have a database where one table column references another by the primary key
The column should have been nullable, but instead when no matching row was found the programmer inserted either 0 or -1.
So I have the following mapping in my model file
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "media_id", nullable = true, updatable=false, insertable=false)
private Media media;
and media_id is either a reference to the media table, or is 0 or -1, if no match is found
So I would like hibernate to give null for media, if media_id = 0 or -1
How would I do this?
Thanks
|