Hibernate @Where offer

I have a user class that has groups.

    @Where(clause = "enabled = 1 and deleted = 0")
    @Fetch(FetchMode.SUBSELECT)
    public Set<Group> getGroups() {
        return groups;
    }

But when I try to perform some operation on Groupthat is already stored in the database and is not suitable for a sentence @Where, Hibernate simply ignores me.

Actually, @Wherethis is not my solution, but the solution I can find to overcome this (create another dao method to perform some operation) is so ugly.

So, is there a way to overcome this? Or am I missing something? Thanks for the help.

+4
source share
1 answer

enabled deleted @Where .

:

@Where(clause = "enabled = 1 and deleted = 0")

: :

@Where(clause = "enabled = '1' and deleted = '0'")

:

@Where(clause = "enabled = true and deleted = false")

( Java- ) @Where.

+2

Source: https://habr.com/ru/post/1545743/


All Articles