Skip to main content

QuerySearch Expanders 2.26.0

· 2 min read
Frédéric Hannes
Frédéric Hannes
R&D Engineer

Changes and improvements

QueryValueType

The QueryValueType enmumeration is used to indicate the type of an object passed to a query constraint. Usually a developer will not interact with this, as every constraint factory method that takes it as a parameter, also comes with a variant that does not. In the latter case, the type will be inferred from the object that is passed to the constraint. This can only be inferred for known types, which is mostly primitives and java.util.Date.

As a default, when not recognized, the type would automatically be set to String, resulting into a conversion of the object to String in supporting constraints. With this update the type QueryValueType.OBJECT was added which handles the supplied object as a raw value that is passed directly into JPA, as this is sometimes desired.

Since converting to String is typically not intended behavior for objects that are not of that type, the default when a type cannot be determined is now QueryValueType.OBJECT. This is a breaking change, but should have very little impact, as currently, cases where unknown object types are passed to a constraint are likely to be unintended. In cases where this is intended, the migration guide will explain how to resolve this in the new implementation.

Migration guide

QueryValueType migration

In the new implementation, any object that is of unknown type (not a primitive or Date), will now be passed as that object to JPA instead of first converting it to String with .toString(). Any normal string processing will then also not be applied to it. This can be reverted by specifically indicating that you want this value to be handled as a String:

Before
when(filter.getNotAString() != null,
equal("o.someString", filter.getNotAString()))
After
when(filter.getNotAString() != null,
equal("o.someString", STRING, filter.getNotAString()))