Hibernate custom join clause on association

Posted by myso on Stack Overflow See other posts from Stack Overflow or by myso
Published on 2010-05-10T18:25:19Z Indexed on 2010/05/11 21:34 UTC
Read the original article Hit count: 258

Filed under:
|
|
|

I would like to associate 2 entities using hibernate annotations with a custom join clause. The clause is on the usual FK/PK equality, but also where the FK is null. In SQL this would be something like:

join b on a.id = b.a_id or b.a_id is null

From what I have read I should use the @WhereJoinTable annotation on the owner entity, but I'm puzzled about how I specify this condition...especially the first part of it - referring to the joining entity's id.

Does anyone have an example?

© Stack Overflow or respective owner

Related posts about java

Related posts about hibernate