I'm using Hibernate version 3.2.4.SP1_CP01-brew within JBoss-4.2.2.GA (build from source).
The datamodel is given for many things by a legacy application.
Numeric foreign key fields are not empty (NULL) but filled with a 0 (zero) which cannot be changed.
Accessing this data gives exceptions like the following:
Code:
Caused by: javax.persistence.EntityNotFoundException: Unable to find biz.mbisoftware.fn.ejb.entity.MbiAdres with id [0]
at org.hibernate.ejb.Ejb3Configuration$Ejb3EntityNotFoundDelegate.handleEntityNotFound(Ejb3Configuration.java:107)
at org.hibernate.proxy.AbstractLazyInitializer.checkTargetState(AbstractLazyInitializer.java:79)
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:68)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:111)
at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.invoke(JavassistLazyInitializer.java:166)
at biz.mbisoftware.fn.ejb.entity.MbiAdres_$$_javassist_1997.getAdressNr(MbiAdres_$$_javassist_1997.java)
The relation field in MbiAdres (uni-directional):
Code:
/** Relation with MbiAdres. */
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumns({
@JoinColumn(name="d_adress_nr",referencedColumnName="adress_nr")
})
private MbiAdres mbiAdresDAdressNr;
Is there a way to configure hibernate to ignore the EntityNotFound and simply set the field to null?
Or better, a way to advise Hibernate to treat a zero within a FK field like NULL as this is not a legal FK/PK value?