CreateQuery with excluding NULL and empty String must both work in Oracle and mySQL

120 Views Asked by At

I'm trying to get records in my Transaction table where the message is not empty and not null. It's working on my MySQL DB but it's not working in Oracle DB. Since I think Oracle is treating empty as null.

public List<Transaction> getAllTransactions() {
    return getEntityManager()
            .createQuery("from Transaction as transaction where transaction.message != null AND transaction.message != ''", Transaction.class)
            .getResultList();
}

How can I make this work on both MySQL and Oracle?

0

There are 0 best solutions below