开发者

Hibernate / JPA: Map a legacy database Not Null Foreign Key 'Dummy' value as NULL

开发者 https://www.devze.com 2023-03-01 19:18 出处:网络
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 as

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

0

精彩评论

暂无评论...
验证码 换一张
取 消