Here's the situation.
I have a complicated query built using CriteriaBuilder that I don't want to throw away.
I have a field in one of my entities that uses a custom type def (it's an encrypted string).
When I query against that field it runs the parameter I pass through the custom type serializer and uses that to query against the DB.
Code:
CriteriaBuilder cb = entityManager.getCriteriaBuilder();
Root<Entity> from = cb.from(Entity.class);
Predicate p = cb.equal(from.get("someField"), "someValue");
Normally this would be great, but in my case this is not the behaviour I want. I would like to bypass the serialization of the parameter. Is there any way to do that in a CriteriaQuery? Can I somehow query using SQL explicitly or get the entityManager to temporarily treat the field as a plain string rather than the custom type I've defined it to be?
Why don't I want the default behaviour? Because the when I serialize the field I add a string indicating the encryption strategy used directly to the field. So as long as the encryption strategy never changes then my query will have no problem However, if the encryption strategy changes then I need to be able to query against all possible encryption formats used.
An example serialized string might be (using JSON): "{"strategy":"strategy1","data":"nsadkWXc?*"}"