Hibernate / JPA: Map a legacy database Not Null Foreign Key 'Dummy' value as NULL
Using JPA 1.0, Hibernate 3.4*
I have to develop a JPA solution over a legacy system where foreign keys are defined as NOT NULL with a default value of -999999 (dummy value) to indicate an optional association.
Using @NotFound(action = NotFoundAction.IGNORE) from Hibernate Annotations isn't really helping, since it seems to ignore the @BatchSize annotation, hence producing thousand of single queries whenever the dummy value is encountered.
I suppose I could handle this using a Hibern开发者_JAVA百科ate UserType but this seems quite elaborate for such a scenario, which is not that uncommon ...
Am I missing some obvious trick or default annotation here ?
Thanks
Try @Where(clause="other_id<>-999999") on the association
精彩评论