What's New With 2.2.0
This release not only has some bug fixes but several new features that pack a punch.
Major Features
Criteria Query Fluent If Statements - when()
when()
How many times have you been dealing with if statements in order to add some restrictions into your criteria object? Many, this was the only way before, not anymore. So instead of doing something like the following:
This looks like normal code, but we can do a more functional approach by introducing the when()
function:
This function takes in as the first argument a boolean value, if the value is true, then the target closure will be called for you and the criteria will be passed via the arguments scope:
This construct will help you create more fluent designs when building criteria queries, enjoy!
PeekaBoo! - peek()
peek()
We have also enhanced the criteria queries with a peek() function which allows you to peek in the current position of the criteria build up. This allows you to debug or inspect the SQL/HQL inside the criteria at that point in time. You can use it for sending debug data or logging, or auditing.
Enjoy your peekaboo function!
ValidateOrFail()
We have added a new function on the ActiveEntity object to assist with validations. The validateOrFail()
function will allow you to validate the entity and if it validates it just returns the instance of the entity for a nice fluent design. However, if the validation fails, it throws a ValidationException
and the errors are passed to the exception object via the extendedInfo
key. You can then deal with the exception as needed.
Release Notes
Features
: New function for criteria querywhen( boolean, target )
that you can use to build functional criterias without the use of if statements.Feature
: MissingnullValue()
is BaseBuilder classFeature
: Added new criteria querypeek( closure )
function to allow for peeking into the building process. Pass in your closure that receives the criteria and interact with it.Feature
: Added avalidateOrFail()
to the active entity, which if the validation fails it will throw an exception or return back to you the same entity validated now.Improvement
: Better documentation fordeleteById()
since it does bulk deletion, which does not do any type of cascading.Improvement
:isValid()
in active entity missingincludeFields
argumentImprovement
: Timeout hints for criteria builderImprovement
: Updated exception type for criteria builderget()
Bug
: ACF2016 issues with elvis operator.Bug
:getOrFail()
had an invalid throw statement
Last updated