Automating the Transaction Logic Layer for Hibernate / JPA Applications
5 rules replace 500 lines of code. That's the claim from Automated Business Logic for their transaction logic engine: an engine that aims to automate the transaction logic layer for applications that plug into Hibernate or JPA. In particular, this framework aims to address the shortcomings of Hibernate's current attribute validation. But really, can we 500 lines of code be replaced?
To ensure certain rules are adhered to, you'll typically need to write logic somewhere - in a service layer, or in your DAOs. But with this engine, by using annotations on your Java (or Groovy) code, you avoid all this complex code. The suggested approach is to add your business logic in a parallel package to your Domain Objects. Annotations in these logic classes identify the methods for business logic - and the logic can be specified in the annotation, or programatically in the method code section.
There's much more to Automated Business Logic - while the constraints are a powerful feature, the engine also helps with multi-table derivations and actions. Complex cases such as allocation can be easily automated.
The pluggable architecture approach taken by the product means that the Hibernate and JPA APIs are preserved - you won't need to refactor your code to get the benefits of the transaction logic engine into your application.
Here's an overview of how it all works:
When you think about it, the approach is great. How much time do you waste writing boilerplate code? If you had the time you'd probably write a framework to get out of the mundane nature of repeating code. It's all provided for you here. There are other benefits - less boring code, means less bugs/maintainance on that code. And, most importantly, you can deliver your product faster.
Initially when I heard about this, I thought that I'd be adding yet another code generation phased into your project. Not so, as it's driven by annotations, and your own logic. If you work with JPA or Hibernate a lot, this could be the solution you've been looking for.
For a more complete overview, check out the following video: