You can map it to java.lang.Long , whose default value is null. Or you can use @PostLoad and reset it to zero if 0 . You can also use @Formula and ignore 0 .
@Formula @Formula , as indicated in the documentation , you can use join conditions .
Since I do not know that your data model providing a valid example is complex. Try:
id_fk is not null or id_fk <> 0
block.
If this does not fit your needs, you can write your own request loader
If you are using some kind of log, enable the show_sql property. And add org.hibernate.sql DEBUG to your configuration.
source share