The error message kind of threw me in the wrong direction at first. The problem was indeed the "= null" part of the query.
I fixed the query like this:
t.something = :something
And then the parameter like this:
query.setParameter("something", null);